UNPKG

audio-transcripter

Version:

Lightweight TypeScript library for transcribing audio files using Google Gemini 2.0 models. Supports local files, remote URLs, and Blobs.

42 lines (41 loc) 2.28 kB
import type { TranscriptionConfig, RunTranscriptionResult } from "./types"; /** * Transcribe audio from a local file path or a remote URL. * * @param {TranscriptionConfig} config - Configuration options for transcription. * @param {string} config.audioFile - Path to a local audio file or URL of a remote audio file. * @param {string} [config.style='conversational'] - Transcription style, e.g., 'conversational' or 'formal'. * @param {string} [config.language='english'] - Language code or name of the audio language. * @param {boolean} [config.verbose=true] - Enable verbose logging of processing steps and errors. * @param {number} [config.timeout=5000] - Timeout in milliseconds for checking remote URL availability. * * @returns {Promise<RunTranscriptionResult>} A promise that resolves to a structured transcription result * including success status, transcription text (if successful), or error message. * * @throws Will not throw errors but return structured error results on failures such as: * - Invalid or missing audio file path/URL * - Local file not found or inaccessible * - Remote URL unreachable or timing out * - Unexpected errors during transcription process * * @example * const result = await runTranscription({ audioFile: "./audio.wav" }); * if (result.success) { * console.log("Transcription:", result.transcription); * } else { * console.error("Error:", result.error); * } */ export declare function runTranscription(config: TranscriptionConfig): Promise<RunTranscriptionResult>; /** * Transcribe audio from a Blob object. * * @param {Blob} audioBlob - The audio Blob to transcribe. * @param {Omit<TranscriptionConfig, "audioFile">} options - Transcription options excluding audioFile. * @param {string} [options.style='conversational'] - Transcription style. * @param {string} [options.language='english'] - Language of the audio. * @param {boolean} [options.verbose=true] - Enable verbose logging. * * @returns {Promise<RunTranscriptionResult>} The transcription result with success status and error or transcription. */ export declare function runTranscriptionWithBlob(audioBlob: Blob, options?: Omit<TranscriptionConfig, "audioFile">): Promise<RunTranscriptionResult>;