diff --git a/.vs/acoustic_model/v15/.suo b/.vs/acoustic_model/v15/.suo index f5fd788..08c3df7 100644 Binary files a/.vs/acoustic_model/v15/.suo and b/.vs/acoustic_model/v15/.suo differ diff --git a/acoustic_model/__pycache__/defaultfiles.cpython-36.pyc b/acoustic_model/__pycache__/defaultfiles.cpython-36.pyc index 635aaae..9a6baf3 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/check_novoapi.py b/acoustic_model/check_novoapi.py index 1814a6b..aa6c993 100644 --- a/acoustic_model/check_novoapi.py +++ b/acoustic_model/check_novoapi.py @@ -3,23 +3,27 @@ os.chdir(r'C:\Users\Aki\source\repos\acoustic_model\acoustic_model') import sys import csv -#import subprocess -#from collections import Counter -#import re import numpy as np import pandas as pd -#import matplotlib.pyplot as plt -#from sklearn.metrics import confusion_matrix +import matplotlib.pyplot as plt + +from sklearn.metrics import confusion_matrix +from sklearn.metrics import accuracy_score +import novoapi + +from forced_alignment import pyhtk, convert_phone_set import acoustic_model_functions as am_func import convert_xsampa2ipa import defaultfiles as default - -from forced_alignment import pyhtk, convert_phone_set - -import novoapi import novoapi_functions +sys.path.append(default.accent_classification_dir) +import output_confusion_matrix + +## procedure +forced_alignment_novo70 = True + ## ===== load novo phoneset ===== phoneset_ipa, phoneset_novo70, translation_key_ipa2novo70, translation_key_novo702ipa = novoapi_functions.load_phonset() @@ -145,9 +149,9 @@ for word in word_list: ## ===== forced alignment ===== -if forced_alignment: +if forced_alignment_novo70: Results = pd.DataFrame(index=[], - columns=['filename', 'ipa', 'word', 'result_ipa', 'result_novo70', 'llh']) + columns=['filename', 'word', 'ipa', 'result_ipa', 'result_novo70', 'llh']) for word in word_list: #for word in ['Oor']: # pronunciation variants top 3 @@ -176,7 +180,7 @@ if forced_alignment: samples = df_.query("ipa in @pronunciation_ipa") results = pd.DataFrame(index=[], - columns=['filename', 'ipa', 'word', 'result_ipa', 'result_novo70', 'llh']) + columns=['filename', 'word', 'ipa', 'result_ipa', 'result_novo70', 'llh']) #j = 0 for i in range(0, len(samples)): @@ -205,5 +209,23 @@ if forced_alignment: Results.to_excel(os.path.join(default.stimmen_dir, 'Results.xlsx'), encoding="utf-8") else: Results_xlsx = pd.ExcelFile(os.path.join(default.stimmen_dir, 'Results.xlsx'), encoding="utf-8") - R = pd.read_excel(Results_xlsx, 'Sheet1') + Results = pd.read_excel(Results_xlsx, 'Sheet1') + +## ===== analysis ===== +result_novoapi_dir = os.path.join(default.stimmen_dir, 'result', 'novoapi') +for word in word_list: + if not word == 'Oog': +#word = 'Reus' + + Results_ = Results[Results['word'] == word] + y_true = list(Results_['ipa']) + y_pred_ = [ipa.replace(' ', '') for ipa in list(Results_['result_ipa'])] + y_pred = [ipa.replace('ː', ':') for ipa in y_pred_] + pronunciation_variants = list(set(y_true)) + cm = confusion_matrix(y_true, y_pred, labels=pronunciation_variants) + + plt.figure() + output_confusion_matrix.plot_confusion_matrix(cm, pronunciation_variants, normalize=False) + #plt.show() + plt.savefig(os.path.join(result_novoapi_dir, word + '.png')) \ No newline at end of file diff --git a/acoustic_model/defaultfiles.py b/acoustic_model/defaultfiles.py index e9c4c96..b9ab0ab 100644 --- a/acoustic_model/defaultfiles.py +++ b/acoustic_model/defaultfiles.py @@ -29,6 +29,7 @@ config_hvite = os.path.join(cygwin_dir, 'config', 'config.HVite') repo_dir = r'C:\Users\Aki\source\repos' 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') WSL_dir = r'C:\OneDrive\WSL' fame_dir = os.path.join(WSL_dir, 'kaldi-trunk', 'egs', 'fame')