Skip to content

feat: add voice interaction to jarvis chat (--voice flag)#539

Open
jeremyboles76 wants to merge 1 commit into
open-jarvis:mainfrom
jeremyboles76:feat/voice-interaction
Open

feat: add voice interaction to jarvis chat (--voice flag)#539
jeremyboles76 wants to merge 1 commit into
open-jarvis:mainfrom
jeremyboles76:feat/voice-interaction

Conversation

@jeremyboles76

Copy link
Copy Markdown

Summary

  • Add --voice flag to jarvis chat enabling full duplex voice I/O (mic-in -> STT -> LLM -> TTS -> speaker-out)
  • New src/openjarvis/speech/voice_io.py: mic recording with automatic silence detection (record_until_silence) and WAV playback (play_wav) via sounddevice/soundfile
  • _record_voice() in chat_cmd.py: auto-discovers the best available STT backend (faster-whisper -> openai -> deepgram), records, transcribes, and returns text
  • _speak() in chat_cmd.py: tries TTS backends in priority order (kokoro -> openai_tts -> cartesia) and plays the synthesised WAV response
  • REPL loop distinguishes empty transcription (loop and listen again) from Ctrl-C / fatal error (clean exit)

Test plan

  • Install deps: pip install sounddevice numpy soundfile faster-whisper kokoro
  • jarvis chat --voice -- speak a question, confirm transcription prints, confirm response is read aloud
  • Silence with no speech -> "Nothing heard -- try again" message, loop continues
  • Ctrl-C during recording -> clean exit with "Goodbye!"
  • jarvis chat (no flag) -> unchanged text-only behavior
  • Missing TTS deps -> graceful warning printed, chat continues in text-only mode

Generated with Claude Code

Add a `--voice` flag to `jarvis chat` that enables full voice I/O:
mic recording with automatic silence detection feeds a speech-to-text
backend, and each assistant response is synthesised and played back via
a text-to-speech backend.

New file `src/openjarvis/speech/voice_io.py`:
- `record_until_silence()` — 16 kHz mono mic capture via sounddevice;
  stops after ~1.5 s of silence (RMS threshold) or a 30 s safety cap;
  returns raw WAV bytes.
- `play_wav()` — plays WAV bytes through the default output device using
  sounddevice + soundfile (handles both WAV-headered and raw PCM).

Changes to `src/openjarvis/cli/chat_cmd.py`:
- `--voice` / `voice_mode` flag wired into the click command.
- `_record_voice()` helper: discovers the best available STT backend
  (faster-whisper → openai → deepgram), records, transcribes, and
  returns the text; returns a sentinel on Ctrl-C / fatal error so the
  REPL loop can distinguish try-again from exit.
- `_speak()` helper: tries TTS backends in priority order (kokoro →
  openai_tts → cartesia) and plays the synthesised WAV back.
- Banner updated to advertise voice mode when active.
- openjarvis.speech imported eagerly so TTS registry is populated
  before the first turn.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants