export type AzureModels = 'fast'; export type DeepgramModels = 'deepgram/nova-2' | 'deepgram/nova-3'; export type GoogleModels = 'latest_long' | 'latest_short' | 'command_and_search' | 'phone_call' | 'video' | 'default' | 'medical_conversation' | 'medical_dictation'; export type TelnyxModels = 'openai/whisper-tiny' | 'openai/whisper-large-v3-turbo'; export type XaiModels = 'xai/grok-stt'; export type SpeechmaticsModels = 'speechmatics/standard' | 'speechmatics/linden-1'; export type SonioxModels = 'soniox/stt-rt-v4' | 'soniox/stt-rt-v6'; export type ParakeetModels = 'nvidia/parakeet-v3' | 'omi-health/omi-med-stt-v1'; export type HumainModels = 'humain/realtime'; export type Reson8Models = 'reson8/turns'; export type CohereArSttModels = 'cohere/ar-stt'; export type GetApiSpeechToTextTranscriptionArgs = {transcription_engine: 'Azure' | 'Deepgram' | 'Google' | 'Telnyx' | 'xAI' | 'Speechmatics' | 'Soniox' | 'Parakeet' | 'Humain' | 'Reson8' | 'Cohere', input_format: 'mp3' | 'wav' | 'linear16' | 'linear32', sample_rate?: number | undefined, language?: string | undefined, interim_results?: boolean | undefined, model?: (AzureModels | DeepgramModels | GoogleModels | TelnyxModels | XaiModels | SpeechmaticsModels | SonioxModels | ParakeetModels | HumainModels | Reson8Models | CohereArSttModels) | undefined, endpointing?: number | undefined, redact?: string | undefined, keyterm?: string | undefined, keywords?: string | undefined, body: BodyInit}; export type GetApiSpeechToTextTranscriptionOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Speech to text over WebSocket * * GET /speech-to-text/transcription */ export const getApiSpeechToTextTranscription = async (args: GetApiSpeechToTextTranscriptionArgs, options: GetApiSpeechToTextTranscriptionOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") if (args.transcription_engine != null) query.append("transcription_engine", String(args.transcription_engine)) if (args.input_format != null) query.append("input_format", String(args.input_format)) if (args.sample_rate != null) query.append("sample_rate", String(args.sample_rate)) if (args.language != null) query.append("language", String(args.language)) if (args.interim_results != null) query.append("interim_results", String(args.interim_results)) if (args.model != null) query.append("model", String(args.model)) if (args.endpointing != null) query.append("endpointing", String(args.endpointing)) if (args.redact != null) query.append("redact", String(args.redact)) if (args.keyterm != null) query.append("keyterm", String(args.keyterm)) if (args.keywords != null) query.append("keywords", String(args.keywords)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/speech-to-text/transcription${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };