diff --git a/.vs/acoustic_model/v15/.suo b/.vs/acoustic_model/v15/.suo index d178133..a64dccd 100644 Binary files a/.vs/acoustic_model/v15/.suo and b/.vs/acoustic_model/v15/.suo differ diff --git a/acoustic_model.sln b/acoustic_model.sln index 7d8fcbe..406d9e5 100644 --- a/acoustic_model.sln +++ b/acoustic_model.sln @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\forced_alignment\forced_alignment\pronunciations.py = ..\forced_alignment\forced_alignment\pronunciations.py ..\toolbox\pyHTK.py = ..\toolbox\pyHTK.py ..\forced_alignment\forced_alignment\pyhtk.py = ..\forced_alignment\forced_alignment\pyhtk.py + reus-test\reus-test.py = reus-test\reus-test.py ..\forced_alignment\forced_alignment\scripts.py = ..\forced_alignment\forced_alignment\scripts.py ..\..\..\..\..\Python36-32\Lib\site-packages\novoapi\backend\session.py = ..\..\..\..\..\Python36-32\Lib\site-packages\novoapi\backend\session.py ..\forced_alignment\forced_alignment\tempfilename.py = ..\forced_alignment\forced_alignment\tempfilename.py diff --git a/acoustic_model/__pycache__/defaultfiles.cpython-36.pyc b/acoustic_model/__pycache__/defaultfiles.cpython-36.pyc index afdf53b..ef367cd 100644 Binary files a/acoustic_model/__pycache__/defaultfiles.cpython-36.pyc and b/acoustic_model/__pycache__/defaultfiles.cpython-36.pyc differ diff --git a/acoustic_model/acoustic_model.pyproj b/acoustic_model/acoustic_model.pyproj index ec61c44..17163f2 100644 --- a/acoustic_model/acoustic_model.pyproj +++ b/acoustic_model/acoustic_model.pyproj @@ -4,8 +4,7 @@ 2.0 4d8c8573-32f0-4a62-9e62-3ce5cc680390 . - - + forced_aligner_comparison.py . diff --git a/acoustic_model/acoustic_model_functions.py b/acoustic_model/acoustic_model_function.py similarity index 100% rename from acoustic_model/acoustic_model_functions.py rename to acoustic_model/acoustic_model_function.py diff --git a/acoustic_model/defaultfiles.py b/acoustic_model/defaultfiles.py index 42ba4e1..f53100f 100644 --- a/acoustic_model/defaultfiles.py +++ b/acoustic_model/defaultfiles.py @@ -31,6 +31,12 @@ ipa_xsampa_converter_dir = os.path.join(repo_dir, 'ipa-xsama-converter') forced_alignment_module_dir = os.path.join(repo_dir, 'forced_alignment') accent_classification_dir = os.path.join(repo_dir, 'accent_classification', 'accent_classification') +htk_config_dir = r'c:\Users\Aki\source\repos\forced_alignment\forced_alignment\data\htk\preset_models\aki_dutch_2017' +config_hvite = os.path.join(htk_config_dir, 'config.HVite') +#acoustic_model = os.path.join(htk_config_dir, 'hmmdefs.compo') +acoustic_model = r'c:\cygwin64\home\Aki\acoustic_model\model\barbara\hmm128-2\hmmdefs.compo' +phonelist_txt = os.path.join(htk_config_dir, 'phonelist.txt') + WSL_dir = r'C:\OneDrive\WSL' fame_dir = os.path.join(WSL_dir, 'kaldi-trunk', 'egs', 'fame') fame_s5_dir = os.path.join(fame_dir, 's5') diff --git a/acoustic_model/forced_aligner_comparison.py b/acoustic_model/forced_aligner_comparison.py index 9243f95..d9d34a4 100644 --- a/acoustic_model/forced_aligner_comparison.py +++ b/acoustic_model/forced_aligner_comparison.py @@ -1,10 +1,42 @@ import os os.chdir(r'C:\Users\Aki\source\repos\acoustic_model\acoustic_model') +import sys import defaultfiles as default +sys.path.append(default.forced_alignment_module_dir) +from forced_alignment import pyhtk, convert_phone_set, scripts -wav_dir = r'c:\Users\Aki\source\repos\acoustic_model\reus-test' +reus_dir = r'c:\Users\Aki\source\repos\acoustic_model\reus-test' +wav_dir = reus_dir wav_files = ['reus1008-reus.wav', 'reus1167-man.wav', 'reus3768-mantsje.wav'] +word = 'reus' +pronunciation_ipa = ['rø:s', 'mɑn', 'mɑntsjə'] + +for wav_file in wav_files: + file_lab = os.path.join(reus_dir, wav_file.replace('.wav', '.lab')) + file_dic = os.path.join(reus_dir, wav_file.replace('.wav', '.dic')) + file_txt = os.path.join(reus_dir, wav_file.replace('.wav', '.txt')) + + # output htk dict file + with open(file_dic, 'w', encoding="utf-8") as f: + for ipa in pronunciation_ipa: + cgn = convert_phone_set.ipa2cgn([ipa.replace(':', 'ː')]) + barbara = convert_phone_set.cgn2barbara(cgn) + f.write(word.upper() + '\t' + barbara + '\n') + + # output htk label file. + pyhtk._create_label_file(word, file_lab) + + scripts.run_command([ + 'HVite','-T', '1', + '-a', + '-C', default.config_hvite, + '-H', default.acoustic_model, + '-m', + '-i', file_txt, + #'-S', script_file, + file_dic, default.phonelist_txt, os.path.join(wav_dir, wav_file) + ]) \ No newline at end of file diff --git a/acoustic_model/acoustic_model.py b/acoustic_model/train_hmm_fame.py similarity index 100% rename from acoustic_model/acoustic_model.py rename to acoustic_model/train_hmm_fame.py diff --git a/reus-test/reus1008-reus.dic b/reus-test/reus1008-reus.dic new file mode 100644 index 0000000..4d22a33 --- /dev/null +++ b/reus-test/reus1008-reus.dic @@ -0,0 +1,3 @@ +REUS r eu s +REUS m ac n +REUS m ac n t s j @ diff --git a/reus-test/reus1008-reus.lab b/reus-test/reus1008-reus.lab new file mode 100644 index 0000000..0475f18 --- /dev/null +++ b/reus-test/reus1008-reus.lab @@ -0,0 +1 @@ +REUS diff --git a/reus-test/reus1008-reus.txt b/reus-test/reus1008-reus.txt new file mode 100644 index 0000000..9726c94 --- /dev/null +++ b/reus-test/reus1008-reus.txt @@ -0,0 +1,6 @@ +#!MLF!# +"c:/Users/Aki/source/repos/acoustic_model/reus-test/reus1008-reus.rec" +0 9700000 r -12463.852539 REUS +9700000 12800000 eu -3622.108887 +12800000 26250001 s -17303.216797 +. diff --git a/reus-test/reus1167-man.dic b/reus-test/reus1167-man.dic new file mode 100644 index 0000000..4d22a33 --- /dev/null +++ b/reus-test/reus1167-man.dic @@ -0,0 +1,3 @@ +REUS r eu s +REUS m ac n +REUS m ac n t s j @ diff --git a/reus-test/reus1167-man.lab b/reus-test/reus1167-man.lab new file mode 100644 index 0000000..0475f18 --- /dev/null +++ b/reus-test/reus1167-man.lab @@ -0,0 +1 @@ +REUS diff --git a/reus-test/reus1167-man.txt b/reus-test/reus1167-man.txt new file mode 100644 index 0000000..06ad7b8 --- /dev/null +++ b/reus-test/reus1167-man.txt @@ -0,0 +1,10 @@ +#!MLF!# +"c:/Users/Aki/source/repos/acoustic_model/reus-test/reus1167-man.rec" +0 150000 m -230.057571 REUS +150000 300000 ac -250.994858 +300000 450000 n -202.377716 +450000 4600000 t -5128.984375 +4600000 5050000 s -711.338501 +5050000 5450000 j -564.730591 +5450000 16049999 @ -13249.787109 +. diff --git a/reus-test/reus3768-mantsje.dic b/reus-test/reus3768-mantsje.dic new file mode 100644 index 0000000..4d22a33 --- /dev/null +++ b/reus-test/reus3768-mantsje.dic @@ -0,0 +1,3 @@ +REUS r eu s +REUS m ac n +REUS m ac n t s j @ diff --git a/reus-test/reus3768-mantsje.lab b/reus-test/reus3768-mantsje.lab new file mode 100644 index 0000000..0475f18 --- /dev/null +++ b/reus-test/reus3768-mantsje.lab @@ -0,0 +1 @@ +REUS diff --git a/reus-test/reus3768-mantsje.txt b/reus-test/reus3768-mantsje.txt new file mode 100644 index 0000000..8e2bc08 --- /dev/null +++ b/reus-test/reus3768-mantsje.txt @@ -0,0 +1,10 @@ +#!MLF!# +"c:/Users/Aki/source/repos/acoustic_model/reus-test/reus3768-mantsje.rec" +0 150000 m -217.347229 REUS +150000 1150000 ac -1266.293579 +1150000 1650000 n -583.382568 +1650000 11100000 t -11259.270508 +11100000 11250000 s -247.939255 +11250000 11550000 j -445.511444 +11550000 24150000 @ -16769.048828 +.