Introducing a new way to review your PRs.

Read the announcement

debpalash / voicestudio

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

View on GitHub

26 documents · Updated Nov 23, 2026

docs / omnivoice-model

OmniVoice model system

The bundled OmniVoice model system turns text and optional voice guidance into speech. It also provides the data preparation and training path used to create or adapt model checkpoints. The package supports VoiceStudio product flows and direct command-line use while keeping optional model assets out of unrelated application startup.

System boundary

OmniVoice is a multilingual text-to-speech package with three connected concerns: speech generation, preparation of training data, and model training. A checkpoint can serve inference or training, while the same model contract links text controls with discrete audio tokens. Inference loads the text tokenizer, audio tokenizer, and duration support when needed. Optional speech recognition is used only when a reference transcript is missing. References: omnivoice/…/omnivoice.py• L491-683, omnivoice/…/omnivoice.py• L689-783, omnivoice/…/omnivoice.py• L813-886

The model uses audio tokens, which are discrete values that represent short parts of sound. Text tokens and audio tokens share one model sequence. The model predicts the missing audio-token values, and an audio tokenizer turns them back into a waveform. This shared path supports voice cloning, voice design, and automatic voice selection. References: omnivoice/…/omnivoice.py• L233-259, omnivoice/…/omnivoice.py• L791-886, omnivoice/…/omnivoice.py• L1643-1722

The package serves both in-process callers and VoiceStudio process boundaries. VoiceStudio can place the model behind a sidecar or an optional GGUF runtime so a native model failure affects the current speech request instead of the whole backend. These runtime choices preserve the same high-level speech result and are described in OmniVoice inference and CLI. References: backend/…/__init__.py• L1-27, backend/…/main.py• L111-190, backend/…/backend.py• L341-367

Product capabilities

The model creates speech from plain text, a reference recording, or a description of a desired voice. It can estimate or target output duration, process long text in chunks, and serve multi-item requests. Request behavior and hardware choices are covered in OmniVoice inference and CLI.

Speech generation modes

Voice cloning uses a reference recording and its transcript to carry voice traits into new speech. A prepared clone prompt can be saved and reused. Voice design uses controlled speaker attributes such as gender, age, pitch, accent, or dialect. Auto voice uses neither and lets the model select a voice. These modes share one generation contract, so callers can change the voice source without changing the result shape. References: omnivoice/…/omnivoice.py• L114-163, omnivoice/…/omnivoice.py• L900-971, omnivoice/…/omnivoice.py• L1036-1067, omnivoice/…/omnivoice.py• L1976-2058

Audio duration control

Generation needs an audio length target because it predicts a sequence of audio tokens. The model estimates that length from the target text and any reference speech unless the caller supplies a duration. A speed value changes the estimate, while a fixed duration takes priority. Long requests move through text chunks before the chunks are joined into one result. References: omnivoice/…/omnivoice.py• L166-179, omnivoice/…/omnivoice.py• L993-1034, omnivoice/…/omnivoice.py• L1366-1475, omnivoice/…/omnivoice.py• L1551-1626

Command-line interfaces

The command-line layer maps common speech tasks to the shared model API. It offers a focused single-item tool, a multi-device batch tool, an interactive demo, and a headless dubbing driver. The direct tools use the same device and precision policy so a model follows one loading rule across CPU and accelerators.

Single-item synthesis

omnivoice-infer is the smallest direct entry point. It accepts text and optional language, reference audio, reference text, or voice instructions, then writes one WAV file. It selects CUDA, MPS, or CPU when no device is supplied and loads the checkpoint with the shared model loader. References: omnivoice/…/infer.py• L1-20, omnivoice/…/infer.py• L33-39, omnivoice/…/infer.py• L42-119, omnivoice/…/infer.py• L122-157

The command exposes the main generation controls without creating a separate speech path. A fixed duration overrides speed-based timing, while the model still applies its language and voice preparation rules. References: omnivoice/…/infer.py• L91-110, omnivoice/…/infer.py• L138-154, omnivoice/…/omnivoice.py• L917-971

Batch synthesis

omnivoice-infer-batch reads one JSON object per line and writes one audio file per item. It groups work by duration or batch size and uses device workers for offline evaluation and large jobs. References: omnivoice/…/infer_batch.py• L18-32, omnivoice/…/infer_batch.py• L204-253, omnivoice/…/infer_batch.py• L348-523

Interactive demo

