Skip to content

Instantly share code, notes, and snippets.

@mrubash1
Created March 22, 2017 22:38
Show Gist options
  • Save mrubash1/616d8af4a4388dd5a055fca71a3cd101 to your computer and use it in GitHub Desktop.
Save mrubash1/616d8af4a4388dd5a055fca71a3cd101 to your computer and use it in GitHub Desktop.
# Load wav files
fs, audio = wav.read(audio_filename)
# Get mfcc coefficients
orig_inputs = mfcc(audio, samplerate=fs, numcep=numcep)
# For each time slice of the training set, we need to copy the context this makes
train_inputs = np.array([], np.float32)
train_inputs.resize((orig_inputs.shape[0], numcep + 2 * numcep * numcontext))
for time_slice in range(train_inputs.shape[0]):
# Pick up to numcontext time slices in the past,
# And complete with empty mfcc features
need_empty_past = max(0, ((time_slices[0] + numcontext) - time_slice))
empty_source_past = list(empty_mfcc for empty_slots in range(need_empty_past))
data_source_past = orig_inputs[max(0, time_slice - numcontext):time_slice]
assert(len(empty_source_past) + len(data_source_past) == numcontext)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment