Mahiruoshi
commited on
Commit
•
2674c8a
1
Parent(s):
13ab15c
Upload mel_processing.py
Browse files- mel_processing.py +12 -1
mel_processing.py
CHANGED
@@ -1,5 +1,16 @@
|
|
|
|
|
|
|
|
1 |
import torch
|
|
|
|
|
2 |
import torch.utils.data
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from librosa.filters import mel as librosa_mel_fn
|
4 |
|
5 |
MAX_WAV_VALUE = 32768.0
|
@@ -53,7 +64,7 @@ def spectrogram_torch(y, n_fft, sampling_rate, hop_size, win_size, center=False)
|
|
53 |
y = y.squeeze(1)
|
54 |
|
55 |
spec = torch.stft(y, n_fft, hop_length=hop_size, win_length=win_size, window=hann_window[wnsize_dtype_device],
|
56 |
-
center=center, pad_mode='reflect', normalized=False, onesided=True
|
57 |
|
58 |
spec = torch.sqrt(spec.pow(2).sum(-1) + 1e-6)
|
59 |
return spec
|
|
|
1 |
+
import math
|
2 |
+
import os
|
3 |
+
import random
|
4 |
import torch
|
5 |
+
from torch import nn
|
6 |
+
import torch.nn.functional as F
|
7 |
import torch.utils.data
|
8 |
+
import numpy as np
|
9 |
+
import librosa
|
10 |
+
import librosa.util as librosa_util
|
11 |
+
from librosa.util import normalize, pad_center, tiny
|
12 |
+
from scipy.signal import get_window
|
13 |
+
from scipy.io.wavfile import read
|
14 |
from librosa.filters import mel as librosa_mel_fn
|
15 |
|
16 |
MAX_WAV_VALUE = 32768.0
|
|
|
64 |
y = y.squeeze(1)
|
65 |
|
66 |
spec = torch.stft(y, n_fft, hop_length=hop_size, win_length=win_size, window=hann_window[wnsize_dtype_device],
|
67 |
+
center=center, pad_mode='reflect', normalized=False, onesided=True)
|
68 |
|
69 |
spec = torch.sqrt(spec.pow(2).sum(-1) + 1e-6)
|
70 |
return spec
|