omnivoice-demo provides a Gradio surface for voice cloning and voice design. It reuses the model's prompt and generation path, and it can load speech recognition when a user omits a reference transcript. References: omnivoice/…/demo.py• L17-24, omnivoice/…/demo.py• L154-221, omnivoice/…/demo.py• L507-537

Headless dubbing

omnivoice-dub is a product workflow driver rather than a local model wrapper. It sends media through ingest, transcription, translation, speech generation, and export stages over the running backend API. This keeps command-line dubbing aligned with the UI job flow. References: omnivoice/…/dub.py• L1-18, omnivoice/…/dub.py• L129-223

Data pipeline

The training data path changes source audio and text metadata into stable, streamable model examples. It uses JSONL records during preparation and paired WebDataset shards during training. Audio becomes the model's discrete token form while labels remain linked to each sample by its ID.

This diagram shows the main preparation path from source records to model-ready training batches.

flowchart LR
    A[Audio files and JSONL labels] --> B[Shard and metadata packing]
    B --> C[Optional denoise or prompt augmentation]
    C --> D[Audio token extraction]
    D --> E[WebDataset shards and manifest]
    E --> F[Streaming readers]
    F --> G[Prompt and mask processing]
    G --> H[Token-budget batches]
    H --> I[Model training]

Dataset records

The source contract contains an ID, an audio path, and text, with optional language and voice-instruction data. The packer writes audio shards with per-shard JSONL labels and a data.lst manifest. The manifest joins each shard with its labels, item count, and duration. References: omnivoice/…/jsonl_to_webdataset.py• L18-49, omnivoice/…/jsonl_to_webdataset.py• L150-187, omnivoice/…/jsonl_to_webdataset.py• L408-421

The packer can shuffle records and reject audio outside the allowed duration range. It records failed records in errors.jsonl, which lets a preparation run be reviewed without losing the source ID. References: omnivoice/…/jsonl_to_webdataset.py• L306-323, omnivoice/…/jsonl_to_webdataset.py• L373-422

Audio token records

Audio-token extraction replaces waveform payloads with an eight-channel discrete representation and stores it beside the original metadata. It accepts raw JSONL or an existing manifest and can spread work across workers and machines. A related path adds noise or room-response effects to the prompt portion and records where clean audio begins for denoising-aware training. References: omnivoice/…/extract_audio_tokens.py• L18-45, omnivoice/…/extract_audio_tokens.py• L218-265, omnivoice/…/extract_audio_tokens.py• L339-411, omnivoice/…/extract_audio_tokens_add_noise.py• L18-50, omnivoice/…/extract_audio_tokens_add_noise.py• L349-455

The denoise stage can restore input audio before token extraction. It reads raw JSONL or a prior manifest and writes new paired shards with a fresh manifest and error log. This keeps cleanup separate from the later reader contract. References: omnivoice/…/denoise_audio.py• L18-48, omnivoice/…/denoise_audio.py• L405-468, omnivoice/…/denoise_audio.py• L816-838, omnivoice/…/denoise_audio.py• L1022-1045

Training examples

The training processor combines voice controls, text, and audio tokens into one model example. It varies how much prompt and target audio remains visible, then marks only the audio-token values that the model must learn. Language, instruction, and denoising signals can travel with the example. References: omnivoice/…/processor.py• L18-27, omnivoice/…/processor.py• L66-172

Streamed batches

Training reads shard pairs as an iterable stream and can combine readers for multilingual data. It packs examples by total token count instead of padding each item to the same length. Document boundaries keep packed examples from attending to unrelated samples. References: omnivoice/…/dataset.py• L18-36, omnivoice/…/dataset.py• L192-251, omnivoice/…/dataset.py• L307-356, omnivoice/…/batching.py• L108-166, omnivoice/…/collator.py• L30-90, omnivoice/…/omnivoice.py• L813-843

Inference system

Inference turns a request into a conditional text-and-audio sequence, predicts audio tokens through repeated masked-token updates, and decodes those tokens into audio. The same path carries language, instruction, and voice-reference context before it returns one waveform per requested text.

This diagram shows how a generation request moves through the shared inference path.

flowchart TD
    A[Text and voice controls] --> B[Normalize language and prompt]
    B --> C[Estimate or set token length]
    C --> D{Short or long request}
    D -->|Short| E[Iterative token generation]
    D -->|Long| F[Text chunks]
    F --> G[Iterative generation per chunk]
    G --> H[Join chunk audio]
    E --> I[Audio tokenizer decode]
    H --> I
    I --> J[Silence, level, and edge processing]
    J --> K[Waveform output]

Model inputs and outputs

The public model accepts one text string or a batch of texts. Optional per-item controls include language, reference speech, a reusable clone prompt, a voice instruction, speed, and duration. It returns a list of two-dimensional audio tensors at the sampling rate supplied by the audio tokenizer. References: omnivoice/…/omnivoice.py• L900-971, omnivoice/…/omnivoice.py• L1477-1612

Reference and output audio

Reference audio is loaded at the model sample rate and reduced to one channel. The model validates it, selects a usable speech passage, and turns that passage into a reusable clone prompt. A supplied transcript limits the reference to a bounded clip. Without one, a cached speech recognizer can find and transcribe a suitable passage. References: omnivoice/…/omnivoice.py• L1036-1067, omnivoice/…/omnivoice.py• L1081-1121, omnivoice/…/omnivoice.py• L1131-1247

The model protects both reference and generated audio from empty or unsafe results. It preserves quiet but valid recordings when hard silence removal would erase them, checks host memory before a CPU reference encode, and applies silence, level, fade, and edge padding to the final waveform. References: omnivoice/…/omnivoice.py• L1254-1283, omnivoice/…/omnivoice.py• L1285-1364

Token generation

The generation loop starts with masked audio positions and fills them over several steps. It compares conditional and unconditional predictions when guidance is enabled, scores candidate audio values, and fills the most certain positions first. Long requests use the same process for text chunks and then cross-fade the decoded audio. References: omnivoice/…/omnivoice.py• L1724-1901, omnivoice/…/omnivoice.py• L1366-1475

Runtime acceleration

The default path uses supported transformer attention implementations. An optional FlashInfer path packs conditional and unconditional sequences and can reuse CUDA graphs for repeated shapes. It keeps the same token scoring and unmasking contract, while requests outside its duration or context limits use an eager fallback. References: omnivoice/…/omnivoice_flashinfer.py• L3-32, omnivoice/…/omnivoice_flashinfer.py• L187-235, omnivoice/…/omnivoice_flashinfer.py• L377-453, omnivoice/…/omnivoice_flashinfer.py• L481-667

Crash-isolated runtime

The crash-isolated runtime puts the model behind a sidecar process. The backend sends synthesis requests over a private framed JSON channel and receives mono PCM audio. The sidecar loads the model on demand and reports readiness and load progress before returning audio. A stalled request can be stopped without restarting the API. References: backend/…/__init__.py• L12-27, backend/…/main.py• L1-29, backend/…/main.py• L41-90, backend/…/main.py• L107-190, backend/…/main.py• L271-390

GGUF runtime boundary

The optional GGUF backend exposes the same basic speech result through a bundled native runtime. It chooses a hardware-appropriate quantized model and tokenizer, starts a separate process for each request, and falls back to in-process OmniVoice when the runtime is not usable. It supports text, language, cloning references, style instructions, duration, and long-form controls, but not voice design. References: backend/…/backend.py• L341-367, backend/…/backend.py• L471-541, backend/…/backend.py• L594-672, backend/…/backend.py• L854-887

For request details, hardware behavior, voice controls, and command examples, see OmniVoice inference and CLI. The data preparation and checkpoint workflow are covered in OmniVoice data and training pipeline.

Training lifecycle

Training starts with a model configuration and a data manifest. Setup creates the model and tokenizer, opens packed train and optional evaluation streams, and passes them to a distributed trainer. The trainer updates the model while recording metrics and saving checkpoints that can resume training or serve inference.

This diagram shows the lifecycle from configuration to a reusable checkpoint.

flowchart LR
    A[Training and data configuration] --> B[Model and tokenizer setup]
    A --> C[Manifest readers]
    C --> D[Processed packed batches]
    B --> E[Distributed trainer]
    D --> E
    E --> F[Loss and optimizer updates]
    F --> G[Evaluation and metrics]
    F --> H[Checkpoint and tokenizer]
    H --> I[Resume or inference]

Model setup

The training builder creates an OmniVoice model around a base language model or restores one from an existing checkpoint. It aligns the tokenizer with the model's special control tokens and returns the pair used by training and checkpoint saving. The model combines text processing with audio-token prediction, so its training and inference paths share the same core contract. References: omnivoice/…/builder.py• L49-120, omnivoice/…/omnivoice.py• L233-259, omnivoice/…/omnivoice.py• L491-543

Optimization loop

