Skip to content

About

Audio/video transcription, diarization, and LLM post-processing pipeline tools

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Audio Transcription Pipeline with Multi-Provider AI Processing

Transcription with speaker diarization plus AI post-processing for technical term correction.

Quick Start

# 1. Setup environment (one time)
# 1. System packages (sudo, one time)
./scripts/install_packages.sh

# 2. Python venvs (no sudo)
./scripts/install_venv.sh --nvidia   # or --amd, --intel, --cpu
cp setup_env.sh.example setup_env.sh
nano setup_env.sh  # Add API keys

# 2. Activate and run
source setup_env.sh
source venv-nvidia/bin/activate  # Match your GPU vendor

# 3. Transcribe audio
python3 scripts/process_single_transcribe_and_diarize.py audio.mp3 --transcribers whisperx

# 4. Post-process transcript
python3 scripts/process_single_post_process.py intermediates/audio/audio_whisperx.md --processors opus

# Or use the combined shell script
./scripts/process_single.sh audio.mp3 --transcribers whisperx --processors opus

Transcription Services

All services include speaker diarization (identifying who said what) and word-level timestamps.

Service Model Type Cost/hour Speed Word-Level JSON
whisperx large-v3 Local (CTranslate2: CUDA/CPU only) FREE ~20 min/hr audio Yes
whisper-cpp large-v3 (ggml) Local — any vendor GPU: NVIDIA CUDA, AMD Vulkan/HIP, Intel Vulkan/SYCL, Apple Metal, CPU FREE GPU-dependent Segments
whisperx-cloud large-v3 Replicate API $2.88 2-3 min Optional
assemblyai assemblyai-stt-3-7 Cloud API $0.23 (incl. diarization) 3-4 min Yes

whisper.cpp backends (any-vendor local ASR)

whisper-cli auto-selects the best backend compiled into the binary. Build whisper.cpp with the one for your GPU:

Vendor CMake flag Notes
NVIDIA -DGGML_CUDA=ON CUDA 12
AMD -DGGML_VULKAN=ON or -DGGML_HIP=ON Vulkan is universal (RADV); HIP for the ROCm toolchain
Intel -DGGML_VULKAN=ON or -DGGML_SYCL=ON Vulkan via ANV/Mesa; SYCL via oneAPI
Apple Metal (default on macOS)
CPU (default)

Env knobs: WHISPER_CPP_BIN (binary path), WHISPER_CPP_MODEL (explicit .bin), WHISPER_CPP_MODEL_NAME (default large-v3; e.g. base.en for quick tests), WHISPER_CPP_ARGS (extra CLI flags, e.g. --beam-size 5), WHISPER_CPP_LANGUAGE, and --force-cpu maps to whisper-cli's -ng. Diarization still uses pyannote (same as the whisperx path), so HF_TOKEN is required.

Noisy recordings with long ambient intros are whisper's weak spot. whisper.cpp has a built-in VAD stage that skips silence before the model ever sees it:

export WHISPER_CPP_ARGS="--vad -vm models/ggml-silero-v5.1.2.bin"

The cleanup pass also runs a hallucination guard (below) and refuses to save output that looks like a wall of !!! or a "Thank you" loop.

Transcription Commands

# Local WhisperX (requires GPU)
python3 scripts/process_single_transcribe_and_diarize.py audio.mp3 --transcribers whisperx

# Force reprocess existing
python3 scripts/process_single_transcribe_and_diarize.py audio.mp3 --transcribers whisperx --force

# Force CPU mode (slower)
python3 scripts/process_single_transcribe_and_diarize.py audio.mp3 --transcribers whisperx --force-cpu

# Cloud transcription
python3 scripts/process_single_transcribe_and_diarize.py audio.mp3 --transcribers assemblyai

# Multiple transcribers
python3 scripts/process_single_transcribe_and_diarize.py audio.mp3 --transcribers whisperx-cloud,assemblyai

AI Post-Processors

Hosted post-processing uses direct Anthropic access for Opus/Sonnet, the direct Google Gemini API for Gemini, OpenRouter for Grok/Qwen/DeepSeek, and direct OpenAI access for GPT-6.2 Sol. See AI_PROVIDERS.md for details.

Processor Model Context Best For
opus Claude Opus 5.5 1M Premium quality, complex reasoning
sonnet Claude Sonnet 5.5 1M Fast, high quality, cheaper
gemini Gemini 4 Neon 1M Long documents, technical
grok Grok 4.7 500K High benchmark performance
qwen Qwen3.8 Max 1M Multilingual, open weights
deepseek DeepSeek V4.1 Flash 1M Ultra-cheap bulk runs
gpt GPT-6.2 Sol 1M+ OpenAI-native post-processing

Post-Processing Commands

# Single processor
python3 scripts/process_single_post_process.py transcript.md --processors opus

# GPT-6.2 Sol via direct OpenAI API
python3 scripts/process_single_post_process.py transcript.md --processors gpt

# All hosted processors
python3 scripts/process_single_post_process.py transcript.md --processors opus,sonnet,gemini,grok,qwen,deepseek,gpt

Output Quality Guard

Every cleaned transcript is scored before it is saved. Content loss, timestamp drift, dropped speaker labels and hallucination signatures are all checked:

  • punctuation walls (!!! runs of 10+)
  • phrase loops (the same four words repeated 15+ times)
  • duplicate turns (more than half of the turns identical)
  • near-zero lexical diversity

An unambiguous signature (a punctuation wall, or two overlapping repetition signals) rejects the output instead of saving it — the existing file is left untouched and the run reports ✗. Add --save-hallucinated to keep it anyway.

