Example: to train en_us arpabet model.
- Place
cmudict-0.7bfile inen_usfolder. - Run commands:
cd py
pip install -r requirements.txt
python g2p/train.py
To train a different model:
- Create a new folder next to
en_us. Place your dictionary in it. - Copies
cfg.yamlinto it and modifies graphemes and phonemes to match your language. The first 4 graphemes and phonemes must be<unk>,<pad>,<bos>,<eos>. - Modify
train.pyto load your config and dictionary. - You may need to reformat your dictionary so that
SphinxDatasetcan load it. Or you can write your own dataset class. - You will need to tweak batch size and epochs (and maybe other parameters) for best results.
A g2p pack zip file contains:
dict.txt
g2p.onnx
phones.txt
- The
G2pPackclass uses entries fromdict.txtfirst. - If not found, it uses
g2p.onnxto generate phonemes. phones.txtallows phonemizers to know which phonemes are vowels and which phonemes to stretch.
For compiling the G2p models read Compiling-G2p-Mdels-Wiki