feat: hold-mode PTT with TTS interrupt, tag-based polyglot TTS, and local TTS retry#328
Open
luisdemarchi wants to merge 2 commits intombailey:masterfrom
Open
Conversation
…evity rules - polyglot_tts.py: detect PT/EN language segments and synthesize each with the appropriate Kokoro voice, then concatenate audio (VOICEMODE_POLYGLOT=true) - ptt.py: toggle push-to-talk via configurable key (default F9) using pynput; replaces continuous microphone VAD when VOICEMODE_PTT_MODE=toggle - cli_commands/voice_notify.py: 'voicemode notify pre|post <tool>' command for Claude Code PreToolUse/PostToolUse hooks; speaks tool name via TTS when a voice session is active (VOICEMODE_TOOL_NOTIFY=true) - converse tool: integrates PTT via record_audio_smart(), touches voice session state file on every call, injects polyglot TTS in text_to_speech_with_failover - prompts/converse.py + converse docstring: strict brevity rules so Claude keeps voice responses to 1-2 sentences and avoids preambles/summaries - pyproject.toml: adds optional [ptt] extra for pynput dependency Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ocal TTS retry ## Push-to-Talk: hold mode + TTS interrupt - Rewrote PTT from toggle-mode to hold-mode (hold key to record, release to send) - Global pynput listener starts eagerly at server startup so PTT is ready on the very first response - Pressing the PTT key during TTS playback immediately aborts the stream and starts recording — no need to wait for Claude to finish speaking - `audio_player.py`: track active player in `_current_playback` global so PTT can call `stop()` from any thread - `streaming.py`: poll `interrupt_streaming` event inside the chunk loop and call `stream.abort()` to cut off PCM playback mid-stream - `core.py`: treat interrupted TTS as success (no buffered fallback) ## Polyglot TTS: tag-based detection - Primary strategy now uses explicit `<en>...</en>` / `<pt>...</pt>` tags that Claude annotates in its responses, replacing unreliable heuristic detection - Heuristic word-scoring retained but disabled by default; opt-in via `VOICEMODE_POLYGLOT_HEURISTIC=true` - Added `parse_tag_segments()` and `strip_language_tags()` helpers - Tags are stripped before non-polyglot TTS so they are never read aloud - `prompts/converse.py` and `tools/converse.py` updated with rules instructing Claude to annotate English terms in Portuguese responses ## Local TTS retry - `simple_failover.py`: retry up to 3 times (2s/4s/8s backoff) on connection errors from local providers (e.g. Kokoro restarting after hitting UVICORN_LIMIT_MAX_REQUESTS) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<en>...</en>tags annotated by Claude. Tags are stripped before synthesis so they are never read aloud. Heuristic mode preserved as opt-in (VOICEMODE_POLYGLOT_HEURISTIC=true).UVICORN_LIMIT_MAX_REQUESTS).Details
Push-to-Talk: hold mode + interrupt
pynputlistener starts eagerly at server startup (not lazily on first recording) so PTT is ready from the very first responseaudio_player.py: tracks active player in_current_playbackglobal so PTT can stop it from any threadstreaming.py: pollsinterrupt_streamingevent inside the PCM chunk loop and callsstream.abort()to cut off playback mid-streamcore.py: treats an interrupted TTS stream as success (avoids triggering buffered fallback)pynput(+evdevon Linux)Polyglot TTS: tag-based detection
<en>...</en>tags via updated system prompts inprompts/converse.pyandtools/converse.pypolyglot_tts.py: newparse_tag_segments()parses tags into(lang, text)pairs; newstrip_language_tags()removes tags before non-polyglot synthesisLocal TTS retry
simple_failover.py: detects connection-error strings and retries withasyncio.sleepbackoff for local endpoints only; non-connection failures and remote endpoints fail-fast as beforeTest plan
<en>word</en>tags uses English voice for tagged segments<en>or</en>aloud🤖 Generated with Claude Code