"""Cheap non-AI audio cleanup: mono 16k, highpass, loudnorm -> out//audio.opus.""" import subprocess import db # Convert the meeting's audio track to 16 kHz mono Opus (small, speech-optimised). def run(name): source_path = db.media(name)[0] # No audio track: nothing to convert. if source_path is None: raise FileNotFoundError(f"no audio source for {name}") output_path = db.out_dir(name) / "audio.opus" result = subprocess.run( [ "ffmpeg", "-y", "-v", "error", "-i", str(source_path), "-vn", "-ac", "1", "-ar", "16000", # highpass 80 Hz removes rumble; loudnorm evens out volume (EBU R128: -18 LUFS, -2 dBTP peak, LRA 11); 24 kbps Opus. "-af", "highpass=f=80,loudnorm=I=-18:TP=-2:LRA=11", "-c:a", "libopus", "-b:a", "24k", str(output_path), ], capture_output=True, text=True, ) # Surface the tail of ffmpeg's error output. if result.returncode: raise RuntimeError(result.stderr[-500:]) # Store the duration probed from the output file. db.upsert_recording(name, duration_s=db.duration(output_path)) return output_path