O'Reilly logo

Hands-On Natural Language Processing with Python by Rajalingappaa Shanmugamani, Rajesh Arumugam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

LSTM model for spoken digit recognition

For this example, we will use the tflearn package for simplicity. The tflearn package can be installed using the following command:

pip install tflearn

We will define the function to read the .wav files and prepare it for batch training:

def get_batch_mfcc(fpath,batch_size=256):    ft_batch = []    labels_batch = []    files = os.listdir(fpath)    while True:        print("Total %d files" % len(files))        random.shuffle(files)        for fname in files:            if not fname.endswith(".wav"):                 continue    mfcc_features = get_mfcc_features(fpath+fname)     label = np.eye(10)[int(fname[0])]    labels_batch.append(label)    ft_batch.append(mfcc_features)    if len(ft_batch) >= batch_size:        yield ft_batch, labels_batch     ft_batch = []     labels_batch = []

In ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required