Skip to content

fix: await ears warmup on boot, give instant PTT release feedback, and support configurable TTS device - #36

Open
pcarff wants to merge 1 commit into
jaredrhod:mainfrom
pcarff:fix/warmup-deadlock-and-release-feedback
Open

pcarff wants to merge 1 commit into
jaredrhod:mainfrom
pcarff:fix/warmup-deadlock-and-release-feedback

Conversation

@pcarff

@pcarff pcarff commented Sep 7, 2026

Copy link
Copy Markdown

Symptoms

  1. Startup STT deadlock on PTT press: If the user presses the PTT key immediately after the greeting speaks or during launch, the process can deadlock/hang in listen_for_ptt(). The console appears hung and the microphone never completes transcription.
  2. Missing release feedback: When releasing the PTT key after speaking, there is no immediate visual indication in stdout or on the signals bus until transcription completes. On slower compute configurations, this feels like an unresponsive freeze.
  3. TTS device locked to CPU: Kokoro TTS initialization in mouth.py previously hardcoded device="cpu", preventing systems with available CUDA compute from leveraging GPU acceleration for speech synthesis.

Causes

  1. In main.py, warm_ears_fut = loop.run_in_executor(None, warm_ears) was dispatched in the background to warm the Whisper STT model during the greeting and brain connect. However, main.py never awaited warm_ears_fut before entering the main interaction loop. If the user pressed the PTT key before the background STT warm-up finished, transcribe() and warm_ears() raced on loading/running the model pipeline, blocking the thread or deadlocking the loop.
  2. In ears.py, release of the PTT button (on_release()) stopped audio recording and put an audio chunk into _audio_q, but stdout logging ([ptt] transcribing...) and signal state updates (signals.set_state("thinking")) were deferred until after transcribe() completed or started later in the consumer.
  3. config.py had no tts_device setting (unlike stt_device), so Kokoro's pipeline always defaulted to CPU.

The Fix

  • main.py: Explicitly await warm_ears_fut (with a 60-second timeout) right after the brain is confirmed warm, ensuring STT model initialization is 100% complete before any user utterances can be captured.
  • ears.py: Added immediate stdout feedback ([ptt] transcribing...) and set the visualizer signal state to "thinking" the moment the PTT key is released, giving the user and attached visualizers (e.g. ai-visualizer, barehands) instant feedback that speech is being processed. Added early-stage debug logging before heavier model imports.
  • config.py & mouth.py: Added "tts_device": "cpu" configuration option (supporting "cpu" or "cuda") in DEFAULTS, and pass device=CFG.get("tts_device", "cpu") to Kokoro's KPipeline.

Deliberately Unchanged

  • Whisper STT defaults (stt_model: small.en, stt_device: auto, stt_compute: int8) and existing microphone stream mechanics are untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant