working config.toml file
This commit is contained in:
@@ -213,6 +213,7 @@ The daemon automatically creates `~/.config/hyprvoice/config.toml` with helpful
|
|||||||
buffer_size = 8192 # Internal buffer size in bytes (larger = less CPU, more latency)
|
buffer_size = 8192 # Internal buffer size in bytes (larger = less CPU, more latency)
|
||||||
device = "" # PipeWire audio device (empty = use default microphone)
|
device = "" # PipeWire audio device (empty = use default microphone)
|
||||||
channel_buffer_size = 30 # Audio frame buffer size (frames to buffer)
|
channel_buffer_size = 30 # Audio frame buffer size (frames to buffer)
|
||||||
|
timeout = "5m" # Maximum recording duration (e.g., "30s", "2m", "5m")
|
||||||
|
|
||||||
# Speech Transcription Configuration
|
# Speech Transcription Configuration
|
||||||
[transcription]
|
[transcription]
|
||||||
@@ -257,8 +258,15 @@ format = "s16" # Audio format (s16 recommended)
|
|||||||
buffer_size = 8192 # Internal buffer size in bytes
|
buffer_size = 8192 # Internal buffer size in bytes
|
||||||
device = "" # PipeWire device (empty for default)
|
device = "" # PipeWire device (empty for default)
|
||||||
channel_buffer_size = 30 # Audio frame buffer size
|
channel_buffer_size = 30 # Audio frame buffer size
|
||||||
|
timeout = "5m" # Maximum recording duration (prevents runaway recordings)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Recording Timeout:**
|
||||||
|
- Prevents accidental long recordings that could consume resources
|
||||||
|
- Default: 5 minutes (`"5m"`)
|
||||||
|
- Format: Go duration strings like `"30s"`, `"2m"`, `"10m"`
|
||||||
|
- Recording automatically stops when timeout is reached
|
||||||
|
|
||||||
#### Text Injection
|
#### Text Injection
|
||||||
|
|
||||||
Configurable text injection with multiple modes:
|
Configurable text injection with multiple modes:
|
||||||
|
|||||||
@@ -21,12 +21,13 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RecordingConfig struct {
|
type RecordingConfig struct {
|
||||||
SampleRate int `toml:"sample_rate"`
|
SampleRate int `toml:"sample_rate"`
|
||||||
Channels int `toml:"channels"`
|
Channels int `toml:"channels"`
|
||||||
Format string `toml:"format"`
|
Format string `toml:"format"`
|
||||||
BufferSize int `toml:"buffer_size"`
|
BufferSize int `toml:"buffer_size"`
|
||||||
Device string `toml:"device"`
|
Device string `toml:"device"`
|
||||||
ChannelBufferSize int `toml:"channel_buffer_size"`
|
ChannelBufferSize int `toml:"channel_buffer_size"`
|
||||||
|
Timeout time.Duration `toml:"timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TranscriptionConfig struct {
|
type TranscriptionConfig struct {
|
||||||
@@ -56,6 +57,7 @@ func (c *Config) ToRecordingConfig() recording.Config {
|
|||||||
BufferSize: c.Recording.BufferSize,
|
BufferSize: c.Recording.BufferSize,
|
||||||
Device: c.Recording.Device,
|
Device: c.Recording.Device,
|
||||||
ChannelBufferSize: c.Recording.ChannelBufferSize,
|
ChannelBufferSize: c.Recording.ChannelBufferSize,
|
||||||
|
Timeout: c.Recording.Timeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +102,9 @@ func (c *Config) Validate() error {
|
|||||||
if c.Recording.Format == "" {
|
if c.Recording.Format == "" {
|
||||||
return fmt.Errorf("invalid recording.format: empty")
|
return fmt.Errorf("invalid recording.format: empty")
|
||||||
}
|
}
|
||||||
|
if c.Recording.Timeout <= 0 {
|
||||||
|
return fmt.Errorf("invalid recording.timeout: %v", c.Recording.Timeout)
|
||||||
|
}
|
||||||
|
|
||||||
// Transcription
|
// Transcription
|
||||||
if c.Transcription.Provider == "" {
|
if c.Transcription.Provider == "" {
|
||||||
@@ -228,6 +233,7 @@ func SaveDefaultConfig() error {
|
|||||||
buffer_size = 8192 # Internal buffer size in bytes (larger = less CPU, more latency)
|
buffer_size = 8192 # Internal buffer size in bytes (larger = less CPU, more latency)
|
||||||
device = "" # PipeWire audio device (empty = use default microphone)
|
device = "" # PipeWire audio device (empty = use default microphone)
|
||||||
channel_buffer_size = 30 # Audio frame buffer size (frames to buffer)
|
channel_buffer_size = 30 # Audio frame buffer size (frames to buffer)
|
||||||
|
timeout = "5m" # Maximum recording duration (e.g., "30s", "2m", "5m")
|
||||||
|
|
||||||
# Speech Transcription Configuration
|
# Speech Transcription Configuration
|
||||||
[transcription]
|
[transcription]
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/leonardotrapani/hyprvoice/internal/config"
|
"github.com/leonardotrapani/hyprvoice/internal/config"
|
||||||
"github.com/leonardotrapani/hyprvoice/internal/injection"
|
"github.com/leonardotrapani/hyprvoice/internal/injection"
|
||||||
@@ -68,7 +67,7 @@ func (p *pipeline) Run(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
runCtx, cancel := context.WithTimeout(ctx, 5*time.Minute)
|
runCtx, cancel := context.WithTimeout(ctx, p.config.Recording.Timeout)
|
||||||
p.setCancel(cancel)
|
p.setCancel(cancel)
|
||||||
|
|
||||||
p.wg.Add(1)
|
p.wg.Add(1)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type Config struct {
|
|||||||
BufferSize int
|
BufferSize int
|
||||||
Device string
|
Device string
|
||||||
ChannelBufferSize int
|
ChannelBufferSize int
|
||||||
|
Timeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type Recorder struct {
|
type Recorder struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user