Data preparation pipeline that converts audio datasets into multi-layer codec tokens (nano-codec) while maintaining original text transcriptions for TTS training
Python
9
4 commits
updated Oct 24, 2025
===============================================
N I N E N I N E S I X πΌ
===============================================
/\_/\
( -.- )ββββ
> ^ < β
===============================================
This pipeline takes your audio datasets from HuggingFace and converts them into tokenized neural codec representations using NVIDIA NeMo NanoCodec.
If you're training audio generation models (like TTS, voice cloning, or speech models), you need your audio data in a tokenized format. This pipeline:
Perfect for: Anyone training audio models that need tokenized audio data (like language models for speech, TTS systems, voice conversion, etc.)
sudo ./setup.sh
The script will:
Setup takes ~5 minutes.
source venv/bin/activate
You should see (venv) appear in your terminal prompt.
You need to authenticate so the pipeline can download and upload datasets:
# Store credentials (so you don't have to log in every time)
git config --global credential.helper store
# Login to HuggingFace
hf auth login
Paste your HuggingFace token when prompted. Get one here: https://huggingface.co/settings/tokens
Edit config.yaml to tell the pipeline what to process:
nano config.yaml
See the Configuration Guide below for details!
python main.py
You'll see progress bars for each GPU and reader process.
The config.yaml file controls everything. Here's what each part does:
base_settings:
audio_codec: nvidia/nemo-nano-codec-22khz-0.6kbps-12.5fps # The model to use
num_readers: 8 # How many CPU processes read data (more = faster)
qsize: 100000 # Queue size (bigger = more RAM, but smoother)
OUT_DIR: shards # Where to save the encoded files
gzip_level: 1 # Compression (1=fast, 9=small files)
buffer_size: 16777216 # Write buffer (16MB is good)
lines_per_file: 50000 # Split output into chunks of 50k samples
load_dataset_num_proc: 20 # Parallel processes for loading (faster!)
save_settings:
local: train_dataset # Save to this folder (or null to skip)
hf_upload: your-username/your-dataset # Upload to HF (or null to skip)
hf_datasets:
- name: your-username/audio-dataset-1 # HuggingFace dataset to process
sub_name: null # Dataset subset/config (or null)
split: train # Which split to use (train/test/validation)
text_column_name: text # Name of the text column
audio_column_name: audio # Name of the audio column
speaker_column_name: null # Speaker column (or null if none)
add_constant: # Add these fields to every sample
- key: speaker
value: speaker1
- key: lang
value: en
- name: your-username/audio-dataset-2 # You can add multiple datasets!
sub_name: clean # Example: LibriSpeech has 'clean', 'other' subsets
split: train # Which split to use
text_column_name: sentences
audio_column_name: audio
speaker_column_name: speaker_id # This dataset has speaker info
add_constant:
- key: lang
value: en
base_settings - Core Configuration| Setting | What It Does | Recommended Value |
|---|---|---|
audio_codec | Which NeMo model to use | nvidia/nemo-nano-codec-22khz-0.6kbps-12.5fps |
num_readers | CPU processes reading data | 8 (more if you have many CPU cores) |
qsize | Queue buffer size | 100000 (increase if you have lots of RAM) |
OUT_DIR | Output folder | shards |
gzip_level | Compression level | 1 (fast) or 9 (small files) |
buffer_size | Write buffer size | 16777216 (16MB) |
lines_per_file | Samples per output file | 50000 |
load_dataset_num_proc | Parallel loading | 20 (more = faster loading) |
save_settings - Where to Save| Setting | What It Does | Example |
|---|---|---|
local | Save to local disk | train_dataset or null to skip |
hf_upload | Upload to HuggingFace | username/dataset-name or null to skip |
hf_datasets - Your DatasetsEach dataset entry has:
| Field | What It Does | Example |
|---|---|---|
name | HuggingFace dataset name | openslr/librispeech_asr |
sub_name | Dataset subset/configuration | clean, other, or null if none |
split | Which split to load | train, test, validation |
text_column_name | Column with text/transcription | text, sentence, transcription |
audio_column_name | Column with audio data | audio, speech, wav |
speaker_column_name | Column with speaker ID | speaker, speaker_id, or null |
add_constant | Fields to add to every sample | Add metadata like language, speaker, etc. |
π‘ Pro Tip: The add_constant fields are super useful! Add metadata like:
lang: en)source: librispeech)speaker: john)After processing, you'll have:
Files in shards/ folder (or your OUT_DIR):
dataset-name-worker00-00000.jsonl.gz
dataset-name-worker00-00001.jsonl.gz
dataset-name-worker01-00000.jsonl.gz
...
If you set local or hf_upload, you'll get a merged dataset with:
{
"text": "Hello world",
"nano_layer_1": [123, 456, 789, ...], // Codec tokens layer 1
"nano_layer_2": [234, 567, 890, ...], // Codec tokens layer 2
"nano_layer_3": [345, 678, 901, ...], // Codec tokens layer 3
"nano_layer_4": [456, 789, 012, ...], // Codec tokens layer 4
"encoded_len": 150, // Number of tokens
"speaker": "speaker1", // Your metadata
"lang": "en"
}
Perfect for: Training TTS models, voice conversion, speech generation, etc.
If you're training audio generation models, you need your audio in a tokenized format. This pipeline:
from datasets import load_dataset
# Load your processed dataset
dataset = load_dataset("your-username/your-dataset")
# Each sample has:
# - text: the transcription
# - nano_layer_1-4: codec tokens (4 layers)
# - encoded_len: sequence length
# - any metadata you added (speaker, lang, etc.)
for sample in dataset:
text = sample['text']
tokens_layer1 = sample['nano_layer_1'] # Shape: [encoded_len]
tokens_layer2 = sample['nano_layer_2']
# Use these tokens to train your model!
Just add more entries to hf_datasets:
hf_datasets:
- name: dataset1
# ... config ...
- name: dataset2
# ... config ...
- name: dataset3
# ... config ...
All datasets will be processed sequentially and merged into one final dataset.
Use add_constant to tag your data:
add_constant:
- key: dataset_source
value: librispeech
- key: lang
value: en
- key: quality
value: clean
This helps when training multi-dataset models!
The pipeline automatically uses all available GPUs. Each GPU:
More GPUs = faster processing! π
LOGGING_GUIDE.md - Logging configurationconfig.yaml - Your configuration file (edit this!)Make sure you have:
Check with: nvidia-smi
Run: chmod +x setup.sh
Get a token from: https://huggingface.co/settings/tokens
Make sure you select "Write" permissions
num_readers (more CPU processes)load_dataset_num_proc (faster loading)nvidia-smiqsize (smaller queue)num_readers (fewer parallel processes)Apache 2. See LICENSE file for details.
2 commits
2 commits
Python
73.7%
Shell
26.3%
Data preparation pipeline that converts audio datasets into multi-layer codec tokens (nano-codec) while maintaining original text transcriptions for TTS training
Python
9
4 commits
updated Oct 24, 2025
===============================================
N I N E N I N E S I X πΌ
===============================================
/\_/\
( -.- )ββββ
> ^ < β
===============================================
This pipeline takes your audio datasets from HuggingFace and converts them into tokenized neural codec representations using NVIDIA NeMo NanoCodec.
If you're training audio generation models (like TTS, voice cloning, or speech models), you need your audio data in a tokenized format. This pipeline:
Perfect for: Anyone training audio models that need tokenized audio data (like language models for speech, TTS systems, voice conversion, etc.)
sudo ./setup.sh
The script will:
Setup takes ~5 minutes.
source venv/bin/activate
You should see (venv) appear in your terminal prompt.
You need to authenticate so the pipeline can download and upload datasets:
# Store credentials (so you don't have to log in every time)
git config --global credential.helper store
# Login to HuggingFace
hf auth login
Paste your HuggingFace token when prompted. Get one here: https://huggingface.co/settings/tokens
Edit config.yaml to tell the pipeline what to process:
nano config.yaml
See the Configuration Guide below for details!
python main.py
You'll see progress bars for each GPU and reader process.
The config.yaml file controls everything. Here's what each part does:
base_settings:
audio_codec: nvidia/nemo-nano-codec-22khz-0.6kbps-12.5fps # The model to use
num_readers: 8 # How many CPU processes read data (more = faster)
qsize: 100000 # Queue size (bigger = more RAM, but smoother)
OUT_DIR: shards # Where to save the encoded files
gzip_level: 1 # Compression (1=fast, 9=small files)
buffer_size: 16777216 # Write buffer (16MB is good)
lines_per_file: 50000 # Split output into chunks of 50k samples
load_dataset_num_proc: 20 # Parallel processes for loading (faster!)
save_settings:
local: train_dataset # Save to this folder (or null to skip)
hf_upload: your-username/your-dataset # Upload to HF (or null to skip)
hf_datasets:
- name: your-username/audio-dataset-1 # HuggingFace dataset to process
sub_name: null # Dataset subset/config (or null)
split: train # Which split to use (train/test/validation)
text_column_name: text # Name of the text column
audio_column_name: audio # Name of the audio column
speaker_column_name: null # Speaker column (or null if none)
add_constant: # Add these fields to every sample
- key: speaker
value: speaker1
- key: lang
value: en
- name: your-username/audio-dataset-2 # You can add multiple datasets!
sub_name: clean # Example: LibriSpeech has 'clean', 'other' subsets
split: train # Which split to use
text_column_name: sentences
audio_column_name: audio
speaker_column_name: speaker_id # This dataset has speaker info
add_constant:
- key: lang
value: en
base_settings - Core Configuration| Setting | What It Does | Recommended Value |
|---|---|---|
audio_codec | Which NeMo model to use | nvidia/nemo-nano-codec-22khz-0.6kbps-12.5fps |
num_readers | CPU processes reading data | 8 (more if you have many CPU cores) |
qsize | Queue buffer size | 100000 (increase if you have lots of RAM) |
OUT_DIR | Output folder | shards |
gzip_level | Compression level | 1 (fast) or 9 (small files) |
buffer_size | Write buffer size | 16777216 (16MB) |
lines_per_file | Samples per output file | 50000 |
load_dataset_num_proc | Parallel loading | 20 (more = faster loading) |
save_settings - Where to Save| Setting | What It Does | Example |
|---|---|---|
local | Save to local disk | train_dataset or null to skip |
hf_upload | Upload to HuggingFace | username/dataset-name or null to skip |
hf_datasets - Your DatasetsEach dataset entry has:
| Field | What It Does | Example |
|---|---|---|
name | HuggingFace dataset name | openslr/librispeech_asr |
sub_name | Dataset subset/configuration | clean, other, or null if none |
split | Which split to load | train, test, validation |
text_column_name | Column with text/transcription | text, sentence, transcription |
audio_column_name | Column with audio data | audio, speech, wav |
speaker_column_name | Column with speaker ID | speaker, speaker_id, or null |
add_constant | Fields to add to every sample | Add metadata like language, speaker, etc. |
π‘ Pro Tip: The add_constant fields are super useful! Add metadata like:
lang: en)source: librispeech)speaker: john)After processing, you'll have:
Files in shards/ folder (or your OUT_DIR):
dataset-name-worker00-00000.jsonl.gz
dataset-name-worker00-00001.jsonl.gz
dataset-name-worker01-00000.jsonl.gz
...
If you set local or hf_upload, you'll get a merged dataset with:
{
"text": "Hello world",
"nano_layer_1": [123, 456, 789, ...], // Codec tokens layer 1
"nano_layer_2": [234, 567, 890, ...], // Codec tokens layer 2
"nano_layer_3": [345, 678, 901, ...], // Codec tokens layer 3
"nano_layer_4": [456, 789, 012, ...], // Codec tokens layer 4
"encoded_len": 150, // Number of tokens
"speaker": "speaker1", // Your metadata
"lang": "en"
}
Perfect for: Training TTS models, voice conversion, speech generation, etc.
If you're training audio generation models, you need your audio in a tokenized format. This pipeline:
from datasets import load_dataset
# Load your processed dataset
dataset = load_dataset("your-username/your-dataset")
# Each sample has:
# - text: the transcription
# - nano_layer_1-4: codec tokens (4 layers)
# - encoded_len: sequence length
# - any metadata you added (speaker, lang, etc.)
for sample in dataset:
text = sample['text']
tokens_layer1 = sample['nano_layer_1'] # Shape: [encoded_len]
tokens_layer2 = sample['nano_layer_2']
# Use these tokens to train your model!
Just add more entries to hf_datasets:
hf_datasets:
- name: dataset1
# ... config ...
- name: dataset2
# ... config ...
- name: dataset3
# ... config ...
All datasets will be processed sequentially and merged into one final dataset.
Use add_constant to tag your data:
add_constant:
- key: dataset_source
value: librispeech
- key: lang
value: en
- key: quality
value: clean
This helps when training multi-dataset models!
The pipeline automatically uses all available GPUs. Each GPU:
More GPUs = faster processing! π
LOGGING_GUIDE.md - Logging configurationconfig.yaml - Your configuration file (edit this!)Make sure you have:
Check with: nvidia-smi
Run: chmod +x setup.sh
Get a token from: https://huggingface.co/settings/tokens
Make sure you select "Write" permissions
num_readers (more CPU processes)load_dataset_num_proc (faster loading)nvidia-smiqsize (smaller queue)num_readers (fewer parallel processes)Apache 2. See LICENSE file for details.
2 commits
2 commits
Python
73.7%
Shell
26.3%