[!IMPORTANT] This is the legacy repository for the Interspeech 2025 conference paper. An extended version with a cleaner, updated implementation is now available at P1ping/TokAN β please head there for the latest code and models.
This repository contains the official implementation and pretrained models for the Interspeech 2025 paper: "Accent Normalization Using Self-Supervised Discrete Tokens with Non-Parallel Data".
We strongly recommend using a conda or venv virtual environment with Python 3.8+.
First, clone the repository, making sure to initialize the fairseq submodule.
git clone --recurse-submodules https://github.com/P1ping/TokAN-Legacy.git
cd TokAN-Legacy
If you forgot the --recurse-submodules flag, run git submodule update --init --recursive after cloning.
Then, create and activate your virtual environment:
# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
# Or you can create a new environment via conda
For successful load of fairseq models, we recommend torch<=2.5.1.
For other CUDA versions or CPU-only installation of PyTorch, please visit the official PyTorch website for the correct command.
Install eSpeak (required for training):
# On Ubuntu/Debian
sudo apt-get install espeak espeak-data
# On other systems, visit: http://espeak.sourceforge.net/
# Please ensure the output version is latest (1.48)
espeak --version
Note: eSpeak (version 1.48) is required if you plan to run the training pipeline, as it's used for phoneme processing in the text-to-speech components.
The token-to-token component of TokAN requires the fairseq toolkit, which is included in the third_party directory.
This should be installed before the the main project. Fairseq requires a lower version of hydra-core, which should be upgraded during installation of the main project.
π‘ Tip: You probably need
pip<=24.0andgcc 9 or laterfor successful fairseq installation.
# Navigate to the submodule directory
cd third_party/fairseq
# Install this specific version of fairseq in editable mode
pip install -e .
# Return to the project root directory
cd ../..
Now that the critical dependencies are in place, you can install the remaining packages from requirements.txt and then install the TokAN source code itself.
# Install all other required packages
pip install -r requirements.txt
# Install the project's core source code in editable mode
pip install -e .
After these steps, the environment is fully configured to run inference.
python inference.py --input_path /path/to/input.wav --output_path /path/to/output.wav --download_models
This will automatically download all required models and perform accent conversion on your audio file. Specifically, it will split the input audio (when it is long) into chunks and convert them one by one. The chunking is based on silero_vad, please check the arguments for detailed configurations. When --preserve_duration is given, the script will select the model with flow-matching-based duration prediction for total duration preservation.
β οΈ Note: If the download is interrupted, please delete the partially downloaded file so that it can be downloaded again.
TokAN requires two main datasets for training:
LibriTTS-R is used for training the text-to-speech components and token-to-token pre-training. The dataset should be organized as follows:
LibriTTS_R/
βββ train-clean-100/
βββ train-clean-360/
βββ train-other-500/
βββ dev-clean/
βββ dev-other/
βββ test-clean/
βββ test-other/
Download Instructions:
libritts_root path in run.shL2ARCTIC contains non-native English speech, while ARCTIC provides native English speakers for comparison. The combined dataset should include:
L2ARCTIC Speakers (by accent):
<ar>): ABA, YBAA, ZHAA, SKA<zh>): BWC, LXC, NCC, TXHC<hi>): ASI, RRBI, SVBI, TNI<ko>): HJK, YDCK, YKWK, HKK<es>): EBVS, ERMS, NJS, MBMPS<vi>): HQTV, PNV, THV, TLVARCTIC Native Speakers (<us>): BDL, RMS, SLT, CLB
Expected Directory Structure:
l2arctic/
β # L2ARCTIC speakers (direct extraction)
βββ YBAA/
βββ BWC/
βββ ...
β # ARCTIC native speakers
βββ BDL/
βββ RMS/
βββ SLT/
βββ CLB/
Download Instructions:
For L2ARCTIC:
For ARCTIC Native Speakers:
cmu_us_bdl_arctic.tar.bz2, cmu_us_rms_arctic.tar.bz2, cmu_us_slt_arctic.tar.bz2, cmu_us_clb_arctic.tar.bz2Before training, verify your datasets are properly prepared:
# Verify both datasets
bash run.sh --stage 0 --stop_stage 0
# Or run the verification script directly
python scripts/verify_data_preparation.py --libritts_root /path/to/LibriTTS_R --l2arctic_root /path/to/l2arctic
The verification script will:
TokAN training consists of multiple stages that build upon each other. We recommend running stages sequentially using bash run.sh --stage [STAGE] --stop_stage [STAGE].
bash run.sh --stage 0 --stop_stage 0
Validates that all required datasets are properly prepared and accessible.
bash run.sh --stage 1 --stop_stage 1
Checks for pre-trained HuBERT and k-means models required for speech tokenization. We recommend specify the related paths directly in the script. If you use HuBERT other than hubert_large_ll60k or our pre-trained K-means model, please also update hubert_path, hubert_layer, and n_clusters correspondingly.
Options:
### Pre-trained Models section belowthird_party/fairseq/examples/hubert/simple_kmeans/README.mdπ‘ Note: K-means clustering is storage-intensive. We recommend using the one we provide, which was clustered on LibriTTS-R. If you have changed the number of clusters, please also update n_vocab in components/token_to_mel/configs/model/yirga.yaml
bash run.sh --stage 2 --stop_stage 2
Trains the text-to-speech model on LibriTTS-R. This model generates synthetic target data for accent conversion training.
What happens:
components/text_to_mel/experiments/bash run.sh --stage 3 --stop_stage 3
Trains the token-to-Mel synthesizer (Yirga) on LibriTTS-R using HuBERT tokens.
What happens:
components/token_to_mel/experiments/bash run.sh --stage 4 --stop_stage 4
Pre-trains the accent conversion model on LibriTTS-R using self-supervised objectives.
What happens:
components/token_to_token/data/libritts/components/token_to_token/experiments/libritts_pretrain/# Specify text-to-Mel checkpoint before running
bash run.sh --stage 5 --stop_stage 5 --text_to_mel_ckpt /path/to/matcha/checkpoint.ckpt
Fine-tunes the accent conversion model on L2ARCTIC for accent-specific adaptation.
What happens:
components/token_to_token/data/l2arctic/synthetic_target/components/token_to_token/data/l2arctic/accent_embeddings/components/token_to_token/data/l2arctic/components/token_to_token/experiments/l2arctic_finetune/# Specify both checkpoints before running
bash run.sh --stage 6 --stop_stage 6 \
--token_to_token_ckpt /path/to/t2t/checkpoint.pt \
--token_to_mel_ckpt /path/to/t2m/checkpoint.ckpt
Generates accent-converted speech on the test set.
What happens:
experiments/l2arctic_finetune/test_output/bash run.sh --stage 7 --stop_stage 7
Evaluates the generated speech using multiple metrics.
What happens:
experiments/l2arctic_finetune/test_output/You can specify custom checkpoint paths:
bash run.sh --stage [STAGE] --stop_stage [STAGE] \
--text_to_mel_ckpt /path/to/matcha.ckpt \
--token_to_token_ckpt /path/to/t2t_model.pt \
--token_to_mel_ckpt /path/to/t2m_model.ckpt
components/*/configs/--nj parameterAfter data preprocessing is complete, you can comment out the preprocessing sections in run.sh to avoid repeated computation.
Download pre-trained models to skip training stages:
python tokan/utils/model_utils.py
Models will be downloaded to pretrained_models/. You can use these directly in your pipeline as long as the k-means model is consistent.
To accelerate training or skip certain stages, you can download our pre-trained models:
python tokan/utils/model_utils.py
This will download models to the pretrained_models/ directory with the following structure:
pretrained_models/
βββ hubert_km/
β βββ hubert_km_libritts_l17_1000.pt # K-means model
βββ token_to_mel/
β βββ tokan-t2m-v1-paper/ # Token-to-Mel model with regression duration predictor
β β β model.ckpt
β βββ tokan-t2m-v2-paper/ # Token-to-Mel model with flow-matching duration predictor
β β model.ckpt
βββ token_to_token/
βββ tokan-t2t-base-paper/ # Token-to-token model
ββ model.pt # Fairseq checkpoint
ββ dict.src.txt # Input token dictionary
ββ dict.tgt.txt # Input token dictionary
ββ dict.aux.txt # Intermediate phone dictionary
Using Pre-trained Models:
You can reference these models in your training pipeline. Update the paths in run.sh:
# Use pre-trained k-means model
km_path=$(pwd)/pretrained_models/hubert_km/hubert_km_libritts_l17_1000.pt
# Use pre-trained token-to-Mel model
token_to_mel_ckpt=$(pwd)/pretrained_models/token_to_mel/tokan-t2m-v2-paper/model.ckpt
# Use pre-trained token-to-token model
token_to_token_ckpt=$(pwd)/pretrained_models/token_to_token/tokan-t2t-base-paper/model.pt
β οΈ Important: Ensure k-means model consistency across all components. All models should use the same HuBERT layer (17) and cluster count (1000) for compatibility.
Hardware Requirements:
components/*/configs/ or in fairseq-train arguments if using different hardwareNotes on Paper's Implementation:
π‘ Note: These implementation choices may affect training dynamics and final model performance, but the impact should be small. The current codebase discards these practices for cleaness and clarity.
This work was conducted at Tencent TEA-Lab.
This project leverages several excellent open-source projects:
We express our gratitude to the authors and contributors of these projects for making their work available to the community.
For detailed information about our modifications to these codebases, please see the Notes.
If you find our work useful in your research, please cite our paper:
@inproceedings{bai2025accent,
title={Accent Normalization Using Self-Supervised Discrete Tokens with Non-Parallel Data},
author={Bai, Qibing and Inoue, Sho and Wang, Shuai and Jiang, Zhongjie and Wang, Yannan and Li, Haizhou},
booktitle={Proceedings of Interspeech},
year={2025}
}
[!IMPORTANT] This is the legacy repository for the Interspeech 2025 conference paper. An extended version with a cleaner, updated implementation is now available at P1ping/TokAN β please head there for the latest code and models.
This repository contains the official implementation and pretrained models for the Interspeech 2025 paper: "Accent Normalization Using Self-Supervised Discrete Tokens with Non-Parallel Data".
We strongly recommend using a conda or venv virtual environment with Python 3.8+.
First, clone the repository, making sure to initialize the fairseq submodule.
git clone --recurse-submodules https://github.com/P1ping/TokAN-Legacy.git
cd TokAN-Legacy
If you forgot the --recurse-submodules flag, run git submodule update --init --recursive after cloning.
Then, create and activate your virtual environment:
# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
# Or you can create a new environment via conda
For successful load of fairseq models, we recommend torch<=2.5.1.
For other CUDA versions or CPU-only installation of PyTorch, please visit the official PyTorch website for the correct command.
Install eSpeak (required for training):
# On Ubuntu/Debian
sudo apt-get install espeak espeak-data
# On other systems, visit: http://espeak.sourceforge.net/
# Please ensure the output version is latest (1.48)
espeak --version
Note: eSpeak (version 1.48) is required if you plan to run the training pipeline, as it's used for phoneme processing in the text-to-speech components.
The token-to-token component of TokAN requires the fairseq toolkit, which is included in the third_party directory.
This should be installed before the the main project. Fairseq requires a lower version of hydra-core, which should be upgraded during installation of the main project.
π‘ Tip: You probably need
pip<=24.0andgcc 9 or laterfor successful fairseq installation.
# Navigate to the submodule directory
cd third_party/fairseq
# Install this specific version of fairseq in editable mode
pip install -e .
# Return to the project root directory
cd ../..
Now that the critical dependencies are in place, you can install the remaining packages from requirements.txt and then install the TokAN source code itself.
# Install all other required packages
pip install -r requirements.txt
# Install the project's core source code in editable mode
pip install -e .
After these steps, the environment is fully configured to run inference.
python inference.py --input_path /path/to/input.wav --output_path /path/to/output.wav --download_models
This will automatically download all required models and perform accent conversion on your audio file. Specifically, it will split the input audio (when it is long) into chunks and convert them one by one. The chunking is based on silero_vad, please check the arguments for detailed configurations. When --preserve_duration is given, the script will select the model with flow-matching-based duration prediction for total duration preservation.
β οΈ Note: If the download is interrupted, please delete the partially downloaded file so that it can be downloaded again.
TokAN requires two main datasets for training:
LibriTTS-R is used for training the text-to-speech components and token-to-token pre-training. The dataset should be organized as follows:
LibriTTS_R/
βββ train-clean-100/
βββ train-clean-360/
βββ train-other-500/
βββ dev-clean/
βββ dev-other/
βββ test-clean/
βββ test-other/
Download Instructions:
libritts_root path in run.shL2ARCTIC contains non-native English speech, while ARCTIC provides native English speakers for comparison. The combined dataset should include:
L2ARCTIC Speakers (by accent):
<ar>): ABA, YBAA, ZHAA, SKA<zh>): BWC, LXC, NCC, TXHC<hi>): ASI, RRBI, SVBI, TNI<ko>): HJK, YDCK, YKWK, HKK<es>): EBVS, ERMS, NJS, MBMPS<vi>): HQTV, PNV, THV, TLVARCTIC Native Speakers (<us>): BDL, RMS, SLT, CLB
Expected Directory Structure:
l2arctic/
β # L2ARCTIC speakers (direct extraction)
βββ YBAA/
βββ BWC/
βββ ...
β # ARCTIC native speakers
βββ BDL/
βββ RMS/
βββ SLT/
βββ CLB/
Download Instructions:
For L2ARCTIC:
For ARCTIC Native Speakers:
cmu_us_bdl_arctic.tar.bz2, cmu_us_rms_arctic.tar.bz2, cmu_us_slt_arctic.tar.bz2, cmu_us_clb_arctic.tar.bz2Before training, verify your datasets are properly prepared:
# Verify both datasets
bash run.sh --stage 0 --stop_stage 0
# Or run the verification script directly
python scripts/verify_data_preparation.py --libritts_root /path/to/LibriTTS_R --l2arctic_root /path/to/l2arctic
The verification script will:
TokAN training consists of multiple stages that build upon each other. We recommend running stages sequentially using bash run.sh --stage [STAGE] --stop_stage [STAGE].
bash run.sh --stage 0 --stop_stage 0
Validates that all required datasets are properly prepared and accessible.
bash run.sh --stage 1 --stop_stage 1
Checks for pre-trained HuBERT and k-means models required for speech tokenization. We recommend specify the related paths directly in the script. If you use HuBERT other than hubert_large_ll60k or our pre-trained K-means model, please also update hubert_path, hubert_layer, and n_clusters correspondingly.
Options:
### Pre-trained Models section belowthird_party/fairseq/examples/hubert/simple_kmeans/README.mdπ‘ Note: K-means clustering is storage-intensive. We recommend using the one we provide, which was clustered on LibriTTS-R. If you have changed the number of clusters, please also update n_vocab in components/token_to_mel/configs/model/yirga.yaml
bash run.sh --stage 2 --stop_stage 2
Trains the text-to-speech model on LibriTTS-R. This model generates synthetic target data for accent conversion training.
What happens:
components/text_to_mel/experiments/bash run.sh --stage 3 --stop_stage 3
Trains the token-to-Mel synthesizer (Yirga) on LibriTTS-R using HuBERT tokens.
What happens:
components/token_to_mel/experiments/bash run.sh --stage 4 --stop_stage 4
Pre-trains the accent conversion model on LibriTTS-R using self-supervised objectives.
What happens:
components/token_to_token/data/libritts/components/token_to_token/experiments/libritts_pretrain/# Specify text-to-Mel checkpoint before running
bash run.sh --stage 5 --stop_stage 5 --text_to_mel_ckpt /path/to/matcha/checkpoint.ckpt
Fine-tunes the accent conversion model on L2ARCTIC for accent-specific adaptation.
What happens:
components/token_to_token/data/l2arctic/synthetic_target/components/token_to_token/data/l2arctic/accent_embeddings/components/token_to_token/data/l2arctic/components/token_to_token/experiments/l2arctic_finetune/# Specify both checkpoints before running
bash run.sh --stage 6 --stop_stage 6 \
--token_to_token_ckpt /path/to/t2t/checkpoint.pt \
--token_to_mel_ckpt /path/to/t2m/checkpoint.ckpt
Generates accent-converted speech on the test set.
What happens:
experiments/l2arctic_finetune/test_output/bash run.sh --stage 7 --stop_stage 7
Evaluates the generated speech using multiple metrics.
What happens:
experiments/l2arctic_finetune/test_output/You can specify custom checkpoint paths:
bash run.sh --stage [STAGE] --stop_stage [STAGE] \
--text_to_mel_ckpt /path/to/matcha.ckpt \
--token_to_token_ckpt /path/to/t2t_model.pt \
--token_to_mel_ckpt /path/to/t2m_model.ckpt
components/*/configs/--nj parameterAfter data preprocessing is complete, you can comment out the preprocessing sections in run.sh to avoid repeated computation.
Download pre-trained models to skip training stages:
python tokan/utils/model_utils.py
Models will be downloaded to pretrained_models/. You can use these directly in your pipeline as long as the k-means model is consistent.
To accelerate training or skip certain stages, you can download our pre-trained models:
python tokan/utils/model_utils.py
This will download models to the pretrained_models/ directory with the following structure:
pretrained_models/
βββ hubert_km/
β βββ hubert_km_libritts_l17_1000.pt # K-means model
βββ token_to_mel/
β βββ tokan-t2m-v1-paper/ # Token-to-Mel model with regression duration predictor
β β β model.ckpt
β βββ tokan-t2m-v2-paper/ # Token-to-Mel model with flow-matching duration predictor
β β model.ckpt
βββ token_to_token/
βββ tokan-t2t-base-paper/ # Token-to-token model
ββ model.pt # Fairseq checkpoint
ββ dict.src.txt # Input token dictionary
ββ dict.tgt.txt # Input token dictionary
ββ dict.aux.txt # Intermediate phone dictionary
Using Pre-trained Models:
You can reference these models in your training pipeline. Update the paths in run.sh:
# Use pre-trained k-means model
km_path=$(pwd)/pretrained_models/hubert_km/hubert_km_libritts_l17_1000.pt
# Use pre-trained token-to-Mel model
token_to_mel_ckpt=$(pwd)/pretrained_models/token_to_mel/tokan-t2m-v2-paper/model.ckpt
# Use pre-trained token-to-token model
token_to_token_ckpt=$(pwd)/pretrained_models/token_to_token/tokan-t2t-base-paper/model.pt
β οΈ Important: Ensure k-means model consistency across all components. All models should use the same HuBERT layer (17) and cluster count (1000) for compatibility.
Hardware Requirements:
components/*/configs/ or in fairseq-train arguments if using different hardwareNotes on Paper's Implementation:
π‘ Note: These implementation choices may affect training dynamics and final model performance, but the impact should be small. The current codebase discards these practices for cleaness and clarity.
This work was conducted at Tencent TEA-Lab.
This project leverages several excellent open-source projects:
We express our gratitude to the authors and contributors of these projects for making their work available to the community.
For detailed information about our modifications to these codebases, please see the Notes.
If you find our work useful in your research, please cite our paper:
@inproceedings{bai2025accent,
title={Accent Normalization Using Self-Supervised Discrete Tokens with Non-Parallel Data},
author={Bai, Qibing and Inoue, Sho and Wang, Shuai and Jiang, Zhongjie and Wang, Yannan and Li, Haizhou},
booktitle={Proceedings of Interspeech},
year={2025}
}