import React$1, { ReactNode } from 'react'; /** * Simple EventEmitter implementation for browser compatibility */ declare class EventEmitter { private events; on(event: string, listener: Function): this; once(event: string, listener: Function): this; off(event: string, listener: Function): this; emit(event: string, ...args: any[]): boolean; removeAllListeners(event?: string): this; } /** * Configuration options for speech recognition engines */ interface SpeechRecognitionConfig { /** Language code (e.g., 'en-US', 'es-ES') */ language?: string; /** Sample rate for audio processing */ sampleRate?: number; /** Enable continuous recognition */ continuous?: boolean; /** Return interim results */ interimResults?: boolean; /** Maximum number of alternatives to return */ maxAlternatives?: number; /** Confidence threshold (0-1) */ confidenceThreshold?: number; /** Custom vocabulary or phrases to improve recognition */ phrases?: string[]; /** Audio encoding format */ encoding?: 'LINEAR16' | 'FLAC' | 'MULAW' | 'AMR' | 'AMR_WB' | 'OGG_OPUS' | 'SPEEX_WITH_HEADER_BYTE'; } /** * Speech recognition result */ interface SpeechRecognitionResult { /** Transcribed text */ transcript: string; /** Confidence score (0-1) */ confidence: number; /** Whether this is a final result */ isFinal: boolean; /** Alternative transcriptions */ alternatives?: Array<{ transcript: string; confidence: number; }>; /** Timestamp information */ timestamp?: { start: number; end: number; }; } /** * Audio input source configuration */ interface AudioInputConfig { /** Audio source type */ source: 'microphone' | 'file' | 'stream'; /** File path (for file source) */ filePath?: string; /** Audio stream (for stream source) */ audioStream?: NodeJS.ReadableStream; /** Device ID (for microphone source) */ deviceId?: string; /** Recording duration in milliseconds (for microphone) */ duration?: number; } /** * Engine-specific configuration */ interface EngineConfig { /** Engine type */ engine: 'web-speech' | 'vosk' | 'google-cloud' | 'whisper'; /** API key (for cloud services) */ apiKey?: string; /** Model path (for offline engines like Vosk) */ modelPath?: string; /** Project ID (for Google Cloud) */ projectId?: string; /** Custom endpoint URL */ endpoint?: string; } /** * Error types that can occur during speech recognition */ declare enum SpeechRecognitionErrorType { NO_SPEECH = "no-speech", ABORTED = "aborted", AUDIO_CAPTURE = "audio-capture", NETWORK = "network", NOT_ALLOWED = "not-allowed", SERVICE_NOT_ALLOWED = "service-not-allowed", BAD_GRAMMAR = "bad-grammar", LANGUAGE_NOT_SUPPORTED = "language-not-supported", ENGINE_ERROR = "engine-error", INVALID_CONFIG = "invalid-config" } /** * Speech recognition error */ declare class SpeechRecognitionError extends Error { type: SpeechRecognitionErrorType; originalError?: Error | undefined; constructor(type: SpeechRecognitionErrorType, message: string, originalError?: Error | undefined); } /** * Events emitted by speech recognition engines */ interface SpeechRecognitionEvents { 'start': () => void; 'result': (result: SpeechRecognitionResult) => void; 'end': () => void; 'error': (error: SpeechRecognitionError) => void; 'audiostart': () => void; 'audioend': () => void; 'soundstart': () => void; 'soundend': () => void; 'speechstart': () => void; 'speechend': () => void; 'initialized': () => void; 'started': () => void; 'stopped': () => void; } /** * Base interface for speech recognition engines */ interface ISpeechRecognitionEngine extends EventEmitter { /** Start speech recognition */ start(audioConfig: AudioInputConfig, recognitionConfig?: SpeechRecognitionConfig): Promise; /** Stop speech recognition */ stop(): Promise; /** Abort speech recognition */ abort(): Promise; /** Check if engine is available */ isAvailable(): boolean; /** Get supported languages */ getSupportedLanguages(): string[]; /** Process audio file directly */ processFile(file: File, config?: SpeechRecognitionConfig): Promise; /** Process audio stream */ processStream(stream: NodeJS.ReadableStream, config?: SpeechRecognitionConfig): Promise; } /** * Voice-to-text converter options */ interface VoiceToTextOptions { /** Default engine configuration */ defaultEngine?: EngineConfig; /** Default speech recognition configuration */ defaultRecognitionConfig?: SpeechRecognitionConfig; /** Enable automatic engine fallback */ enableFallback?: boolean; /** Engine priority order for fallback */ enginePriority?: Array; /** Debug mode */ debug?: boolean; } /** * Microphone recording options */ interface MicrophoneOptions { /** Recording duration in milliseconds */ duration?: number; /** Device ID to use */ deviceId?: string; /** Sample rate */ sampleRate?: number; /** Number of channels */ channels?: number; /** Bit depth */ bitDepth?: number; /** Audio format */ format?: 'wav' | 'raw'; } /** * Browser compatibility information */ interface BrowserSupport { /** Whether Web Speech API is supported */ webSpeechAPI: boolean; /** Whether MediaRecorder API is supported */ mediaRecorder: boolean; /** Whether getUserMedia is supported */ getUserMedia: boolean; /** Browser name and version */ browser: { name: string; version: string; }; } /** * Props for VoiceRecorder component */ interface VoiceRecorderProps { /** CSS class name */ className?: string; /** Whether to show language selector */ showLanguageSelector?: boolean; /** Whether to show results display */ showResults?: boolean; /** Whether to show recording controls */ showControls?: boolean; /** Default language */ language?: string; /** Enable continuous recording */ continuous?: boolean; /** Show interim results */ interimResults?: boolean; /** Callback when result is received */ onResult?: (result: SpeechRecognitionResult) => void; /** Callback when error occurs */ onError?: (error: string) => void; /** Callback when recording starts */ onStart?: () => void; /** Callback when recording stops */ onStop?: () => void; /** Child components */ children?: React.ReactNode; } /** * Props for FileUpload component */ interface FileUploadProps { /** CSS class name */ className?: string; /** Callback when file is selected */ onFileSelect?: (file: File) => void; /** Callback when file is converted */ onConvert?: (file: File, language: string) => Promise; /** Callback when error occurs */ onError?: (error: string) => void; /** Accepted file formats */ acceptedFormats?: string[]; /** Maximum file size in bytes */ maxFileSize?: number; /** Whether to show language selector */ showLanguageSelector?: boolean; /** Default language */ language?: string; /** Enable drag and drop */ dragAndDrop?: boolean; /** Allow multiple file selection */ multiple?: boolean; /** Whether component is disabled */ disabled?: boolean; /** Child components */ children?: React.ReactNode; } /** * Props for ResultsDisplay component */ interface ResultsDisplayProps { /** Array of recognition results */ results: SpeechRecognitionResult[]; /** Error message */ error?: string | null; /** Callback to clear results */ onClear?: () => void; /** Whether to show clear button */ showClearButton?: boolean; /** Whether to show confidence scores */ showConfidence?: boolean; /** Whether to show status (final/interim) */ showStatus?: boolean; /** Maximum number of results to display */ maxResults?: number; /** CSS class name */ className?: string; /** Text to show when no results */ emptyText?: string; } /** * Props for LanguageSelector component */ interface LanguageSelectorProps { /** Selected language value */ value?: string; /** Callback when language changes */ onChange?: (language: string) => void; /** Whether component is disabled */ disabled?: boolean; /** CSS class name */ className?: string; /** Whether to show label */ showLabel?: boolean; /** Label text */ label?: string; /** Placeholder text */ placeholder?: string; } /** * Props for RecordingControls component */ interface RecordingControlsProps { /** Whether currently recording */ isRecording: boolean; /** Whether currently processing */ isProcessing: boolean; /** Callback to start recording */ onStart?: () => void; /** Callback to stop recording */ onStop?: () => void; /** Whether component is disabled */ disabled?: boolean; /** CSS class name */ className?: string; /** Whether to show status */ showStatus?: boolean; /** Text for start button */ startText?: string; /** Text for stop button */ stopText?: string; /** Text for processing state */ processingText?: string; } interface VoiceToTextProviderProps { children: ReactNode; options?: VoiceToTextOptions; onResult?: (result: SpeechRecognitionResult) => void; onError?: (error: string) => void; onStart?: () => void; onStop?: () => void; } declare const VoiceToTextProvider: React$1.FC; declare const VoiceRecorder: React$1.FC; declare const FileUpload: React$1.FC; interface VoiceToTextConverterProps { className?: string; showFileUpload?: boolean; showVoiceRecorder?: boolean; showResults?: boolean; defaultLanguage?: string; onResult?: (result: SpeechRecognitionResult) => void; onError?: (error: string) => void; onStart?: () => void; onStop?: () => void; children?: React$1.ReactNode; } declare const VoiceToTextConverter: React$1.FC; declare const ResultsDisplay: React$1.FC; declare const LanguageSelector: React$1.FC; declare const RecordingControls: React$1.FC; interface UseVoiceToTextOptions extends VoiceToTextOptions { onResult?: (result: SpeechRecognitionResult) => void; onError?: (error: string) => void; onStart?: () => void; onStop?: () => void; } interface UseVoiceToTextReturn { isInitialized: boolean; isRecording: boolean; isProcessing: boolean; results: SpeechRecognitionResult[]; error: string | null; browserSupport: BrowserSupport | null; startRecording: (options?: Partial) => Promise; stopRecording: () => Promise; clearResults: () => void; clearError: () => void; updateConfig: (config: Partial) => void; getConfig: () => VoiceToTextOptions; } declare const useVoiceToText: (options?: UseVoiceToTextOptions) => UseVoiceToTextReturn; interface UseVoiceRecorderOptions { language?: string; continuous?: boolean; interimResults?: boolean; onResult?: (result: any) => void; onError?: (error: string) => void; onStart?: () => void; onStop?: () => void; } interface UseVoiceRecorderReturn { isInitialized: boolean; isRecording: boolean; isProcessing: boolean; results: any[]; error: string | null; startRecording: () => Promise; stopRecording: () => Promise; clearResults: () => void; clearError: () => void; } declare const useVoiceRecorder: (options?: UseVoiceRecorderOptions) => UseVoiceRecorderReturn; interface UseFileUploadOptions { acceptedFormats?: string[]; maxFileSize?: number; onFileSelect?: (file: File) => void; onConvert?: (file: File, language: string) => Promise; onError?: (error: string) => void; } interface UseFileUploadReturn { selectedFile: File | null; isConverting: boolean; results: any[]; error: string | null; selectFile: (file: File) => void; convertFile: (language?: string) => Promise; clearFile: () => void; clearResults: () => void; clearError: () => void; validateFile: (file: File) => { isValid: boolean; error?: string; }; } declare const useFileUpload: (options?: UseFileUploadOptions) => UseFileUploadReturn; interface UseSpeechRecognitionOptions { language?: string; continuous?: boolean; interimResults?: boolean; maxAlternatives?: number; onResult?: (event: any) => void; onError?: (event: any) => void; onStart?: () => void; onEnd?: () => void; onAudioStart?: () => void; onAudioEnd?: () => void; onSoundStart?: () => void; onSoundEnd?: () => void; onSpeechStart?: () => void; onSpeechEnd?: () => void; onNoMatch?: () => void; onNomatch?: () => void; } interface UseSpeechRecognitionReturn { isSupported: boolean; isListening: boolean; transcript: string; finalTranscript: string; interimTranscript: string; error: string | null; start: () => void; stop: () => void; abort: () => void; reset: () => void; updateConfig: (config: Partial) => void; } declare const useSpeechRecognition: (options?: UseSpeechRecognitionOptions) => UseSpeechRecognitionReturn; /** * Supported audio file formats */ declare const SUPPORTED_AUDIO_FORMATS: string[]; /** * Check if a file is a supported audio format */ declare function isSupportedAudioFormat(filePath: string): boolean; /** * Validate audio file format (browser version) */ declare function validateAudioFile(file: File): void; /** * Get audio file information (browser version) */ interface AudioFileInfo { size: number; format: string; name: string; type: string; lastModified: number; } declare function getAudioFileInfo(file: File): AudioFileInfo; /** * Convert audio buffer to WAV format (simplified implementation) */ declare function bufferToWav(buffer: ArrayBuffer, sampleRate?: number, channels?: number): ArrayBuffer; /** * Normalize audio volume */ declare function normalizeAudio(buffer: ArrayBuffer, targetVolume?: number): ArrayBuffer; /** * Detect silence in audio buffer */ declare function detectSilence(buffer: ArrayBuffer, threshold?: number): boolean; /** * Split audio buffer into chunks */ declare function chunkAudioBuffer(buffer: ArrayBuffer, chunkSize: number): ArrayBuffer[]; /** * Merge multiple audio buffers */ declare function mergeAudioBuffers(buffers: ArrayBuffer[]): ArrayBuffer; /** * Convert sample rate (basic implementation) */ declare function resampleAudio(buffer: ArrayBuffer, fromRate: number, toRate: number): ArrayBuffer; /** * Create audio context for web audio processing */ declare function createAudioContext(): AudioContext | null; /** * Load audio file as ArrayBuffer */ declare function loadAudioFile(file: File): Promise; /** * Check browser support for speech recognition and related APIs */ declare function getBrowserSupport(): BrowserSupport; /** * Get the SpeechRecognition constructor for the current browser */ declare function getSpeechRecognition(): any | null; /** * Check if speech recognition is supported in the current browser */ declare function isSpeechRecognitionSupported(): boolean; /** * Get available audio input devices */ declare function getAudioDevices(): Promise; /** * Request microphone permission */ declare function requestMicrophonePermission(): Promise; /** * Check if the current environment is a browser */ declare function isBrowser(): boolean; /** * Check if the current environment is a secure context (HTTPS) */ declare function isSecureContext(): boolean; /** * Get browser name and version */ declare function getBrowserInfo(): { name: string; version: string; }; /** * Create a new SpeechRecognition instance with the given configuration */ declare function createSpeechRecognition(config: SpeechRecognitionConfig): any | null; /** * Check if speech recognition is available in the current environment */ declare function isSpeechRecognitionAvailable(): boolean; /** * Validate speech recognition configuration */ declare function validateSpeechRecognitionConfig(config: Partial): { isValid: boolean; errors: string[]; }; /** * Check if a language code is valid */ declare function isValidLanguageCode(languageCode: string): boolean; /** * Get supported language codes */ declare function getSupportedLanguages(): string[]; /** * Get language name from language code */ declare function getLanguageName(languageCode: string): string; /** * Format a SpeechRecognitionResult for display */ declare function formatRecognitionResult(result: SpeechRecognitionResult): string; /** * Merge multiple recognition results */ declare function mergeRecognitionResults(results: SpeechRecognitionResult[]): string; /** * Get the best result from multiple alternatives */ declare function getBestResult(results: SpeechRecognitionResult[]): SpeechRecognitionResult | null; /** * Base class for speech recognition engines */ declare abstract class BaseSpeechRecognitionEngine extends EventEmitter implements ISpeechRecognitionEngine { protected isRecording: boolean; protected config: SpeechRecognitionConfig; constructor(); /** * Start speech recognition */ abstract start(audioConfig: AudioInputConfig, recognitionConfig?: SpeechRecognitionConfig): Promise; /** * Stop speech recognition */ abstract stop(): Promise; /** * Abort speech recognition */ abstract abort(): Promise; /** * Check if engine is available */ abstract isAvailable(): boolean; /** * Get supported languages */ abstract getSupportedLanguages(): string[]; /** * Process audio file directly */ abstract processFile(file: File, config?: SpeechRecognitionConfig): Promise; /** * Process audio stream */ abstract processStream(stream: NodeJS.ReadableStream, config?: SpeechRecognitionConfig): Promise; /** * Validate configuration */ protected validateConfig(config: SpeechRecognitionConfig): void; /** * Validate audio input configuration */ protected validateAudioConfig(audioConfig: AudioInputConfig): void; /** * Emit error event with proper error handling */ protected emitError(type: SpeechRecognitionErrorType, message: string, originalError?: Error): void; /** * Emit result event with validation */ protected emitResult(result: SpeechRecognitionResult): void; /** * Get default configuration merged with provided config */ protected getConfig(config?: SpeechRecognitionConfig): SpeechRecognitionConfig; /** * Check if currently recording */ get isActive(): boolean; /** * Set recording state */ protected setRecordingState(recording: boolean): void; /** * Clean up resources */ cleanup(): void; /** * Type-safe event emitter methods */ emit(event: K, ...args: Parameters): boolean; on(event: K, listener: SpeechRecognitionEvents[K]): this; once(event: K, listener: SpeechRecognitionEvents[K]): this; off(event: K, listener: SpeechRecognitionEvents[K]): this; } declare global { interface Window { SpeechRecognition: any; webkitSpeechRecognition: any; } } /** * Web Speech API engine for browser environments */ declare class WebSpeechEngine extends BaseSpeechRecognitionEngine { private recognition; private mediaRecorder; private audioChunks; constructor(); /** * Check if Web Speech API is available */ isAvailable(): boolean; /** * Get supported languages (common languages supported by most browsers) */ getSupportedLanguages(): string[]; /** * Initialize the speech recognition engine */ initialize(_config?: SpeechRecognitionConfig): Promise; /** * Start listening for speech */ startListening(config?: SpeechRecognitionConfig): Promise; /** * Stop listening for speech */ stopListening(): Promise; /** * Start speech recognition */ start(audioConfig: AudioInputConfig, recognitionConfig?: SpeechRecognitionConfig): Promise; /** * Initialize speech recognition instance */ private initializeRecognition; /** * Start microphone recognition */ private startMicrophoneRecognition; /** * Process audio file (requires MediaRecorder API) */ private processAudioFile; /** * Stop speech recognition */ stop(): Promise; /** * Abort speech recognition */ abort(): Promise; /** * Process audio file directly (not supported by Web Speech API) */ processFile(_file: File, _config?: SpeechRecognitionConfig): Promise; /** * Process audio stream (not supported by Web Speech API) */ processStream(_stream: NodeJS.ReadableStream, _config?: SpeechRecognitionConfig): Promise; /** * Get available audio input devices */ static getAudioDevices(): Promise; /** * Check browser compatibility */ static getBrowserSupport(): { supported: boolean; features: string[]; }; } declare const VERSION = "1.0.0"; export { EventEmitter, FileUpload, LanguageSelector, RecordingControls, ResultsDisplay, SUPPORTED_AUDIO_FORMATS, SpeechRecognitionError, SpeechRecognitionErrorType, VERSION, VoiceRecorder, VoiceToTextConverter, VoiceToTextProvider, WebSpeechEngine, bufferToWav, chunkAudioBuffer, createAudioContext, createSpeechRecognition, VoiceToTextProvider as default, detectSilence, formatRecognitionResult, getAudioDevices, getAudioFileInfo, getBestResult, getBrowserInfo, getBrowserSupport, getLanguageName, getSpeechRecognition, getSupportedLanguages, isBrowser, isSecureContext, isSpeechRecognitionAvailable, isSpeechRecognitionSupported, isSupportedAudioFormat, isValidLanguageCode, loadAudioFile, mergeAudioBuffers, mergeRecognitionResults, normalizeAudio, requestMicrophonePermission, resampleAudio, useFileUpload, useSpeechRecognition, useVoiceRecorder, useVoiceToText, validateAudioFile, validateSpeechRecognitionConfig }; export type { AudioFileInfo, AudioInputConfig, BrowserSupport, EngineConfig, FileUploadProps, ISpeechRecognitionEngine, LanguageSelectorProps, MicrophoneOptions, RecordingControlsProps, ResultsDisplayProps, SpeechRecognitionConfig, SpeechRecognitionEvents, SpeechRecognitionResult, VoiceRecorderProps, VoiceToTextOptions };