Commit 4ea9f847 authored by Quentin Aristote's avatar Quentin Aristote
Browse files

corrected resize

parent bda2368d
......@@ -26,10 +26,10 @@ def soundToSpectrogram(path, sample_rate = 16000, duration = 30) :
waveform = resample(waveform)
# Extract a certain duration
try :
waveform = waveform[:, :duration * sample_rate]
except :
raise TypeError('the recording is too long or too short')
nb_frames = duration * sample_rate
waveform = waveform[:, :nb_frames]
nb_frames_missing = nb_frames - waveform.size()[1]
waveform = torch.cat([waveform, torch.zeros((2, nb_frames_missing))], dim = 1)
# Compute the Mel-spectrogram
melspectrogram = transforms.MelSpectrogram(sample_rate = sample_rate)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment