Skip to content
Zlatko Lakisic edited this page Aug 3, 2026 · 1 revision

Speech (STT / TTS)

Speech path overview


Preferred path (production)

AO ≥ 1.28 advertises speech on WebSocket hello. After SessionBridge.start, the bridge uses:

  • speechClient.transcribe → Ada STT sidecar :8090
  • speechClient.synthesize → Ada TTS sidecar :8091

OpenAI-compatible HTTP. PCM leaves the Pi over LAN — same trust boundary as CPAI. See ADR 0003.

On the AI server:

python speech/stt_server.py --host 0.0.0.0 --port 8090 --model base --device cuda
AGENTIC_SPEECH_TTS_MODEL_DIR=… python speech/tts_server.py --host 0.0.0.0 --port 8091

export AGENTIC_SPEECH_ENABLED=1
export AGENTIC_SPEECH_ADVERTISE_STT_URL=http://<ada-lan-ip>:8090
export AGENTIC_SPEECH_ADVERTISE_TTS_URL=http://<ada-lan-ip>:8091

Confirm WS hello includes "speech": { "enabled": true, "sttBaseUrl": "...", "ttsBaseUrl": "..." }.


Fallback path (Mac / offline / speech disabled)

Service Unit Port Script
STT comstar-stt 127.0.0.1:8090 scripts/stt_server_whisper.py --model tiny --beam-size 5
TTS comstar-tts 127.0.0.1:8091 scripts/tts_server.py

Bridge uses $COMSTAR_STT_URL / $COMSTAR_TTS_URL when speechClient == null.

Use Python 3.12 for .venv-stt — PyAV/faster-whisper struggle on 3.14.

Prefer vs fallback


Live accuracy path

mic → comstar-audio (VAD) → bridge PCM → Reach SpeechClient or HttpSttClient → transcript

STT is batch after VAD end, not streaming.

Debug WAV: /tmp/comstar-last-utterance.wav
Pi archive: /opt/comstar/testdata/stt/live/

Fixture testing

Do not score product STT by replaying one golden WAV ten times — that only proves determinism.

python3 -m unittest discover -s testdata/stt -p 'test_*.py'
COMSTAR_STT_BENCH=1 python3 -m testdata.stt.bench_stt --trials 1 --require-live 10

Labeled fixtures need source: bridge and path: audio→bridge→stt. Parecord/synthetic fixtures are smoke-only.

{
  "file": "utterance.wav",
  "transcript": "How are you doing today",
  "source": "bridge",
  "path": "audio→bridge→stt"
}

STT fixture labeling


Latency notes

Stage Budget
STT (Ada GPU or local tiny) ~1–5 s
TTS ~1 s (first chunk can start earlier)

Full budget: Latency Budget.


Related pages

Clone this wiki locally