Skip to main content

Dharma Transcription Pipeline

A headless multilingual transcription pipeline designed for Buddhist dharma teachings. Handles mixed-language audio (Tibetan, Sanskrit, English, Japanese) with per-language forced alignment, speaker diarization, a Tibetan second-pass using dharma-trained models, and optional LLM post-correction.

Privacy-first: all processing runs locally. Sacred content never touches a cloud unless you explicitly configure LLM correction with a cloud API.

Version 0.1.2 — see CHANGELOG.md for release history.

Architecture — 7 Stages

Audio/Video → Ingest → WhisperX → Alignment → Diarization → Tibetan 2nd-Pass → LLM Correction → Output
Stage Purpose Model GPU Memory
1. Ingest ffmpeg extract to 16kHz mono WAV, checksum idempotency ffmpeg —
2. Transcription Primary ASR with auto language detection WhisperX large-v3 (int8) ~4 GB
3. Alignment Word-level timestamps per language wav2vec2 (per-language) ~1–2 GB
4. Diarization Speaker identification pyannote diarization-community-1 ~1 GB
5. Tibetan 2nd-Pass Re-transcribe Tibetan segments with dharma-trained model OpenPecha op-whisper_small-ft-v2 ~1 GB
6. LLM Correction Post-correction with dharma domain knowledge Any OpenAI-compatible API (cloud or local)
7. Output JSON, SRT, VTT, TXT, review queue — —

Stages run serially with GPU memory flushing between each — designed for 6 GB consumer GPUs.

Setup

Prerequisites

  • Python 3.10+
  • ffmpeg + ffprobe (system install)
  • NVIDIA GPU with CUDA (optional — --device cpu works for all stages)
  • HuggingFace token (for diarization only — transcription works without it)

Installation

# Clone
git clone https://github.com/retiform-labs/dharma-transcribe.git
cd dharma-transcribe

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install with pip
pip install -e ".[dev]"

# Or install from PyPI (when published)
pip install dharma-transcribe[dev]
# Install PyTorch with CUDA support (adjust cuXXX for your CUDA version)
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu128

HuggingFace Token (for diarization)

The pipeline needs a HuggingFace token to download the pyannote diarization model. Without it, diarization is skipped — transcription still completes normally.

# Get a token: https://huggingface.co/settings/tokens
# Also accept the model license: https://huggingface.co/pyannote/speaker-diarization-community-1

export HF_TOKEN=hf_your_token_here

LLM Correction Configuration (optional)

Stage 6 uses any OpenAI-compatible API. Configure via environment variables:

# Cloud API example (Synthetic.new)
export DHARMA_LLM_API_URL=https://api.example.com/v1
export DHARMA_LLM_API_KEY=your-key
export DHARMA_LLM_MODEL=hf:openai/gpt-oss-120b

# Local model example (Ollama)
ollama pull qwen3.5:9b
export DHARMA_LLM_API_URL=http://localhost:11434/v1
export DHARMA_LLM_API_KEY=ollama
export DHARMA_LLM_MODEL=qwen3.5:9b

# vLLM example (local GPU)
# Start vLLM server: vllm serve Qwen/Qwen3.5-9B
export DHARMA_LLM_API_URL=http://localhost:8000/v1
export DHARMA_LLM_API_KEY=none
export DHARMA_LLM_MODEL=Qwen/Qwen3.5-9B

Or skip LLM correction entirely: --skip-llm

Usage

# Single file
dharma-transcribe /path/to/teaching.mp4

# Directory (batch — finds all audio/video recursively)
dharma-transcribe /path/to/recordings/

# Skip LLM correction (ASR only, faster)
dharma-transcribe /path/to/teaching.mp4 --skip-llm

# CPU-only mode (no GPU required)
dharma-transcribe /path/to/teaching.mp4 --device cpu --skip-llm

# With explicit HF token
dharma-transcribe /path/to/teaching.mp4 --hf-token $HF_TOKEN

CLI Flags

Flag Default Description
input (positional) — File or directory to process
--source-dir — Default source directory
--skip-llm off Skip LLM correction stage
--hf-token $HF_TOKEN HuggingFace token for diarization
--device cuda Compute device: cuda or cpu

Environment Variables

