-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
31 lines (20 loc) · 707 Bytes
/
example.py
File metadata and controls
31 lines (20 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import torch
import sonopytorch
def main():
print("SonopyTorch usage sample\n")
audio = torch.rand(20, 16000).float()
print("Power Spectrogram")
spectrogram = sonopytorch.PowerSpectrogram()
spec = spectrogram(audio).data.numpy()
print("SonopyTorch output shape: " + str(spec.shape))
print("\nMel Spectrogram")
fs=16000
mel_spectrogram = sonopytorch.MelSpectrogram(fs)
mels = mel_spectrogram(audio).data.numpy()
print("SonopyTorch output shape: " + str(mels.shape))
print("\nMFCCs")
mfcc = sonopytorch.MFCC(fs)
mfccs = mfcc(audio).data.numpy()
print("SonopyTorch output shape: " + str(mfccs.shape))
if __name__ == '__main__':
main()