fix: add STT timeout, move finally restart to thread, guard exit on recording

- Set OpenAI client timeout=30s in transcribe_audio() — default 600s
  blocks _voice_processing for 10 min if Groq/OpenAI stalls
- Move _voice_start_recording in _voice_stop_and_transcribe finally
  block to a daemon thread (same pattern as Ctrl+B handler and
  process_loop)
- Add _should_exit guard at top of _voice_start_recording so all 4
  call sites respect shutdown without individual checks
This commit is contained in:
0xbyt4 2026-03-10 14:30:12 +03:00
parent bcf4513cb3
commit 0a89933f9b
2 changed files with 11 additions and 7 deletions

View file

@ -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(