|
|
@@ -63,7 +63,8 @@ stateful lives in the assistant, which is a separate process (see
|
|
|
Clone the repo and install with `uv`:
|
|
|
|
|
|
```bash
|
|
|
-cd /home/efren/Repositories/STT-TTS
|
|
|
+# From the repo root (wherever you cloned it)
|
|
|
+cd /path/to/STT-TTS
|
|
|
|
|
|
# Sync dependencies (installs into .venv)
|
|
|
uv sync
|
|
|
@@ -85,7 +86,8 @@ cp config.example.toml config.toml
|
|
|
|
|
|
### Configuration Reference
|
|
|
|
|
|
-The config file is TOML. Here are all available options with defaults:
|
|
|
+The config file is TOML. Here are all available options with defaults.
|
|
|
+`config.example.toml` ships values only; this section is the annotated reference.
|
|
|
|
|
|
```toml
|
|
|
[audio]
|
|
|
@@ -109,7 +111,7 @@ rms_floor = 0.008 # Drop segments quieter than this RMS (noi
|
|
|
trailing_trim_ms = 200 # Keep only this much trailing silence (less hallucination-prone padding)
|
|
|
|
|
|
[whisper]
|
|
|
-model = "small" # "tiny", "base", "small", "medium", "large"
|
|
|
+model = "small" # "tiny"/"base"/"small"/"medium"/"large" (multilingual; do NOT use `.en` variants)
|
|
|
device = "cpu" # "cpu" or "cuda"
|
|
|
compute_type = "int8" # "int8" (CPU) or "float16" (CUDA, slower but more accurate)
|
|
|
language = "auto" # "auto" (detect), "en", "es", or None/""/"none"
|
|
|
@@ -264,7 +266,9 @@ uv run stt-daemon --backend sounddevice --device 0 # device 0 = default input
|
|
|
|
|
|
### Subcommands
|
|
|
|
|
|
-The `stt-daemon` CLI supports these subcommands:
|
|
|
+The `stt-daemon` CLI supports these subcommands. Every subcommand also accepts the
|
|
|
+common overrides `--config`, `--device`, `--backend`, `--model`, `--language`, and
|
|
|
+`-v/--verbose` (for example `stt-daemon setup --device ...`).
|
|
|
|
|
|
#### `setup` — Create virtual sink and loopbacks
|
|
|
|
|
|
@@ -462,8 +466,12 @@ refused unless a TUI is attached.
|
|
|
`stt-ctl` verbs (one message each): `command-start`, `command-execute`, `command-cancel`,
|
|
|
`command-edit --text "..."`, `chat-toggle`, `status`.
|
|
|
|
|
|
+Clients attach by sending `subscribe` first (`viewer: true` for the TUI, which makes the
|
|
|
+assistant treat it as a watcher for the `require_viewer` gate).
|
|
|
+
|
|
|
Assistant → clients: `mode`, `command_text`, `transcript`, `speech_start`/`speech_stop`,
|
|
|
-`tool_call`, `tool_result`, `chat_message`, `heartbeat`, `error`.
|
|
|
+`tool_call`, `tool_result`, `chat_message`, `heartbeat`, `error`, plus the direct
|
|
|
+replies `ack` (command accepted) and `status`.
|
|
|
|
|
|
### Audit
|
|
|
|
|
|
@@ -674,7 +682,12 @@ Tests cover:
|
|
|
- **Pre-roll buffer** preservation: confirm the first frames are not cut
|
|
|
- **Silence finalization**: utterances end after N silence frames
|
|
|
- **Min/max utterance duration**: blips are discarded, long utterances are finalized
|
|
|
+- **Pause-aligned chunking**: long speech splits at pauses (`end_reason = "pause"`)
|
|
|
- **Config loading and language normalization**
|
|
|
+- **Provisioning**: `setup`/`ensure`/`teardown`, orphan-name cleanup, and `clear` idempotency
|
|
|
+- **Event bus**: envelope codec, ring replay, subscriber fan-out
|
|
|
+- **Assistant**: mode machine, command readiness/timeouts, tool schema validation, LLM client/history trimming, audit log
|
|
|
+- **TUI**: pure view-state reducer and control-socket client
|
|
|
|
|
|
## Development
|
|
|
|
|
|
@@ -688,6 +701,10 @@ src/stt_daemon/
|
|
|
├── ctl.py - One-shot control client (`stt-ctl`, hotkeys)
|
|
|
├── config.py - Config loading (TOML)
|
|
|
├── audio.py - Audio capture (parec, sounddevice)
|
|
|
+├── pulse.py - PulseAudio/pactl wrapper (devices, modules, sink checks)
|
|
|
+├── provisioner.py - Virtual sink + loopback lifecycle (setup/ensure/teardown)
|
|
|
+├── state.py - Provisioning state file (~/.local/state/stt-daemon/audio.json)
|
|
|
+├── picker.py - Interactive device picker (questionary / numbered menu)
|
|
|
├── segmenter.py - VAD + pre-roll buffer + utterance segmentation (core)
|
|
|
├── transcriber.py - Faster-Whisper wrapper
|
|
|
├── output.py - Sinks (stdout, JSONL, optional WAV)
|
|
|
@@ -702,13 +719,14 @@ src/stt_daemon/
|
|
|
│ ├── tools.py - Tool registry + schema validation + get_datetime
|
|
|
│ ├── llm.py - llama.cpp client + chat session (block trimming)
|
|
|
│ ├── audit.py - Daily action audit log
|
|
|
-│ └── runner.py - `stt-assistant` process
|
|
|
+│ ├── runner.py - `stt-assistant` process
|
|
|
+│ └── __main__.py - Entry point for `python -m stt_daemon.assistant`
|
|
|
└── tui/
|
|
|
├── state.py - Pure view-state reducer
|
|
|
├── client.py - Control-socket client
|
|
|
└── app.py - Textual app + `stt-tui` entry point
|
|
|
|
|
|
-tests/ - 196 tests, no audio hardware or live LLM required
|
|
|
+tests/ - 206 tests, no audio hardware or live LLM required
|
|
|
|
|
|
scripts/
|
|
|
├── audio-sink.sh - Thin wrapper over `stt-daemon setup|clear|list`
|
|
|
@@ -724,18 +742,15 @@ uv run ruff check .
|
|
|
### Building/packaging
|
|
|
|
|
|
```bash
|
|
|
-# Install hatchling if needed
|
|
|
-uv pip install hatchling
|
|
|
-
|
|
|
-# Build wheel
|
|
|
-uv run python -m build
|
|
|
+# Build sdist + wheel (hatchling backend, installed in an isolated env by uv)
|
|
|
+uv build
|
|
|
```
|
|
|
|
|
|
## Limitations & Design Decisions
|
|
|
|
|
|
1. **Mono only**: Stereo support can be added, but speech is typically mono in transcription pipelines
|
|
|
2. **Single language per transcription**: Whisper detects one language per utterance; mixed-language speech is attributed to the dominant language
|
|
|
-3. **No LLM integration**: This is transcription-only; use the JSONL output to feed an LLM if needed
|
|
|
+3. **LLM is optional and separate**: the daemon itself is transcription-only; the `stt-assistant` process adds chat/commands/tools on top, and can be disabled with `[llm].enabled = false`
|
|
|
4. **PulseAudio/PipeWire-Pulse**: The default `parec` backend assumes UNIX-like systems with PulseAudio. macOS/Windows should use `sounddevice`
|
|
|
5. **Real-time**: Latency depends on frame duration (30ms), silence threshold (default 700ms), and model size. Expect ~1–3 second latency with `small` model on CPU
|
|
|
6. **Thread-safe queues**: Reader thread (audio) is separate from worker thread (transcription) so audio never blocks waiting for transcription
|
|
|
@@ -748,7 +763,7 @@ uv run python -m build
|
|
|
|
|
|
## License
|
|
|
|
|
|
-This project is MIT-licensed. See LICENSE file (if included).
|
|
|
+This project is ISC-licensed. See [`LICENSE.md`](LICENSE.md).
|
|
|
|
|
|
---
|
|
|
|