/** What the host's server needs to sign the Transcribe URL. */ export interface AwsTranscribeUrlRequest { /** An Amazon Transcribe language code, such as `it-IT`. */ readonly languageCode: string; readonly mediaEncoding: 'pcm'; /** Hz. One of 8000, 16000, 44100 or 48000, matching the audio sent. */ readonly sampleRate: number; } export interface AwsTranscribeDictationOptions { /** * Fetches a pre-signed `wss://transcribestreaming..amazonaws.com` * URL for this request from the host's server. Honour `signal`: it aborts * when the user stops before the stream opens. */ getUrl: (request: AwsTranscribeUrlRequest, signal: AbortSignal) => Promise; /** The Transcribe language code, or a function read at each start. */ languageCode: string | (() => string); } /** The kit's dictation seam (`onDictate`). */ export type DictationSession = (ctx: { signal: AbortSignal; onPartialTranscript: (text: string) => void; onFinalTranscript: (text: string) => void; }) => Promise; export type AwsTranscribeErrorCode = /** The browser cannot capture audio or open the stream. */ 'unsupported' /** The user or the browser refused the microphone. */ | 'permission' /** The host could not sign a URL. */ | 'url' /** The WebSocket failed. */ | 'connection' /** Transcribe refused or stopped the stream. */ | 'service'; export declare class AwsTranscribeError extends Error { readonly code: AwsTranscribeErrorCode; constructor(code: AwsTranscribeErrorCode, detail?: string); } /** `it` or `it-IT` → `it-IT`; null for a language this map does not cover. */ export declare function awsLanguageCode(uiLanguage: string): string | null; /** The PCM rate to send for an audio context running at `contextRate`. */ export declare function transmitSampleRate(contextRate: number): number; /** Linear resampling, enough for speech. */ export declare function resample(input: Float32Array, fromRate: number, toRate: number): Float32Array; /** Float samples to little-endian 16-bit PCM. */ export declare function toPcm16(input: Float32Array): Uint8Array; /** The results inside a TranscriptEvent payload. */ export declare function transcriptResults(payload: unknown): { text: string; partial: boolean; }[]; /** Whether this browser can run Transcribe dictation at all. */ export declare function isAwsTranscribeSupported(): boolean; /** * Dictation through Amazon Transcribe, for any of the kit's `onDictate` props. * * Each call is one session: it resolves when the stream ends (after the user * stops and Transcribe has sent its last phrase) and rejects with an * `AwsTranscribeError` when it cannot start or fails. Finished phrases arrive * through `onFinalTranscript`, including one that completes just after the * user stops; the phrase being spoken arrives through `onPartialTranscript`. */ export declare function createAwsTranscribeDictation(options: AwsTranscribeDictationOptions): DictationSession; //# sourceMappingURL=aws-transcribe.d.ts.map