# langswap — advanced guide Detailed reference for running langswap from source, the model registry, all environment variables, Docker build notes, and troubleshooting. For the quick path see the [README](../README.md). The pipeline: **ASR** (faster-whisper large-v3 + Silero VAD) → **translation** (Gemma-4-E2B) → **TTS** (OmniVoice) → **dubbing/merge** → muxed video + SRT subtitles. It runs entirely on a local machine (no S3/AWS required). --- ## 1. Prerequisites - **Python 3.12** and [`uv`](https://github.com/astral-sh/uv) - **NVIDIA GPU** with a recent driver (CUDA 13 capable; the stack uses `torch==2.11.0+cu130`) - **System tools:** - `ffmpeg` — audio/video processing - `rubberband-cli` — time-stretching for the `speedup` / `stretch_whole` dubbing algorithms ```bash sudo apt-get install -y ffmpeg rubberband-cli ``` - **Docker** + the **NVIDIA Container Toolkit** — to run the all-in-one container - **HuggingFace token** (`HF_TOKEN`) — required only for the gated `pyannote/speaker-diarization-3.1` model (used when diarization is enabled). The default backends' weights download without a token. Create a `.env` in the project root: ```bash HF_TOKEN=hf_xxxxxxxxxxxxxxxxx ELEVEN_API_KEY=... # only if using the ElevenLabs TTS backend MODEL_WEIGHTS_DIR=./models_weights # where model weights live (used by Docker too) LANGSWAP_DATA_DIR=./data # where outputs/artifacts go ``` --- ## 2. Install dependencies **uv is the only supported installer, and `pyproject.toml` is the single source of truth for dependencies** (there is no `requirements.txt` / lock file). One command per variant: ```bash uv venv --python 3.12 source .venv/bin/activate uv pip install -e ".[gpu]" # full local-model stack (NVIDIA GPU) # or, Mac / no GPU — hosted APIs, far fewer deps: uv pip install -e ".[api]" # RunPod serverless worker (what the Docker image installs): uv pip install -e ".[gpu,runpod]" ``` No pre-install step or index flags are needed: `torch`/`torchaudio`/`torchcodec` for the `[gpu]` extra resolve from the CUDA 13 wheel index, and `llama-cpp-python` from its prebuilt CPU wheel — both wired in pyproject's `[tool.uv]` section. The `[api]` extra's torch resolves from PyPI (CPU/MPS). `transformers==5.9.0` / `vllm==0.21.0` are pinned in the `[gpu]` extra to the validated ABI pair OmniVoice needs, so torch is resolved to a compatible cu130 build automatically. --- ## 3. Model weights Models are loaded directly from HuggingFace and **auto-downloaded on first use** into the project's `models_weights/` directory (i.e. `MODEL_WEIGHTS_DIR`, which defaults to `./models_weights`). Keeping weights in the project tree is what makes the container and runpod builds self-contained. Set `HF_TOKEN` for the gated models. | Model | Default repo / id | Gated | Used by | |------------------|--------------------------------------------------------------------|---------|----------------------------| | faster-whisper | `large-v3` | No | ASR `vad` (default) | | Silero VAD | `silero-vad` (bundled, ~1.4 MB) | No | ASR `vad` segmentation | | Gemma-4-E2B GGUF | `unsloth/gemma-4-E2B-it-GGUF` / `gemma-4-E2B-it-UD-Q4_K_XL.gguf` | No | translation `llamacpp` (default) | | OmniVoice | `k2-fsa/OmniVoice` | No | TTS `omnivoice` (default) | | pyannote | `pyannote/speaker-diarization-3.1` | **Yes** | diarization (optional) | Model ids and repos are **hardcoded** in each client (no env-var overrides). To use a different model, change the constant in the relevant `*_client.py`. The hosted-API backends (`openai` ASR/translation, `elevenlabs` TTS) download no weights. --- ## 4. Run locally for debugging (`main.py local`) Runs each pipeline stage separately with verbose logging and caches intermediate JSON under `data//`, so reruns skip stages that already succeeded. ```bash .venv/bin/python main.py local 12.mp4 english russian 2>&1 | tee /tmp/langswap_debug.log ``` Positional args: `local