OmniVoice data and training pipeline
OmniVoice training turns labeled speech into masked audio-token learning examples, packs those examples into efficient batches, and updates the OmniVoice model with distributed training. The pipeline also records enough state to resume work and provides loss and speech-quality checks for models that later serve the OmniVoice model. Generated-speech benchmark use belongs to OmniVoice inference.
Training system
The training system links four concerns: data preparation, example construction, model optimization, and result checks. A command-line entrypoint reads two JSON files, builds the model and data loaders, and starts the trainer.
This diagram shows the main path from source speech to a saved model.
flowchart LR
A[Raw JSONL and audio] --> B[Audio token preparation]
B --> C[WebDataset shards and data.lst]
C --> D[Sample reader]
D --> E[Masked sample processor]
E --> F[Token packing and collation]
F --> G[OmniVoice trainer]
G --> H[Loss and optimizer updates]
G --> I[Dev loss]
G --> J[Checkpoint and logs]
Dataset preparation
Source records
The pipeline starts with records that pair an utterance ID and audio path with text. Optional metadata can describe language, instructions, or alternate text. Audio is made mono and placed at the target sample rate before it is used for token extraction or training.
The preparation tools support two useful stages:
- jsonl_to_webdataset.py packs source audio and metadata into shard files. It adds duration data and writes an error report for records that fail.
- extract_audio_tokens.py converts audio into the multi-codebook tokens expected by OmniVoice. It writes token shards, matching metadata, a
data.lstmanifest, and processing errors.
Training reads the tokenized form. The raw-audio path is also available through JsonlDatasetReader for preparation and other data tools. It reads source records, loads and normalizes their audio, and skips records whose audio cannot be read. The training builder selects token-bearing WebDataset samples.
References: omnivoice/…/jsonl_to_webdataset.py• L18-49 omnivoice/…/extract_audio_tokens.py• L18-44 omnivoice/…/dataset.py• L363-449
Shard manifests
data.lst is the hand-off contract between preparation and training. Each line names an audio or token shard, its JSONL label file, the sample count, and the total duration. A data config maps these manifests to train and optional dev groups. Repeated manifest entries can increase the number of times a source is presented.
The manifest reader checks the four-field shape and converts counts and duration to numeric values. The label file maps each sample ID to its metadata, so the ID in a shard must match an ID in its paired labels.
References: omnivoice/…/dataset.py• L66-158 omnivoice/…/dataset.py• L161-189 omnivoice/…/dataset.py• L255-280 examples/…/data_config_emilia.json• L1-36
Example construction
Audio-token samples
The sample processor changes one decoded record into the tensors used by the model. It keeps audio tokens in their codebook layers, adds text and style context when conditioning is enabled, and marks only selected audio positions as prediction targets. Text and style positions do not contribute to the loss.
The processor samples prompt and mask ranges for training. It can drop the prompt and text conditioning, add language or instruction markers, and use pinyin text when that field is present. These choices expose the model to both conditioned and unconditioned cases.
References: omnivoice/…/processor.py• L35-90 omnivoice/…/processor.py• L92-172
Training and development streams
The builder creates one streaming reader for training and one for development data when the data config provides a dev group. Training shards are shuffled by epoch and within a buffer. Development shards keep a stable order so loss comparisons are easier to interpret.
The readers split work across distributed processes and data-loader workers. A raw JSONL reader and a WebDataset reader therefore expose the same sample shape while using different source formats. Multiple WebDataset readers can also be multiplexed, which lets a run draw from several sources with optional sampling weights. The trainer resets the stream at each new epoch, which changes the training shard order without changing the development order.
References: omnivoice/…/dataset.py• L283-359 omnivoice/…/dataset.py• L363-449 omnivoice/…/dataset.py• L452-477 omnivoice/…/builder.py• L142-178 omnivoice/…/trainer.py• L251-279
Batch formation
Token packing
OmniVoice uses a token budget instead of padding every utterance to the same source length. The packing stream processes records one at a time and groups them until the next record would exceed batch_tokens. A record that is longer than the full budget is skipped.
This approach keeps each emitted item close to the configured token budget. It is different from duration bucketing: the training builder uses token packing directly, while the duration-based grouping helper serves other streaming data work.
References: omnivoice/…/batching.py• L108-166 omnivoice/…/batching.py• L39-105 omnivoice/…/builder.py• L145-149
Collated model inputs
The collator joins the processed examples in a packed item and pads the result to the fixed token budget. It returns model inputs, masked loss labels, an audio-region mask, position IDs, and document IDs. Document IDs mark which packed positions came from the same source example, while padding is excluded from the loss and audio mask.
The data loader therefore uses batch_size=None: packing already creates the batch, and collation only makes its shape and boundary metadata uniform for the model.
References: omnivoice/…/collator.py• L30-90 omnivoice/…/builder.py• L149-165
Model and trainer construction
Model initialization
The builder chooses the text tokenizer from the initialization checkpoint when one is supplied; otherwise it uses the base language-model path. It adds the control markers needed by the data processor and aligns the model vocabulary with the tokenizer.
init_from_checkpoint supplies starting model weights for a new run, which is the normal fine-tuning path. resume_from_checkpoint is different: it restores the state of an existing training run after the trainer has prepared the model and optimizer.
References: omnivoice/…/builder.py• L49-120 omnivoice/…/config.py• L30-57 examples/…/train_config_finetune.json• L1-18
Trainer runtime
OmniTrainer places the model, optimizer, and schedule under Accelerate so the same loop can run with mixed precision and distributed processes. By default it uses AdamW with either constant or cosine warmup scheduling. Gradient accumulation turns several data batches into one optimizer step, and gradient clipping limits unusually large updates.
The trainer records progress at configured intervals. It evaluates against the development stream when one exists, saves at save intervals, and always saves the final state when the loop ends.
References: omnivoice/…/trainer.py• L56-185 omnivoice/…/trainer.py• L243-353
Configuration and run control
Training configuration
TrainingConfig is the single typed view of model, data, optimization, hardware, logging, and checkpoint settings. The training JSON is filtered to known fields, while output_dir and data_config are supplied by the command line. The example configs show the main run variants: Emilia training, multilingual training, and fine-tuning from a released checkpoint.
The settings that shape the training contract are:
| Setting group | Role |
|---|---|
| Model and audio vocabulary | Defines the language-model source, audio codebook count, and mask token used by prepared data. |
| Conditioning and masking | Controls prompt use, conditioning drop, language markers, instructions, and alternate text. |
| Optimization | Sets steps, learning rate, weight decay, warmup, accumulation, and gradient limits. |
| Data and system | Sets the token budget, worker count, precision, TF32, and optional DeepSpeed support. |
| Output and monitoring | Sets logging, evaluation, checkpoint intervals, retention, and output location. |
References: omnivoice/…/config.py• L30-98 examples/…/train_config_emilia.json• L1-38 examples/…/train_config_multilingual.json• L1-38
Training entrypoint
The training entrypoint is omnivoice.cli.train. It loads the config, applies the command-line data and output paths, builds the model and loaders, constructs OmniTrainer, and starts the loop. Distributed launch is supplied by Accelerate rather than by a separate OmniVoice training command.
A typical run has this shape:
accelerate launch --gpu_ids "0,1" --num_processes 2 \
-m omnivoice.cli.train \
--train_config config/train_config_finetune.json \
--data_config config/data_config_finetune.json \
--output_dir exp/omnivoice_finetune
The staged shell examples place data preparation before this command. The Emilia flow downloads or checks source manifests, extracts audio tokens for each split, and then trains. The fine-tuning flow performs the same token preparation for custom train and dev JSONL files.
References: omnivoice/…/train.py• L18-70 examples/run_emilia.sh• L45-115 examples/run_finetune.sh• L41-83
Checkpointing and monitoring
Checkpoint state
A checkpoint is a restart point for both the model and the training process. It stores the model and tokenizer in a reusable model directory and stores Accelerate state for the optimizer, schedule, random state, and related runtime state. The trainer also saves a copy of the run config inside each checkpoint.
Checkpoint rotation is optional. A positive retention value removes older checkpoint directories after a new save; a negative value keeps them all. Loading a checkpoint restores the trainer step from the directory name when that name follows the checkpoint-<step> form.
References: omnivoice/…/checkpoint.py• L118-180 omnivoice/…/trainer.py• L187-207 omnivoice/…/config.py• L80-84
Training metrics
The logger gives the main process a progress view and sends metrics to the configured TensorBoard tracker. Periodic training records include loss, learning rate, gradient norm, epoch, and step speed. Development evaluation reports mean eval/loss across the distributed workers.
TensorBoard reads the run directory selected by output_dir. The saved initial config and per-checkpoint config make a run easier to compare with its later model state.
References: omnivoice/…/checkpoint.py• L42-116 omnivoice/…/trainer.py• L133-159 omnivoice/…/trainer.py• L209-241
Evaluation helpers
Development loss
Development loss is an in-training check on the same masked-token objective used for updates. It does not produce speech; it measures whether the model fits the held-out tokenized examples. If no dev manifests are configured, the trainer skips this check.
Generated-speech metrics
Benchmark evaluation is a separate path after training or inference. run_eval.sh generates WAV files with the batch inference entrypoint, then compares them with reference test records. The helpers cover three broad signals:
- Speaker similarity compares embeddings from reference and generated speech.
- Word error rate compares normalized generated text with the reference transcript.
- UTMOS predicts a speech quality score for each generated file.
These helpers expect generated file IDs and test-list records to agree. They can write detailed per-item results and aggregate scores, including language-level summaries where the test data provides language names.
References: omnivoice/…/trainer.py• L209-241 examples/run_eval.sh• L111-143 omnivoice/…/sim.py• L151-176 omnivoice/…/common.py• L27-88 omnivoice/…/utmos.py• L181-291
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the audio codebook count, valid vocabulary, mask ID, and codebook loss weights aligned across token extraction,
TrainingConfig, the sample processor, and the model config. - Keep shard keys, label IDs, and
data.lstpaths aligned. A valid tar shard with a missing or mismatched label entry cannot become a training sample. - When label metadata changes, review the processor's language, instruction, pinyin, and text choices. These fields affect the conditioning contract rather than only record display.
- When the token budget or packed-input shape changes, review the packer, collator, and model boundary fields together.
position_ids,audio_mask, anddocument_idsdescribe the same packed sequence. - When checkpoint contents or directory naming changes, update both save and resume behavior. A model that can load for inference is not automatically a complete restart point for training.
- When generated-file IDs or test-list fields change, update batch inference and the speaker, WER, and MOS helpers as one evaluation contract.
- When a raw JSONL reader changes, keep its yielded
audioandlabelfields aligned with the WebDataset reader so shared processing paths receive the same sample shape.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A manifest line does not contain shard path, label path, count, and duration | Data setup stops before the reader can build its stream | Validate every data.lst line with the manifest format and check both paths |
| A shard key has no matching label ID | Sample decoding fails when metadata is looked up | Keep the original ID unchanged through JSONL input, token extraction, and shard writing |
| Audio is missing, unreadable, or outside the configured duration range | Preparation or reading reports an error and the sample is skipped or stops the token job | Inspect errors.jsonl and preparation counts before training |
A processed example is longer than batch_tokens | The packing stream drops the example without adding it to a batch | Set the token budget for the longest intended examples and monitor skipped samples |
A raw JSONL record has no usable audio_path or its audio cannot be decoded | The reader skips the record and the effective data set becomes smaller | Check source paths and reader warnings before starting a run |
init_from_checkpoint and resume_from_checkpoint are used for the wrong purpose | A fine-tune may start from the wrong weights, or a resume may lack the required optimizer state | Use initialization for a new run and resume for a saved training state |
| No development manifests are present | Training continues without periodic eval/loss | Add a valid dev group when held-out loss is part of run control |
| A generated WAV or reference path does not match the test-list ID | The corresponding speaker, WER, or MOS item fails and aggregate coverage falls | Check output IDs and reference paths before benchmark scoring |
Key files
| File | Why to read it |
|---|---|
| omnivoice/…/train.py | Shows the complete model-building and training entrypoint. |
| omnivoice/…/builder.py | Shows how configuration becomes a model, tokenizer, reader, packer, and loader. |
| omnivoice/…/config.py | Defines the run-level contract for model, data, optimization, system, and output settings. |
| omnivoice/…/dataset.py | Defines manifest handling, shard and JSONL reading, label lookup, and train/dev stream behavior. |
| omnivoice/…/processor.py | Defines how labeled speech becomes a masked, conditioned learning example. |
| omnivoice/…/batching.py and omnivoice/…/collator.py | Explain token-budget packing and the final packed tensors sent to the model. |
| omnivoice/…/trainer.py | Defines distributed updates, evaluation timing, logging, and save/resume control. |
| omnivoice/…/checkpoint.py | Defines checkpoint contents, rotation, progress metrics, and state restoration. |
| omnivoice/…/extract_audio_tokens.py | Shows the audio-to-codebook-token preparation boundary and its output contract. |
| examples/run_emilia.sh and examples/run_finetune.sh | Show the staged preparation and launch flows for pre-training and fine-tuning. |
| examples/…/data_config_emilia.json and examples/…/data_config_finetune.json | Show how train and dev manifests are assigned to a run. |
| examples/run_eval.sh | Shows how generated speech is connected to benchmark data and evaluation helpers. |