Calibrated against all 83 corpus transcripts: zero false positives, and a fabricated "Thank you. !!!!!!" loop is rejected with all four signals firing.

Speaker Identification

Map SPEAKER_XX labels to real names from self-introductions in the opening minutes:

# Default: Gemini 4 Hydrogen via GEMINI_API_KEY (cheap, structured JSON output)
python3 scripts/identify_speakers.py intermediates/<ep>/<ep>_assemblyai.md --apply

# Zero-cost local alternative (home-lab llama.cpp server)
python3 scripts/identify_speakers.py <transcript.md> --endpoint http://100.103.20.81:8080/v1 --apply

Produces a reviewable speakers.json ({SPEAKER_XX: {name, confidence, evidence}}) and, with --apply, a <transcript>_named.md. Verified live: 7/7 speakers identified with high confidence on the STRATO ICO AMA (all introduced themselves in the first 3 minutes).

Output Structure

intermediates/
  <episode>/
    # Raw transcriber outputs
    <episode>_whisperx.md               # Markdown with timestamps
    <episode>_assemblyai.md

outputs/
  <episode>/
    # AI post-processed transcripts
    <episode>_assemblyai_opus.md
    <episode>_whisperx-cloud_opus.md
    ...

Hardware Requirements

Local transcription auto-detects your accelerator: NVIDIA CUDA, AMD ROCm, Apple Metal (MPS), Intel XPU, or CPU fallback. No specific GPU model is required. On MPS/XPU the Whisper pass runs on CPU (CTranslate2 limitation) while pyannote diarization still uses the GPU.

Local mode is gated, not best-effort. The local transcribers (whisperx, whisper-cpp) check the box before loading anything and refuse below the baseline instead of quietly degrading to a tiny model:

Mode RAM (enforced) GPU Disk
CPU-only 32GB None 50GB
NVIDIA CUDA 32GB 8GB+ VRAM (4GB floor) 50GB
AMD ROCm 32GB 8GB+ VRAM (4GB floor) 50GB
Apple MPS 32GB Apple Silicon (unified memory) 50GB
Intel XPU 32GB Arc/Iris (8GB+ shared) 50GB

32GB is the installed physical figure (a 32GB machine reports ~30 GiB after kernel reservations, so the gate rounds up to the module capacity). 8GB VRAM is the headroom baseline for large-v3 + pyannote, which run sequentially and each peak around 3GB; below 8GB you get a warning, below 4GB a stronger one suggesting --force-cpu.

# Below baseline? Proceed anyway (warning, not a refusal)
python3 scripts/process_single_transcribe_and_diarize.py audio.mp3 \
    --transcribers whisper-cpp --allow-low-mem

# Or lower the threshold explicitly (GB)
TRANSCRIPTS_MIN_LOCAL_RAM_GB=16 ...

Cloud transcription (assemblyai, whisperx-cloud) has no local hardware requirement, and LLM post-processing runs on hosted APIs or a remote llama.cpp server (LOCAL_BASE_URL) — so the local GPU/RAM is only needed for on-box ASR.

Tested GPUs

  • NVIDIA RTX 5070 (12GB) - PyTorch 2.9.1+cu130
  • NVIDIA RTX 3090 (24GB) - PyTorch 2.9.1+cu130

Setup

1. Install Dependencies

# For NVIDIA GPU
./scripts/install_venv.sh --nvidia

# For AMD GPU (ROCm)
./scripts/install_venv.sh --amd

# For Intel GPU (Arc/XPU)
./scripts/install_venv.sh --intel

# CPU-only fallback
./scripts/install_venv.sh --cpu

# Create all venvs (for eGPU workflows)
./scripts/install_venv.sh --all

2. Configure API Keys

cp setup_env.sh.example setup_env.sh
nano setup_env.sh

Required keys in setup_env.sh:

export HF_TOKEN="hf_..."              # Required for WhisperX diarization
export ANTHROPIC_API_KEY="sk-ant-..." # Required for Opus post-processing
export OPENROUTER_API_KEY="sk-or-..." # Required for Gemini/Grok/Qwen post-processors
export OPENAI_API_KEY="sk-..."        # Required for GPT-5.4 post-processing
export ASSEMBLYAI_API_KEY="..."       # Optional: AssemblyAI transcription
export REPLICATE_API_TOKEN="..."      # Optional: Cloud WhisperX

3. Accept HuggingFace Model Agreements

Package Versions

Key dependencies managed by install_venv.sh (system prerequisites via install_packages.sh):

Package Version Notes
PyTorch 2.9.1+cu130 CUDA 13.0 for Blackwell GPUs
torchaudio 2.9.1+cu130 Matches PyTorch
pyannote-audio 4.0.1 Last version without torch pin
speechbrain 1.1.0 Includes torchaudio 2.9 compatibility fixes
whisperx 3.8.5 Speaker diarization

The install script applies compatibility patches for:

  • PyTorch 2.6+ weights_only=True default
  • pyannote/torchcodec ABI compatibility

Troubleshooting

CUDA not detected

# Check CUDA availability
python3 -c "import torch; print(torch.cuda.is_available())"

# Verify driver
nvidia-smi

OOM errors during transcription

The script automatically falls back to smaller batch sizes (32 -> 4 -> 1).

--force vs --force-cpu

  • --force - Reprocess even if output exists
  • --force-cpu - Use CPU instead of GPU (slower)

License

GPL-3.0 - See LICENSE file.

About

Audio/video transcription, diarization, and LLM post-processing pipeline tools

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages