voice-to-text-converter
Version:
A modern, lightweight Node.js package for speech-to-text conversion with support for multiple engines
108 lines • 3.51 kB
TypeScript
import { EventEmitter } from 'events';
import { VoiceToTextOptions, SpeechRecognitionConfig, SpeechRecognitionResult, AudioInputConfig, EngineConfig, MicrophoneOptions, SpeechRecognitionEvents, BrowserSupport } from './types';
/**
* Main VoiceToText converter class
*/
export declare class VoiceToText extends EventEmitter {
private options;
private currentEngine;
private isInitialized;
constructor(options?: VoiceToTextOptions);
/**
* Initialize the voice-to-text converter
*/
initialize(): Promise<void>;
/**
* Convert speech from microphone to text
*/
fromMicrophone(options?: MicrophoneOptions): Promise<void>;
/**
* Convert speech from audio file to text
*/
fromFile(filePath: string, config?: SpeechRecognitionConfig): Promise<SpeechRecognitionResult[]>;
/**
* Convert speech from audio stream to text
*/
fromStream(stream: NodeJS.ReadableStream, config?: SpeechRecognitionConfig): Promise<SpeechRecognitionResult[]>;
/**
* Start continuous speech recognition
*/
startListening(audioConfig: AudioInputConfig, config?: SpeechRecognitionConfig): Promise<void>;
/**
* Stop speech recognition
*/
stopListening(): Promise<void>;
/**
* Abort speech recognition
*/
abort(): Promise<void>;
/**
* Check if currently listening/recording
*/
get isListening(): boolean;
/**
* Get current engine information
*/
getCurrentEngine(): {
type: string;
available: boolean;
capabilities: any;
} | null;
/**
* Switch to a different engine
*/
switchEngine(engineConfig: EngineConfig): Promise<void>;
/**
* Get available engines in current environment
*/
static getAvailableEngines(): Array<EngineConfig['engine']>;
/**
* Check if a specific engine is available
*/
static isEngineAvailable(engineType: EngineConfig['engine']): boolean;
/**
* Get engine capabilities
*/
static getEngineCapabilities(engineType: EngineConfig['engine']): any;
/**
* Get browser support information
*/
static getBrowserSupport(): BrowserSupport;
/**
* Create a quick instance for one-time use
*/
static quickTranscribe(source: string | NodeJS.ReadableStream | 'microphone', options?: {
engine?: EngineConfig['engine'];
duration?: number;
language?: string;
config?: SpeechRecognitionConfig;
}): Promise<SpeechRecognitionResult[]>;
/**
* Clean up resources
*/
cleanup(): Promise<void>;
/**
* Ensure the converter is initialized
*/
private ensureInitialized;
/**
* Select the best available engine
*/
private selectEngine;
/**
* Set up event forwarding from engine to main class
*/
private setupEngineEvents;
/**
* Handle engine fallback on error
*/
private handleEngineFallback;
/**
* Type-safe event emitter methods
*/
emit<K extends keyof SpeechRecognitionEvents>(event: K, ...args: Parameters<SpeechRecognitionEvents[K]>): boolean;
on<K extends keyof SpeechRecognitionEvents>(event: K, listener: SpeechRecognitionEvents[K]): this;
once<K extends keyof SpeechRecognitionEvents>(event: K, listener: SpeechRecognitionEvents[K]): this;
off<K extends keyof SpeechRecognitionEvents>(event: K, listener: SpeechRecognitionEvents[K]): this;
}
//# sourceMappingURL=voice-to-text.d.ts.map