
← Hacker Public Radio4 days ago
HPR4746: Monotone
Python and its libraries
1. librosa — loading and resampling audio
def load_audio(path):
y, sr = librosa.load(path, sr=SR, mono=True)
return y, sr
Every episode, regardless of its original sample rate or channel count, gets loaded down to a single mono stream at 16kHz (SR = 16000). That's one line of librosa, resampling, and folding stereo to mono. It made every downstream tool (VAD, pitch tracking, MFCC extraction) operate on a consistent, predictable input regardless of what an MP3 encoder or podcast host originally used.
2. parselmouth (Praat bindings) — pitch and voice-quality tracking
def pitch_and_hnr(y, sr):
snd = parselmouth.Sound(y, sampling_frequency=sr)
pitch = snd.to_pitch(time_step=PITCH_TIME_STEP, pitch_floor=PITCH_FLOOR, pitch_ceiling=PITCH_CEILING)
f0 = pitch.selected_array["frequency"]
times = pitch.xs()