ilyassmoummad
commited on
Commit
•
2749826
1
Parent(s):
bedbb17
device argument for using gpu
Browse files- melspectrogram.py +2 -2
melspectrogram.py
CHANGED
@@ -28,13 +28,13 @@ class Standardization(torch.nn.Module):
|
|
28 |
return (x - self.mean) / self.std
|
29 |
|
30 |
class MelSpectrogramProcessor:
|
31 |
-
def __init__(self, sample_rate=SR, n_mels=NMELS, n_fft=NFFT, hop_length=HOPLEN, f_min=FMIN, f_max=FMAX):
|
32 |
self.transform = nn.Sequential(
|
33 |
T.MelSpectrogram(sample_rate=sample_rate, n_mels=n_mels, n_fft=n_fft, hop_length=hop_length, f_min=f_min, f_max=f_max),
|
34 |
T.AmplitudeToDB(),
|
35 |
Normalization(),
|
36 |
Standardization(mean=MEAN, std=STD),
|
37 |
-
)
|
38 |
|
39 |
def process(self, waveform):
|
40 |
return self.transform(waveform)
|
|
|
28 |
return (x - self.mean) / self.std
|
29 |
|
30 |
class MelSpectrogramProcessor:
|
31 |
+
def __init__(self, sample_rate=SR, n_mels=NMELS, n_fft=NFFT, hop_length=HOPLEN, f_min=FMIN, f_max=FMAX, device='cpu'):
|
32 |
self.transform = nn.Sequential(
|
33 |
T.MelSpectrogram(sample_rate=sample_rate, n_mels=n_mels, n_fft=n_fft, hop_length=hop_length, f_min=f_min, f_max=f_max),
|
34 |
T.AmplitudeToDB(),
|
35 |
Normalization(),
|
36 |
Standardization(mean=MEAN, std=STD),
|
37 |
+
).to(device)
|
38 |
|
39 |
def process(self, waveform):
|
40 |
return self.transform(waveform)
|