Commit d703ce95 authored by Quentin Aristote's avatar Quentin Aristote
Browse files

corrected bugs

parent ea684b44
......@@ -31,17 +31,14 @@ def soundToSpectrogram(path, sample_rate = 16000, duration = 30, nb_mels = 128)
nb_frames = duration * sample_rate
spectrograms = []
melspectrogram_of = transforms.MelSpectrogram(sample_rate = sample_rate)
get_melspectrogram = transforms.MelSpectrogram(sample_rate = sample_rate,
n_mels = nb_mels)
while waveform.size()[1] > 0 :
sample = waveform[:nb_frames]
waveform = waveform[nb_frames:]
spectrogram = melspectrogram_of(sample)
spectorgrams.append(samples)
nb_frames_missing = nb_frames - sample.size()[0]
if nb_frames_missing > 0 :
spectrograms.pop()
while waveform.size()[1] >= nb_frames :
sample = waveform[:,:nb_frames]
waveform = waveform[:,nb_frames:]
spectrogram = get_melspectrogram(sample)
spectrograms.append(spectrogram)
return spectrograms
......@@ -68,7 +65,7 @@ def getSpectrograms(dir_source, dir_target,
path_source = os.path.join(dir_source, filename)
path_target = os.path.join(dir_target, title + '-{part}.pt')
print('Computing the Mel-spectrogram of {filename} ...'.format(filename = filename))
print('Computing Mel-spectrograms for {filename} ...'.format(filename = filename))
if (overwrite or not(os.path.isfile(path_target))) and not(title in to_ignore) :
try :
spectrograms = soundToSpectrogram(path_source,
......
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