Skip to content

Commit

Permalink
Integrate padding for eval.
Browse files Browse the repository at this point in the history
  • Loading branch information
breizhn authored Apr 26, 2022
1 parent 0d4f81d commit 1de1f15
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions run_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ def process_file(model, audio_file_name, out_file_name):

# read audio file with librosa to handle resampling and enforce mono
in_data,fs = librosa.core.load(audio_file_name, sr=16000, mono=True)
# get length of file
len_orig = len(in_data)
# pad audio
zero_pad = np.zeros(384)
in_data = np.concatenate((zero_pad, in_data, zero_pad), axis=0)
# predict audio with the model
predicted = model.predict_on_batch(
np.expand_dims(in_data,axis=0).astype(np.float32))
# squeeze the batch dimension away
predicted_speech = np.squeeze(predicted)
predicted_speech = predicted_speech[384:384+len_orig]
# write the file to target destination
sf.write(out_file_name, predicted_speech,fs)

Expand Down

0 comments on commit 1de1f15

Please sign in to comment.