Long-Form-Audio-Pipeline

December 15, 2025 · View on GitHub

A preprocessing pipeline for preparing long-form audio recordings for speech-to-text (ASR) APIs. This tool optimizes audio files for transcription by reducing file size, normalizing audio levels, and cleaning up the signal before upload.

Why Preprocess?

While many ASR APIs perform server-side preprocessing, this pipeline:

  • Reduces upload time and bandwidth by compressing audio before transmission
  • Ensures consistent input quality regardless of original recording conditions
  • Removes unnecessary data (silence, stereo channels) that don't aid transcription
  • Optimizes for speech recognition with filters tuned for voice clarity

Pipeline Stages

The preprocessing script applies the following transformations in order:

StageTransformationDetails
1Silence Detection & TrimmingDetects silence at start/end (threshold: -50dB, min duration: 0.5s) and trims it
2Stereo to Mono ConversionMixes stereo channels to mono (0.5×L + 0.5×R) — ASR doesn't benefit from stereo
3Sample Rate ConversionResamples to 16kHz — the standard rate for most STT systems
4Loudness NormalizationApplies EBU R128 normalization (I=-16 LUFS, TP=-1.5 dB, LRA=11)
5High-Pass FilterRemoves low-frequency rumble below 80Hz common in voice recordings
6Speech Clarity EQ4-band EQ optimized for voice intelligibility (see below)
7Dynamic Range CompressionGentle compression (threshold: -20dB, ratio: 3:1) to even out volume levels
8Codec TransformationEncodes to OGG Opus at 48kbps VBR with voip application mode

Speech Clarity EQ Details

The EQ stage applies frequency adjustments specifically tuned for speech intelligibility:

FrequencyAdjustmentPurpose
300 Hz-3 dB cutReduces muddiness in the low-mid range
1.5 kHz+3 dB boostEnhances vowel presence and clarity
3 kHz+4 dB boostBoosts consonant clarity (the "intelligibility band")
4 kHz++2 dB shelfAdds air and crispness to sibilants

These adjustments were derived from frequency analysis of real voice recordings, targeting the bands that most impact ASR accuracy.

Example Results

Processing a real-world voice recording through this pipeline:

MetricBeforeAfter
File Size482.87 MB16.80 MB
FormatWAV (PCM 16-bit)OGG (Opus)
ChannelsStereoMono
Sample Rate44100 Hz16000 Hz
Duration2870.32s (~47 min)2869.71s
Compression Ratio28.7×

The 0.6 seconds trimmed from the start was detected silence before speech began.

GUI Application

A desktop GUI is available for easy audio processing and EQ calibration.

Process Audio Tab

Features:

  • Drag & drop audio file input
  • Automatic output naming (_processed.ogg suffix)
  • EQ calibration workflow with sample extraction
  • Import/export EQ presets (.conf, .json, .ffmpeg formats)
  • View and edit current EQ bands
TabDescription
Process AudioDrop files for processing with current EQ preset
EQ CalibrationExtract samples, edit in Audacity, compute custom EQ
Current PresetView, import, and export EQ presets

Install GUI (Debian/Ubuntu)

sudo apt install ./audio-processor_1.0.0_all.deb

Or run directly:

./install_gui.sh   # Sets up Python venv and PyQt6
./run_gui.sh       # Launch the GUI

Installation

Dependencies

  • ffmpeg with libopus support
  • ffprobe (included with ffmpeg)
  • Standard Unix tools: awk, grep, sed

On Ubuntu/Debian:

sudo apt install ffmpeg

Usage

Quick Start (Single File)

# Process a single file with default EQ
./preprocess_for_stt.sh recording.wav

Batch Processing with Custom EQ

This pipeline supports creating your own EQ preset by editing a sample in your preferred audio editor:

# 1. Extract a 15-second sample for calibration
./extract_sample.sh calibration.wav

# 2. Edit samples/sample_before.wav in your audio editor
#    Apply your preferred EQ adjustments
#    Export as samples/sample_after.wav

# 3. Compute your custom EQ preset
./compute_eq.sh

# 4. Drop files in the 'in/' folder and batch process
./process_batch.sh

Directory Structure

├── in/                    # Drop input files here
├── out/                   # Processed files appear here
├── samples/
│   ├── sample_before.wav  # Raw sample for editing
│   └── sample_after.wav   # Your edited sample (you create this)
├── eq_preset.conf         # Generated EQ preset
├── extract_sample.sh      # Extract calibration sample
├── compute_eq.sh          # Derive EQ from before/after
├── process_batch.sh       # Batch process with custom EQ
└── preprocess_for_stt.sh  # Single-file processor (default EQ)

Supported Input Formats

Any format ffmpeg can decode:

  • WAV, FLAC, AIFF (uncompressed)
  • MP3, AAC, OGG, M4A (compressed)
  • Most other audio formats

Configuration

Edit the variables at the top of preprocess_for_stt.sh:

SAMPLE_RATE=16000           # Target sample rate (Hz)
BITRATE="48k"               # OGG Opus bitrate
SILENCE_THRESHOLD="-50dB"   # Silence detection threshold
SILENCE_DURATION="0.5"      # Minimum silence duration (seconds)

When to Use This

This pipeline is specifically intended for:

  • Voice memos and dictation recordings
  • Interview recordings
  • Podcast audio for transcription
  • Meeting recordings
  • Any long-form speech content destined for ASR

It's optimized for speech, not music. The high-pass filter and compression settings are tuned for voice clarity.

License

MIT