import type { WebSocket } from 'ws';
import { type LanguageCode } from '../language.js';
import { STT as BaseSTT, SpeechStream as BaseSpeechStream, type SpeechEvent } from '../stt/index.js';
import { type APIConnectOptions } from '../types.js';
import { type AudioBuffer } from '../utils.js';
import { type VAD } from '../vad.js';
import { type AnyString } from './utils.js';
export type DeepgramModels = 'deepgram/nova-3' | 'deepgram/nova-3-medical' | 'deepgram/nova-2' | 'deepgram/nova-2-medical' | 'deepgram/nova-2-conversationalai' | 'deepgram/nova-2-phonecall';
export type DeepgramFluxModels = 'deepgram/flux-general' | 'deepgram/flux-general-en' | 'deepgram/flux-general-multi';
export type CartesiaModels = 'cartesia/ink-whisper' | 'cartesia/ink-2';
export type AssemblyaiModels = 'assemblyai/universal-streaming' | 'assemblyai/universal-streaming-multilingual' | 'assemblyai/u3-rt-pro';
export type ElevenlabsSTTModels = 'elevenlabs/scribe_v2_realtime';
export type XaiSTTModels = 'xai/stt-1';
export type SpeechmaticsModels = 'speechmatics/enhanced' | 'speechmatics/standard';
export type InworldSTTModels = 'inworld/inworld-stt-1';
export interface CartesiaOptions {
    /** Minimum volume threshold. Default: not specified. */
    min_volume?: number;
    /** Maximum silence duration in seconds. Default: not specified. */
    max_silence_duration_secs?: number;
}
export interface DeepgramOptions {
    /** Enable filler words. Default: true. */
    filler_words?: boolean;
    /** Enable interim results. Default: true. */
    interim_results?: boolean;
    /** Endpointing timeout in milliseconds. Default: 25. */
    endpointing?: number;
    /** Enable punctuation. Default: false. */
    punctuate?: boolean;
    /** Enable smart formatting. */
    smart_format?: boolean;
    /** Keywords with boost values. */
    keywords?: Array<[string, number]>;
    /** Key terms for recognition. */
    keyterms?: string[];
    /** Enable profanity filter. */
    profanity_filter?: boolean;
    /** Convert spoken numbers to numerals. */
    numerals?: boolean;
    /** Opt out of model improvement program. */
    mip_opt_out?: boolean;
    /** Enable speaker diarization. Default: false. */
    diarize?: boolean;
}
export interface DeepgramFluxOptions {
    /** Eager end-of-turn threshold (0.3–0.9). Enables preflight transcripts for preemptive generation. Default: 0.5. */
    eager_eot_threshold?: number;
    /** End-of-turn threshold (0.5–0.9). */
    eot_threshold?: number;
    /** End-of-turn timeout in milliseconds. */
    eot_timeout_ms?: number;
    /** Key terms for recognition. */
    keyterm?: string | string[];
    /** Opt out of model improvement program. Default: false. */
    mip_opt_out?: boolean;
    /** Language hint. */
    language_hint?: string;
    /** Enable automatic language detection. */
    detect_language?: boolean;
}
export interface AssemblyAIOptions {
    /** Enable turn formatting. Default: false. */
    format_turns?: boolean;
    /** End of turn confidence threshold. Default: 0.01. */
    end_of_turn_confidence_threshold?: number;
    /** Minimum silence duration in milliseconds when confident about end of turn. Default: 0. */
    min_end_of_turn_silence_when_confident?: number;
    /** Maximum turn silence in milliseconds. Default: not specified. */
    max_turn_silence?: number;
    /** Key terms prompt for recognition. Default: not specified. */
    keyterms_prompt?: string[];
    /** Enable speaker diarization. Default: false. */
    speaker_labels?: boolean;
}
export interface XaiOptions {
    /** Enable speaker diarization. Default: false. */
    diarize?: boolean;
    /** Silence duration in ms before utterance-final (0-5000). */
    endpointing?: number;
    /** Enable Inverse Text Normalization. Requires language. */
    format?: boolean;
    /** Default true; set false to opt out of interim transcripts. */
    interim_results?: boolean;
}
export interface SpeechmaticsOptions {
    /** Domain to use, for example "finance". */
    domain?: string;
    /** BCP-47 locale for output formatting. */
    output_locale?: string;
    /** Maximum delay in seconds. Valid range is 0.7-4.0. Default: 1.0. */
    max_delay?: number;
    /** Maximum delay mode. */
    max_delay_mode?: 'flexible' | 'fixed' | string;
    /** Enable diarization for modes other than "none". */
    diarization?: 'none' | 'speaker' | 'channel' | 'channel_and_speaker_change' | 'speaker_change' | string;
    /** Speaker diarization sensitivity. Valid range is 0.0-1.0. */
    speaker_sensitivity?: number;
    /** Maximum number of speakers to detect. */
    max_speakers?: number;
    /** Prefer grouping nearby words as the current speaker. */
    prefer_current_speaker?: boolean;
    /** Enable partial results. Default: true, overridden by the gateway. */
    enable_partials?: boolean;
    /** Enable entity recognition. */
    enable_entities?: boolean;
    /** Punctuation override configuration. */
    punctuation_overrides?: Record<string, unknown>;
    /** Additional vocabulary entries for custom dictionary support. */
    additional_vocab?: Array<Record<string, unknown>>;
    /** Seconds of silence before finalizing an utterance. */
    end_of_utterance_silence_trigger?: number;
    /** Audio filtering configuration. */
    audio_filtering_config?: Record<string, unknown>;
    /** Transcript filtering configuration. */
    transcript_filtering_config?: Record<string, unknown>;
}
export interface InworldSTTOptions {
    /** Enable Voice Profile detection. Default: true. */
    enable_voice_profile?: boolean;
    /** Max labels per category in voice-profile responses (1–20). Default: 10. */
    voice_profile_top_n?: number;
    /** Enable word-level timestamps. Default: true. */
    include_word_timestamps?: boolean;
    /** Wire-format encoding sent to Inworld. Default: LINEAR16. */
    audio_encoding?: 'LINEAR16' | 'AUTO_DETECT';
    /** Stop transcription after this many seconds of silence; 0 disables. */
    inactivity_timeout_seconds?: number;
    /** End-of-turn confidence threshold (0.0–1.0). Default: 0.5. */
    end_of_turn_confidence_threshold?: number;
    /** Domain-specific contextual hints passed to the model. */
    prompts?: string[];
    /** Minimum end-of-turn silence in milliseconds when confident. */
    min_end_of_turn_silence_when_confident?: number;
    /** VAD threshold (0.0–1.0). Default: 0.5. */
    vad_threshold?: number;
}
export type STTLanguages = 'multi' | 'en' | 'de' | 'es' | 'fr' | 'ja' | 'pt' | 'zh' | 'hi' | AnyString;
type _STTModels = DeepgramModels | DeepgramFluxModels | CartesiaModels | AssemblyaiModels | ElevenlabsSTTModels | XaiSTTModels | SpeechmaticsModels | InworldSTTModels;
export type STTModels = _STTModels | 'auto' | AnyString;
export type ModelWithLanguage = `${_STTModels}:${STTLanguages}` | STTModels;
export type STTOptions<TModel extends STTModels> = TModel extends DeepgramFluxModels ? DeepgramFluxOptions : TModel extends DeepgramModels ? DeepgramOptions : TModel extends CartesiaModels ? CartesiaOptions : TModel extends AssemblyaiModels ? AssemblyAIOptions : TModel extends XaiSTTModels ? XaiOptions : TModel extends SpeechmaticsModels ? SpeechmaticsOptions : TModel extends InworldSTTModels ? InworldSTTOptions : Record<string, unknown>;
/** Inference Fallback Adapter: configuration for a fallback STT model that runs server-side in LiveKit Inference, providing automatic fallback between providers. Extra fields are passed through to the provider. */
export interface STTFallbackModel {
    /** Model name (e.g. "deepgram/nova-3", "assemblyai/universal-streaming", "cartesia/ink-whisper"). */
    model: string;
    /** Extra configuration for the model. */
    extraKwargs?: Record<string, unknown>;
}
export type STTFallbackModelType = STTFallbackModel | string;
/** Parse a model string into [model, language]. Language is undefined if not specified. */
export declare function parseSTTModelString(model: string): [string, LanguageCode | undefined];
/** Normalize a single or list of FallbackModelType into STTFallbackModel[]. */
export declare function normalizeSTTFallback(fallback: STTFallbackModelType | STTFallbackModelType[]): STTFallbackModel[];
export type STTEncoding = 'pcm_s16le';
export interface InferenceSTTOptions<TModel extends STTModels> {
    model?: TModel;
    language?: LanguageCode;
    encoding: STTEncoding;
    sampleRate: number;
    baseURL: string;
    apiKey: string;
    apiSecret: string;
    modelOptions: STTOptions<TModel>;
    fallback?: STTFallbackModel[];
    connOptions?: APIConnectOptions;
}
/**
 * Livekit Cloud Inference STT
 */
export declare class STT<TModel extends STTModels> extends BaseSTT {
    #private;
    private opts;
    private streams;
    private vad?;
    private _vadPromise?;
    /**
     * Resolves to the VAD instance for the current model, or `undefined` if the model
     * handles endpointing server-side. Lazily computed on first read.
     */
    get vadPromise(): Promise<VAD | undefined>;
    constructor(opts?: {
        model?: ModelWithLanguage;
        language?: STTLanguages;
        baseURL?: string;
        encoding?: STTEncoding;
        sampleRate?: number;
        apiKey?: string;
        apiSecret?: string;
        modelOptions?: STTOptions<TModel>;
        fallback?: STTFallbackModelType | STTFallbackModelType[];
        connOptions?: APIConnectOptions;
        vad?: VAD;
    });
    get label(): string;
    get model(): string;
    get provider(): string;
    static fromModelString(modelString: string): STT<AnyString>;
    protected _recognize(_: AudioBuffer): Promise<SpeechEvent>;
    updateOptions(opts: Partial<Pick<InferenceSTTOptions<TModel>, 'model' | 'language' | 'modelOptions'>>): void;
    stream(options?: {
        language?: STTLanguages | string;
        connOptions?: APIConnectOptions;
    }): SpeechStream<TModel>;
    connectWs(timeout: number): Promise<WebSocket>;
}
export declare class SpeechStream<TModel extends STTModels> extends BaseSpeechStream {
    #private;
    private opts;
    private requestId;
    private speaking;
    private speechDuration;
    private reconnectEvent;
    private stt;
    private connOptions;
    private activeWs?;
    constructor(sttImpl: STT<TModel>, opts: InferenceSTTOptions<TModel>, connOptions: APIConnectOptions);
    get label(): string;
    updateOptions(opts: Partial<Pick<InferenceSTTOptions<TModel>, 'model' | 'language' | 'modelOptions'>>): void;
    protected run(): Promise<void>;
    private processTranscript;
}
export {};
//# sourceMappingURL=stt.d.ts.map