"""Speech-to-text for the actual query, after the wake word fires. The "guaranteed" fallback for when stt_stream's opportunistic live-feed session didn't produce a transcript (streaming disabled, or the socket never came up). There is no separate one-shot REST endpoint server-side any more — /desk/stt is a websocket relay only — so this connects the exact same way stt_stream.py does and just feeds the whole buffered utterance in one go instead of frame-by-frame as it's captured. That connection is unconditional (not gated by STT_STREAMING, which only controls the opportunistic optimisation), since there is nothing left to fall back to if it fails. """ from __future__ import annotations from .. import config from . import stt_stream class SttError(Exception): pass def transcribe(pcm) -> str: if not config.is_configured(): raise SttError("BOLT_SERVER_URL / DESK_API_KEY not set") try: socket = stt_stream.connect() except Exception as exc: raise SttError(f"couldn't reach the transcription server: {exc}") from exc session = stt_stream.StreamingTranscriber(socket) session.feed(pcm) return session.finish()