Download server/realtime-stt-provider.ts from taqarub/node-api: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/taqarub/node-api/resolve/main/server/realtime-stt-provider.ts
- Command line
-
hf download hf://spaces/taqarub/node-api/server/realtime-stt-provider.ts
-
curl -L -o realtime-stt-provider.ts https://huggingface.co/spaces/taqarub/node-api/resolve/main/server/realtime-stt-provider.ts
966 Bytes
| import type { BufferedAudioFrame } from "../shared/realtime-voice-protocol"; | |
| export type SendVoiceMessage = (message: Record<string, unknown>) => void; | |
| export interface RealtimeSttRecognizer { | |
| start(): Promise<void>; | |
| accept(frame: BufferedAudioFrame): void; | |
| stop(): void; | |
| close(): void; | |
| acknowledgedSequence(): number; | |
| replayTranscriptEvents(): void; | |
| } | |
| export type SttProvider = "existing" | "shihab"; | |
| export type SttEnvironment = Record<string, string | undefined>; | |
| 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; | |
| } | |