diff --git a/cli.py b/cli.py index 98476a4270..f874448f1f 100755 --- a/cli.py +++ b/cli.py @@ -3544,6 +3544,8 @@ class HermesCLI: def _voice_start_recording(self): """Start capturing audio from the microphone.""" + if getattr(self, '_should_exit', False): + return from tools.voice_mode import AudioRecorder, check_voice_requirements reqs = check_voice_requirements() @@ -3691,12 +3693,14 @@ class HermesCLI: # (When transcript IS submitted, process_loop handles restart # after chat() completes.) if self._voice_continuous and not submitted and not self._voice_recording: - try: - self._voice_start_recording() - if hasattr(self, '_app') and self._app: - self._app.invalidate() - except Exception: - pass + def _restart_recording(): + try: + self._voice_start_recording() + if hasattr(self, '_app') and self._app: + self._app.invalidate() + except Exception: + pass + threading.Thread(target=_restart_recording, daemon=True).start() def _voice_speak_response(self, text: str): """Speak the agent's response aloud using TTS (runs in background thread).""" diff --git a/tools/transcription_tools.py b/tools/transcription_tools.py index 7f217bc77e..d7c0a84bbd 100644 --- a/tools/transcription_tools.py +++ b/tools/transcription_tools.py @@ -150,7 +150,7 @@ def transcribe_audio(file_path: str, model: Optional[str] = None) -> Dict[str, A try: from openai import OpenAI, APIError, APIConnectionError, APITimeoutError - client = OpenAI(api_key=api_key, base_url=base_url) + client = OpenAI(api_key=api_key, base_url=base_url, timeout=30) with open(file_path, "rb") as audio_file: transcription = client.audio.transcriptions.create(