The trainer uses Accelerate so one configuration can run on one device or across distributed devices. It supports mixed precision, gradient accumulation, learning-rate scheduling, evaluation, and metric logging. When a data stream ends, it starts the next epoch with a new reader seed. References: omnivoice/…/trainer.py• L56-185, omnivoice/…/trainer.py• L209-353

Checkpoint lifecycle

Each checkpoint preserves the model and tokenizer with optimizer, scheduler, random-state, and related accelerator state. A later run can restore the directory and recover its step count. Optional rotation removes older checkpoints when a retention limit is set. References: omnivoice/…/checkpoint.py• L118-180, omnivoice/…/trainer.py• L187-207

For data preparation, training configuration, and checkpoint workflow details, see OmniVoice data and training pipeline.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the audio tokenizer's codebook count and mask-token contract aligned across model configuration, token extraction, sample processing, and decoding.
  • Keep the data.lst manifest contract aligned between shard writers, dataset readers, token extraction tools, and training configuration.
  • Keep tokenizer special tokens aligned between model setup and inference and training prompt formats.
  • Keep checkpoint contents compatible with both inference loading and accelerator resume loading.
  • Keep long-request chunk behavior aligned between the baseline and optional accelerated paths.
  • Keep CLI option names aligned with the shared generation API when adding voice or duration controls.
  • Keep the device and precision policy aligned across direct CLIs, demo, workers, and sidecar loading.
  • Keep the sidecar request and response contract aligned for readiness, progress, audio format, sample rate, and errors.
  • Keep optional tokenizer and speech-recognition loading deferred and cache-aware so unrelated backend features can start.
  • Keep clone-reference validation and failure markers aligned with the caller's error mapping.

Important failure modes

TriggerConsequenceGuard
A checkpoint has no usable audio-tokenizer assetThe model cannot encode references or decode generated audioKeep the tokenizer with the checkpoint or allow the documented fallback asset to load
The audio tokenizer dependency is missing or mismatchedSpeech requests fail while unrelated backend features can still startInstall compatible audio dependencies and load the tokenizer only when speech needs it
A local or cached checkpoint is incompleteModel loading fails before generationTreat the checkpoint and its tokenizer assets as one complete unit
Reference audio is empty, silent, or non-finiteVoice-clone prompt creation failsUse a clear short speech recording and check the input file or device
Automatic cloning has no cached speech recognizerA reference without supplied text cannot be selected or transcribedProvide matching reference text or install a complete speech-to-text checkpoint
A batch mixes reference and non-reference items during long-form generationChunked generation rejects the batchGroup items by compatible voice-reference mode
A manifest points to a missing shard, label file, or mismatched sample IDThe reader cannot pair audio tokens with text metadataValidate manifest paths and preserve one stable ID in both records
A resumed checkpoint is incomplete or does not match the training setupOptimizer or model state cannot resume reliablyRetain the model, tokenizer, and accelerator state as one checkpoint unit
FlashInfer is requested without supported CUDA or its optional dependencyThe accelerated path cannot runUse the default path or install a matching CUDA and FlashInfer stack
A sidecar times out or its framed stream is polluted by logsThe current synthesis fails or the parent loses protocol alignmentKeep the private channel clean and preserve the ready, progress, and timeout guards
A GGUF binary or pinned model asset is missing or invalidThe optional runtime is unavailableVerify the bundled binary and use the in-process fallback
A voice instruction contains unsupported valuesRequest preparation fails before token generationUse the supported language-specific instruction values

Key files

FileWhy to read it
omnivoice/…/omnivoice.pyPrimary model contract shared by inference and training
omnivoice/…/infer.pySmallest direct synthesis entry point and device selection
omnivoice/…/infer_batch.pyOffline synthesis and device-worker flow
omnivoice/…/demo.pyInteractive voice cloning and voice design surface
omnivoice/…/dub.pyHeadless product dubbing lifecycle driver
omnivoice/…/jsonl_to_webdataset.pySource-record to shard and manifest handoff
omnivoice/…/extract_audio_tokens.pyWaveform to model-ready audio-token conversion
omnivoice/…/dataset.pyStreaming audio, token, and label readers
omnivoice/…/processor.pyTraining prompt, mask, and label construction
omnivoice/…/collator.pyPacked batch representation and document boundaries
omnivoice/…/builder.pyModel, tokenizer, and loader assembly
omnivoice/…/trainer.pyDistributed optimization, evaluation, and save schedule
omnivoice/…/checkpoint.pyCheckpoint persistence and resume contract
backend/…/main.pySidecar lifecycle and model-to-audio message flow
backend/…/backend.pyOptional native runtime and engine fallback