confusion matrix is output.
This commit is contained in:
parent
05e8a671c1
commit
8efb091715
Binary file not shown.
Binary file not shown.
@ -3,23 +3,27 @@ os.chdir(r'C:\Users\Aki\source\repos\acoustic_model\acoustic_model')
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import csv
|
import csv
|
||||||
#import subprocess
|
|
||||||
#from collections import Counter
|
|
||||||
#import re
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
#import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
#from sklearn.metrics import confusion_matrix
|
|
||||||
|
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 acoustic_model_functions as am_func
|
||||||
import convert_xsampa2ipa
|
import convert_xsampa2ipa
|
||||||
import defaultfiles as default
|
import defaultfiles as default
|
||||||
|
|
||||||
from forced_alignment import pyhtk, convert_phone_set
|
|
||||||
|
|
||||||
import novoapi
|
|
||||||
import novoapi_functions
|
import novoapi_functions
|
||||||
|
sys.path.append(default.accent_classification_dir)
|
||||||
|
import output_confusion_matrix
|
||||||
|
|
||||||
|
## procedure
|
||||||
|
forced_alignment_novo70 = True
|
||||||
|
|
||||||
|
|
||||||
## ===== load novo phoneset =====
|
## ===== load novo phoneset =====
|
||||||
phoneset_ipa, phoneset_novo70, translation_key_ipa2novo70, translation_key_novo702ipa = novoapi_functions.load_phonset()
|
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 =====
|
## ===== forced alignment =====
|
||||||
if forced_alignment:
|
if forced_alignment_novo70:
|
||||||
Results = pd.DataFrame(index=[],
|
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 word_list:
|
||||||
#for word in ['Oor']:
|
#for word in ['Oor']:
|
||||||
# pronunciation variants top 3
|
# pronunciation variants top 3
|
||||||
@ -176,7 +180,7 @@ if forced_alignment:
|
|||||||
samples = df_.query("ipa in @pronunciation_ipa")
|
samples = df_.query("ipa in @pronunciation_ipa")
|
||||||
|
|
||||||
results = pd.DataFrame(index=[],
|
results = pd.DataFrame(index=[],
|
||||||
columns=['filename', 'ipa', 'word', 'result_ipa', 'result_novo70', 'llh'])
|
columns=['filename', 'word', 'ipa', 'result_ipa', 'result_novo70', 'llh'])
|
||||||
|
|
||||||
#j = 0
|
#j = 0
|
||||||
for i in range(0, len(samples)):
|
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")
|
Results.to_excel(os.path.join(default.stimmen_dir, 'Results.xlsx'), encoding="utf-8")
|
||||||
else:
|
else:
|
||||||
Results_xlsx = pd.ExcelFile(os.path.join(default.stimmen_dir, 'Results.xlsx'), encoding="utf-8")
|
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'))
|
@ -29,6 +29,7 @@ config_hvite = os.path.join(cygwin_dir, 'config', 'config.HVite')
|
|||||||
repo_dir = r'C:\Users\Aki\source\repos'
|
repo_dir = r'C:\Users\Aki\source\repos'
|
||||||
ipa_xsampa_converter_dir = os.path.join(repo_dir, 'ipa-xsama-converter')
|
ipa_xsampa_converter_dir = os.path.join(repo_dir, 'ipa-xsama-converter')
|
||||||
forced_alignment_module_dir = os.path.join(repo_dir, 'forced_alignment')
|
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'
|
WSL_dir = r'C:\OneDrive\WSL'
|
||||||
fame_dir = os.path.join(WSL_dir, 'kaldi-trunk', 'egs', 'fame')
|
fame_dir = os.path.join(WSL_dir, 'kaldi-trunk', 'egs', 'fame')
|
||||||
|
Loading…
Reference in New Issue
Block a user