import type { Uploadable } from 'openai/uploads.js'; import { type AIMLAPIClient } from '../client'; /** * Audio file input for speech-to-text */ export interface AudioInput { /** * The audio file to transcribe (for file upload) */ file?: Uploadable; /** * The URL of the audio file to transcribe (for URL-based transcription) */ url?: string; } /** * Base speech-to-text parameters */ export interface SpeechToTextParams { /** * The model to use for transcription */ model: 'aai/slam-1' | 'aai/universal' | '#g1_whisper-tiny' | 'openai/gpt-4o-mini-transcribe'; /** * The audio file or URL to transcribe */ audio: AudioInput; } /** * Extended speech-to-text parameters that support all model-specific options */ export interface SpeechToTextCreateParams extends SpeechToTextParams { audio_start_from?: number; audio_end_at?: number; language_code?: string; language_confidence_threshold?: number; language_detection?: boolean; punctuate?: boolean; format_text?: boolean; disfluencies?: boolean; multichannel?: boolean; speaker_labels?: boolean; speakers_expected?: number; content_safety?: boolean; iab_categories?: boolean; custom_spelling?: Array<{ from: string; to: string; }>; auto_highlights?: boolean; word_boost?: string[]; boost_param?: 'low' | 'default' | 'high'; filter_profanity?: boolean; redact_pii?: boolean; redact_pii_audio?: boolean; redact_pii_audio_quality?: 'mp3' | 'wav'; redact_pii_policies?: string[]; redact_pii_sub?: 'entity_name' | 'hash'; sentiment_analysis?: boolean; entity_detection?: boolean; summarization?: boolean; summary_model?: 'informative' | 'conversational' | 'catchy'; summary_type?: 'bullets' | 'bullets_verbose' | 'gist' | 'headline' | 'paragraph'; auto_chapters?: boolean; speech_threshold?: number; custom_intent?: string[]; custom_topic?: string[]; custom_intent_mode?: string; custom_topic_mode?: string; detect_language?: boolean; detect_entities?: boolean; detect_topics?: boolean; diarize?: boolean; dictation?: boolean; filler_words?: boolean; intents?: string[]; keywords?: string[]; language?: string; measurements?: boolean; multi_channel?: boolean; numerals?: boolean; paragraphs?: boolean; profanity_filter?: boolean; search?: boolean; sentiment?: boolean; smart_format?: boolean; summarize?: boolean; topics?: string[]; utterances?: boolean; utt_split?: boolean; prompt?: string; temperature?: number; } /** * Speech-to-text creation response */ export interface SpeechToTextCreateResponse { generation_id: string; } /** * Response from getting speech-to-text status */ export interface SpeechToTextStatusResponse { id: string; status: 'queued' | 'generating' | 'completed' | 'error'; result?: TranscriptionResult; error?: string; } /** * Transcription word details */ export interface TranscriptionWord { word: string; start: number; end: number; confidence: number; speaker?: string | null; } /** * Transcription sentence */ export interface Sentence { text: string; start: number; end: number; } /** * Transcription paragraph */ export interface Paragraph { sentences: Sentence[]; num_words: number; start: number; end: number; } /** * Transcription alternative */ export interface TranscriptionAlternative { transcript: string; confidence: number; words: TranscriptionWord[]; paragraphs?: Paragraph[]; } /** * Channel results */ export interface ChannelResults { alternatives: TranscriptionAlternative[]; } /** * Transcription metadata * Transcription results metadata */ export interface TranscriptionMetadata { /** * A unique transaction key; currently always "deprecated". */ transaction_key: string; /** * A UUID identifying this specific transcription request. */ request_id: string; /** * The SHA-256 hash of the submitted audio file (for pre-recorded requests). */ sha256: string; /** * ISO-8601 timestamp. */ created: string; /** * Length of the audio in seconds. */ duration: number; /** * The top-level results object containing per-channel transcription alternatives. */ channels: number; /** * List of model UUIDs used for this transcription */ models: string[]; /** * Mapping from each model UUID (in 'models') to detailed info: its name, version, and architecture. */ model_info: Record; } /** * Full transcription result (detailed format) */ export interface DetailedTranscriptionResult { /** * Metadata about the transcription response, including timing, models, and IDs. */ metadata: TranscriptionMetadata; /** * The top-level results object containing per-channel transcription alternatives. */ results: { /** * Per-channel transcription results */ channels: Record; }; } /** * Simple transcription result (for OpenAI models) */ export interface SimpleTranscriptionResult { /** * The transcribed text */ text: string; /** * Usage information */ usage?: { /** * Type of usage (tokens) */ type: 'tokens'; /** * Number of input tokens */ input_tokens: number; /** * Details about input tokens */ input_token_details: { /** * Number of text tokens */ text_tokens: number; /** * Number of audio tokens */ audio_tokens: number; }; /** * Number of output tokens */ output_tokens: number; /** * Total number of tokens */ total_tokens: number; }; } /** * Union type for different transcription result formats */ export type TranscriptionResult = DetailedTranscriptionResult | SimpleTranscriptionResult; /** * Response from getting speech-to-text status */ export interface SpeechToTextStatusResponse { /** * The generation ID */ generation_id: string; /** * Status of the transcription task */ status: 'queued' | 'generating' | 'completed' | 'error'; /** * The transcription result if completed */ result?: TranscriptionResult; /** * Error message if failed */ error?: string; } /** * Speech-to-Text resource class that handles parameter transformation */ export declare class SpeechToText { private readonly _client; constructor(_client: AIMLAPIClient); /** * Create a speech-to-text transcription task * Transforms our extended interface to the API format before making the request * @see https://docs.aimlapi.com/api-references/speech-models/speech-to-text/stt-create * * @example * ```typescript * const result = await client.speechToText.create({ * model: 'aai/slam-1', * audio: { url: 'https://example.com/audio.mp3' } * }); * console.log("Generation ID:", result.generation_id); * ``` */ create(params: SpeechToTextCreateParams): Promise; /** * Get the status and result of a speech-to-text task * @see https://docs.aimlapi.com/api-references/speech-models/speech-to-text/stt-get * * @example * ```typescript * const status = await client.speechToText.getStatus("generation-id"); * if (status.status === "completed") { * console.log("Transcript:", status.result); * } * ``` */ getStatus(generationId: string): Promise; /** * Create a transcription with automatic polling for completion * Useful for long audio files that take time to process. * * @param params - The transcription parameters * @param pollInterval - How often to poll for status (in seconds) * @param pollTimeout - Maximum time to wait (in seconds) */ createWithPolling(params: SpeechToTextCreateParams, pollInterval?: number, pollTimeout?: number): Promise; /** * Transform our extended SpeechToTextCreateParams to the API format */ private _transformToApiParams; /** * Add model-specific parameters to FormData (for file uploads) */ private _addModelSpecificParams; /** * Convert Uploadable to Blob */ private _toBlob; } //# sourceMappingURL=speech-to-text.d.ts.map