Let's see how to build a speech recognizer:
- Create a new Python file and import the following packages (the full code is in the speech_recognizer.py file that's already provided for you):
import os import argparse import numpy as np from scipy.io import wavfile from hmmlearn import hmm from python_speech_features import mfcc
- Define a function to parse the input arguments in the command line:
# Function to parse input arguments def build_arg_parser(): parser = argparse.ArgumentParser(description='Trains the HMM classifier') parser.add_argument("--input-folder", dest="input_folder", required=True, help="Input folder containing the audio files in subfolders") return parser
- Let's use the HMMTrainer class defined in the previous ...