Switch config to JSON

This commit is contained in:
Thales Maciel 2026-02-06 18:53:02 -03:00
parent 123dc0160b
commit b296491703
6 changed files with 127 additions and 36 deletions

View file

@ -1,6 +1,6 @@
# lel
X11 transcription daemon that records audio and runs Whisper, logging the transcript.
X11 transcription daemon that records audio, runs Whisper, logs the transcript, and can optionally run AI post-processing before injecting text.
## Requirements
@ -13,26 +13,37 @@ X11 transcription daemon that records audio and runs Whisper, logging the transc
## Build
```bash
go build -o leld ./cmd/leld
go build -o lelctl ./cmd/lelctl
make build
```
## Config
Create `~/.config/lel/config.toml`:
Create `~/.config/lel/config.json`:
```toml
hotkey = "Cmd+m"
ffmpeg_input = "pulse:default"
whisper_model = "base"
whisper_lang = "en"
whisper_device = "cpu"
whisper_extra_args = ""
record_timeout_sec = 120
whisper_timeout_sec = 300
segment_sec = 5
streaming = false
injection_backend = "clipboard"
```json
{
"hotkey": "Cmd+m",
"ffmpeg_input": "pulse:default",
"ffmpeg_path": "",
"whisper_model": "base",
"whisper_lang": "en",
"whisper_device": "cpu",
"whisper_extra_args": "",
"record_timeout_sec": 120,
"whisper_timeout_sec": 300,
"segment_sec": 5,
"streaming": false,
"injection_backend": "clipboard",
"ai_enabled": true,
"ai_provider": "ollama",
"ai_model": "llama3.2:3b",
"ai_temperature": 0.0,
"ai_system_prompt_file": "",
"ai_base_url": "http://localhost:11434",
"ai_api_key": "",
"ai_timeout_sec": 20
}
```
Env overrides:
@ -41,11 +52,14 @@ Env overrides:
- `WHISPER_FFMPEG_IN`
- `WHISPER_STREAM`, `WHISPER_SEGMENT_SEC`, `WHISPER_TIMEOUT_SEC`
- `LEL_RECORD_TIMEOUT_SEC`, `LEL_HOTKEY`, `LEL_INJECTION_BACKEND`
- `LEL_FFMPEG_PATH`
- `LEL_AI_ENABLED`, `LEL_AI_PROVIDER`, `LEL_AI_MODEL`, `LEL_AI_TEMPERATURE`, `LEL_AI_SYSTEM_PROMPT_FILE`
- `LEL_AI_BASE_URL`, `LEL_AI_API_KEY`, `LEL_AI_TIMEOUT_SEC`
## Run manually
```bash
./leld --config ~/.config/lel/config.toml
./leld --config ~/.config/lel/config.json
```
Disable the tray icon:
@ -70,11 +84,26 @@ systemctl --user enable --now lel
- Press it again to stop and transcribe.
- The transcript is logged to stderr.
Execution flow (single in-flight state machine):
- `recording` -> `transcribing` -> `processing` (optional) -> `outputting` -> `idle`
Injection backends:
- `clipboard`: copy to clipboard and inject via Ctrl+V (requires `xclip` + `xdotool`)
- `injection`: type the text with simulated keypresses (requires `xdotool`)
AI providers:
- `ollama`: calls the local Ollama HTTP API (`/api/generate`)
- `openai_compat`: calls a chat-completions compatible API (`/v1/chat/completions`)
Dependency checks:
- Recording requires `ffmpeg` (or set `ffmpeg_path`)
- Transcribing uses the `whisper` CLI
- Outputting requires `xclip` (and `xdotool` for injection backends)
Control:
```bash