import type { BufferedAudioFrame } from "../shared/realtime-voice-protocol"; export type SendVoiceMessage = (message: Record) => void; export interface RealtimeSttRecognizer { start(): Promise; accept(frame: BufferedAudioFrame): void; stop(): void; close(): void; acknowledgedSequence(): number; replayTranscriptEvents(): void; } export type SttProvider = "existing" | "shihab"; export type SttEnvironment = Record; export function resolveSttProvider( environment: SttEnvironment = process.env, ): SttProvider { const configured = (environment.STT_PROVIDER ?? "shihab") .trim() .toLowerCase(); if (configured !== "existing" && configured !== "shihab") { throw new Error( `Unsupported STT_PROVIDER=${configured}; expected existing or shihab`, ); } if (configured === "shihab" && !environment.SHIHAB_API_KEY?.trim()) { return "existing"; } return configured; }