/** * Voice Recorder Utility * Provides audio recording functionality with waveform visualization support. */ export interface VoiceRecorderOptions { /** Maximum recording duration in milliseconds (default: 300000 = 5 minutes) */ maxDuration?: number; /** Audio bits per second (default: 128000) */ audioBitsPerSecond?: number; } export interface VoiceRecordingResult { /** The recorded audio blob */ audioBlob: Blob; /** Recording duration in milliseconds */ duration: number; /** MIME type of the audio */ mimeType: string; } export type VoiceRecorderEventCallback = (data: T) => void; /** * VoiceRecorder class for handling audio recording with visualization support. */ export declare class VoiceRecorder { private mediaRecorder; private audioChunks; private isRecording; private stream; private recordingStartTime; private maxDuration; private audioBitsPerSecond; private mimeType; private audioContext; private analyser; private animationFrame; private onStartCallback?; private onStopCallback?; private onErrorCallback?; private onAudioLevelCallback?; private onDurationUpdateCallback?; private durationInterval; constructor(options?: VoiceRecorderOptions); /** * Check if the browser supports audio recording. */ static isSupported(): boolean; /** * Get the best supported MIME type for recording. */ private getSupportedMimeType; /** * Start audio recording. * @returns Promise that resolves to true if recording started successfully. */ startRecording(): Promise; /** * Stop audio recording. */ stopRecording(): void; /** * Cancel audio recording without emitting the result. */ cancelRecording(): void; /** * Check if currently recording. */ isCurrentlyRecording(): boolean; /** * Get recording duration in milliseconds. */ getRecordingDuration(): number; /** * Set up audio analysis for waveform visualization. */ private setupAudioAnalysis; /** * Start monitoring audio levels for visualization. */ private startAudioLevelMonitoring; /** * Start duration update interval. */ private startDurationUpdates; /** * Stop duration update interval. */ private stopDurationUpdates; /** * Clean up resources. */ private cleanup; /** * Destroy the recorder and clean up all resources. */ destroy(): void; /** * Set callback for when recording starts. */ onStart(callback: VoiceRecorderEventCallback): this; /** * Set callback for when recording stops with the result. */ onStop(callback: VoiceRecorderEventCallback): this; /** * Set callback for recording errors. */ onError(callback: VoiceRecorderEventCallback): this; /** * Set callback for audio level updates (for waveform visualization). * Level is normalized between 0 and 1. */ onAudioLevel(callback: VoiceRecorderEventCallback): this; /** * Set callback for duration updates (in milliseconds). */ onDurationUpdate(callback: VoiceRecorderEventCallback): this; /** * Format duration in milliseconds to MM:SS format. */ static formatDuration(ms: number): string; } export default VoiceRecorder;