def run_tests(test_files):
# Classify input data
for test_file in test_files:
# Read input file
sampling_freq, signal = wavfile.read(test_file)
# Extract MFCC features
with warnings.catch_warnings():
warnings.simplefilter('ignore')
features_mfcc = mfcc(signal, sampling_freq)
# Define variables
max_score = -float('inf')
output_label = None
# Run the current feature vector through all the HMM
# models and pick the one with the highest score
for item in speech_models:
model, label = item
score = model.compute_score(features_mfcc)
if score > max_score:
max_score = score
predicted_label = label
# Print the predicted output
start_index = test_file.find('/') + 1
end_index = test_file.rfind('/')
original_label = test_file[start_index:end_index]
print('\nOriginal: ', original_label)
print('Predicted:', predicted_label)
speech_recognizer.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录