This Python script crawls a directory, finds subfolders containing .lab files, and validates the phonemes within them based on a language tag in the folder's name. This script uses all the phoneme sets included in the NeoDIVA DiffSinger model, but should be applicable to most datasets.
It checks for:
- Typos: Phonemes not found in the global list or the specified language's phoneme set. (AP, SP, vf, q, cl, ctrash, vtrash and trash)
- Suggestions:
pau(suggestsSP) andbr(suggestsAP). - Tagged Phonemes: Validates phonemes with language tags (e.g.,
ja/a).
The script recognizes folder names ending in the following language tags (case-insensitive):
_enEnglish (Arpasing+ Phoneme Set)_esSpanish (Namine Criss Phoneme Set)_frFrench (Millefeuille Phoneme Set)_itItalian (Gianloop Phoneme Set)_jaJapanese (Standard Phoneme Set)_kaGeorgian (Datawave Phoneme Set)_koKorean (Team CODA Phoneme Set)_plPolish (PixPrucer Phoneme Set)_ptPortuguese (Brazillian, Team BRAPA Phoneme Set)_roRomanian (NeoDIVA Phoneme Set)_ruRussian (Lunai Phoneme Set)_thThai (PrintMOV Phoneme Set)_zhChinese (TGM Phoneme Set)_hyArmenian (amihopeutau Phoneme Set)
Save the Python file anywhere on your computer, ideally in documents in it's own folder for organization.
This is the most important step. The script is designed to find language codes in your folder names.
- A folder's name must end with an underscore (
_) followed by one of the two-letter language codes listed above (e.g.,_en,_es,_ja). - The script will skip any folder that does not match this format.
C:\My_Data\Speaker_01_en
C:\My_Data\Recordings_fr
C:\My_Data\Section_4\Speaker_10_ko
C:\My_Data\English_Files(The script will skip this folder because it has no language tag).C:\My_Data\Speaker_pt_files(The script will skip this because the_pttag is not at the very end of the folder name).
All your .lab files should be placed directly inside these language-tagged folders.
-
Open your terminal (like Command Prompt, PowerShell, or Windows Terminal).
-
Use the
cdcommand to move to the folder where you saved thecheck_phonemes.pyfile.# Example: cd C:\Users\Example\Documents\LabelChecker
-
Once you are in the correct folder, run the script:
python check_phonemes.py
(You may need to use
pyinstead ofpythondepending on your setup).
- The script will ask you:
Please enter the path to the root folder to scan: - This is the main folder that contains all your language-tagged folders (like
C:\My_Datafrom the example above). - Copy the full path to this root folder, paste it into the terminal, and press Enter.
The script will scan all the subfolders.
- When it is finished, look inside your root folder (the path you just gave the script).
- For every language-tagged folder it processed (e.g.,
Speaker_01_en), it will create a new log file in that root directory (e.g.,Speaker_01_en_errors.log). - Open these
.logfiles to see the results.- If any typos, suggestions (
pau/br), or malformed lines were found, they will be listed with the file name and line number. - If a folder's labels were all correct, its log file will simply say "No errors found."
- If any typos, suggestions (