See .env.example for the full list. Key variables:

Variable Default Description
DHARMA_LLM_API_URL (empty) OpenAI-compatible API endpoint
DHARMA_LLM_API_KEY (empty) API key for LLM correction
DHARMA_LLM_MODEL (empty) Model name for LLM correction
HF_TOKEN (empty) HuggingFace token for diarization
DHARMA_DEVICE cuda Compute device
DHARMA_WHISPER_MODEL large-v3 WhisperX model size
DHARMA_OUTPUT_DIR ./output Output directory
DHARMA_TIBETAN_MODEL openpecha/op-whisper_small-ft-v2 Tibetan second-pass model

Output Formats

Each processed file generates:

  • JSON — full structured transcript with word-level timestamps, speaker labels, confidence scores
  • SRT — subtitle file with speaker labels
  • VTT — WebVTT subtitles with speaker tags
  • TXT — plain text reading copy
  • Review queue — JSON of low-confidence segments for manual review

Outputs are written to output/{json,srt,vtt,txt,review}/.

Corrections Dictionary

output/corrections/corrections.json — case-insensitive string replacement applied before LLM correction. Grows from manual review.

{
  "corrections": [
    {"pattern": "bodichita", "replacement": "bodhicitta"},
    {"pattern": "shun yata", "replacement": "shunyata"}
  ]
}

Idempotency

The manifest (output/manifest.json) tracks processed files. Re-running the pipeline skips completed files. Delete the manifest to reprocess everything.

VRAM Management

Designed for consumer GPUs (6 GB+). Stages run serially with gc.collect() + torch.cuda.empty_cache() between each. No CPU fallback needed — the GPU is flushed fully before loading the next model.

Why This Exists

Most transcription tools handle single languages. Dharma teachings commonly mix Tibetan, Sanskrit, English, and sometimes Japanese in a single recording. This pipeline:

  1. Detects language per segment — not per file
  2. Aligns each language separately — wav2vec2 models for bo, sa, en, ja
  3. Re-transcribes Tibetan — OpenPecha's model (trained on Garchen Rinpoche's teachings) often outperforms WhisperX on Tibetan
  4. Corrects with dharma knowledge — LLM post-correction knows bodhicitta from bodichita

License

MIT — see LICENSE.

Sponsors

If dharma-transcribe is useful to you, consider supporting its continued development:

  • GitHub Sponsors
  • Bitcoin: bc1q0gd3mwjg3zy9sghv22kmpg823vss4c0zzdzg24
  • Solana: Eu8wQcW68TKMs1a6eqzZu8znzU52QLqQugAMG8uCD6y6
  • Ethereum / EVM: 0x2733ff7c865C56d565a99BE1DC11B81cc76850A5
  • XRP Ledger: r4X6e7McAQj7e8vBCeued1RYu4mCJrREDG

Crafted with ❤️ by Retiform Labs

Metadata

Release files for dharma-transcribe 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dharma-transcribe 0.1.3
File Size Uploaded Provenance Actions
dharma_transcribe-0.1.3.tar.gz 40.1 kB Without provenance Details for dharma_transcribe-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dharma-transcribe 0.1.3
File Interpreter ABI Platform Actions
dharma_transcribe-0.1.3-py3-none-any.whl Python 3 none any Details for dharma_transcribe-0.1.3-py3-none-any.whl

Total release size: 69.0 kB

Release files / dharma_transcribe-0.1.3.tar.gz

Download URL dharma_transcribe-0.1.3.tar.gz
Size 40.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bb8888c868c90d6769359c53220826b5496798134afab5066c6cdf6461ae89b6
BLAKE2b-256 checksum
How to use checksums
9ebc7a1b648ff80846e2d888eef532990e47b75b071e275fd32c3e11f5bc3c02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / dharma_transcribe-0.1.3-py3-none-any.whl

Download URL dharma_transcribe-0.1.3-py3-none-any.whl
Size 28.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfb2b10f05289f61d1aaad1cd98e71ea236f3d4d2683754a425bfefeec50d879
BLAKE2b-256 checksum
How to use checksums
d5c9b1b428c90d1199d6ec57e406dad9148ea2a304f7b68fa69238ac6b8807bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for dharma-transcribe 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page