import { type APIConnectOptions, stt } from '@livekit/agents'; import type { AudioFrame } from '@livekit/rtc-node'; import type { V2Models } from './models.js'; /** * Configuration options for STTv2 (Deepgram Flux model). */ export interface STTv2Options { apiKey?: string; model: V2Models | string; sampleRate: number; keyterms: string[]; endpointUrl: string; language?: string; eagerEotThreshold?: number; eotThreshold?: number; eotTimeoutMs?: number; mipOptOut?: boolean; tags?: string[]; /** * List of language hints to bias the model for improved accuracy. * Only usable with `flux-general-multi`. */ languageHint?: string[]; } /** * Deepgram STTv2 using the Flux model for streaming speech-to-text. * * This uses Deepgram's V2 API (`/v2/listen`) which provides turn-based * transcription with support for preemptive generation. * * @remarks * Key differences from STT (V1): * - Uses `TurnInfo` events instead of `SpeechStarted`/`Results` * - Supports `eagerEotThreshold` for preemptive LLM generation * - Sends `PREFLIGHT_TRANSCRIPT` events when eager end-of-turn is detected * * @example * ```typescript * import { STTv2 } from '@livekit/agents-plugin-deepgram'; * * const stt = new STTv2({ * model: 'flux-general-en', * eagerEotThreshold: 0.5, // Enable preemptive generation * }); * * const stream = stt.stream(); * stream.pushFrame(audioFrame); * * for await (const event of stream) { * if (event.type === SpeechEventType.FINAL_TRANSCRIPT) { * console.log(event.alternatives?.[0]?.text); * } * } * ``` */ export declare class STTv2 extends stt.STT { #private; readonly label = "deepgram.STTv2"; /** * Create a new Deepgram STTv2 instance. * * @param opts - Configuration options * @param opts.apiKey - Deepgram API key (defaults to `DEEPGRAM_API_KEY` env var) * @param opts.model - Model to use (default: `flux-general-en`) * @param opts.eagerEotThreshold - Threshold (0.3-0.9) for preemptive generation * @param opts.eotThreshold - End-of-turn detection threshold (default: 0.7) * @param opts.eotTimeoutMs - End-of-turn timeout in ms (default: 3000) * @param opts.keyterms - List of key terms to improve recognition * @param opts.tags - Tags for usage reporting (max 128 chars each) * @param opts.languageHint - List of language hints to bias the model for improved accuracy. * Only usable with `flux-general-multi`. * * @throws Error if no API key is provided */ constructor(opts?: Partial); /** The model being used for transcription */ get model(): string; /** The STT provider name */ get provider(): string; protected _recognize(_frame: AudioFrame | AudioFrame[], _abortSignal?: AbortSignal): Promise; /** * Create a new streaming transcription session. * * @param options - Stream options * @returns A SpeechStream that emits transcription events */ stream(options?: { connOptions?: APIConnectOptions; }): stt.SpeechStream; /** * Update STT options. Changes will take effect on the next stream. * * @param opts - Partial options to update */ updateOptions(opts: Partial): void; } //# sourceMappingURL=stt_v2.d.ts.map