Technical Overview
src/preprocess.py relies on standard torchaudio or dynamic library codecs to decode raw audio signals. In minimal runtime environments or virtual systems where OS-level FFmpeg codecs are missing, standard audio loading throws unhandled decoding errors.
Affected Modules
- File:
src/utils.py & src/preprocess.py
Acceptance Criteria
- Platform Independence: Preprocessing succeeds even in minimalist systems lacking native OS-level media codecs.
- Format Support: Processes various target formats (WAV, MP3, M4A) and standardizes them to 16kHz mono.
- Silent Fallback: Automatically tries alternative Python-native decoders if the default C++ system libraries fail.
Proposed Implementation Approach
Implement a multi-layered fallback loop within our dataset audio parsing module:
def load_audio_resilient(audio_path, target_sr=16000):
try:
# Layer 1: Attempt standard torchaudio loading
import torchaudio
waveform, sr = torchaudio.load(audio_path)
# Resample if needed
# ...
return waveform
except Exception as e1:
try:
# Layer 2: Fall back to native soundfile loading
import soundfile as sf
data, sr = sf.read(audio_path)
# ...
return torch.tensor(data).float()
except Exception as e2:
# Layer 3: Final fallback to pydub/librosa if installed
import librosa
data, sr = librosa.load(audio_path, sr=target_sr)
return torch.tensor(data)
Severity & Priority
- Severity: Medium (Enhances cross-environment compatibility)
- Priority: P2
Technical Overview
src/preprocess.pyrelies on standardtorchaudioor dynamic library codecs to decode raw audio signals. In minimal runtime environments or virtual systems where OS-level FFmpeg codecs are missing, standard audio loading throws unhandled decoding errors.Affected Modules
src/utils.py&src/preprocess.pyAcceptance Criteria
Proposed Implementation Approach
Implement a multi-layered fallback loop within our dataset audio parsing module:
Severity & Priority