Implementation of SNR
Description
This merge request introduces real-time client-side Signal-to-Noise Ratio (SNR) monitoring in the ASR frontend using the Web Audio API. The implementation analyzes live microphone input directly in the browser and displays dynamic SNR values and audio quality indicators within the existing Live Transcription UI without relying on backend processing.
Changes Implemented
Client-Side SNR Processing
- Added real-time SNR calculation using Web Audio API
- Integrated microphone audio analysis using:
AudioContextAnalyserNodeMediaStreamAudioSourceNode
- Implemented RMS-based signal energy calculation
- Added background noise estimation for live SNR computation
UI Enhancements
- Added live SNR display inside the Live Transcription section
- Implemented dynamic audio quality indicators:
- Excellent
- Good
- Moderate
- Poor
- Added color-coded SNR feedback based on audio quality
- Preserved existing dark-themed UI and layout
WaveSurfer Integration
- Integrated SNR-based waveform color updates
- Dynamically changes waveform appearance depending on audio quality
Performance & Stability
- Added optimized real-time update intervals
- Implemented proper cleanup for:
- AudioContext
- microphone streams
- animation/update loops
- Prevented memory leaks and duplicate analyzer initialization
- Added graceful handling for microphone permission failures
Files Modified
- Added reusable SNR calculation hook/component
- Updated Live Transcription UI integration
- Modified only frontend audio-analysis-related files
Constraints Followed
- No backend API changes
- No transcription flow modifications
- No unrelated component changes
- No UI redesigns
- No state management refactors
- Existing recording/transcription functionality preserved
Expected Outcome
The frontend now provides real-time client-side SNR monitoring and audio quality feedback directly from microphone input, improving the live transcription experience while seamlessly integrating with the existing ASR interface and WaveSurfer visualization.
Closes #44 (closed)