Audio Dataset
This commit is contained in:
@ -37,6 +37,9 @@ class MFCC(object):
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update(kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}({self.__dict__})'
|
||||
|
||||
def __call__(self, y):
|
||||
mfcc = librosa.feature.mfcc(y, **self.__dict__)
|
||||
return mfcc
|
||||
@ -47,6 +50,9 @@ class NormalizeLocal(object):
|
||||
self.cache: np.ndarray
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}({self.__dict__})'
|
||||
|
||||
def __call__(self, x: np.ndarray):
|
||||
mean = x.mean()
|
||||
std = x.std() + 0.0001
|
||||
@ -65,6 +71,9 @@ class NormalizeMelband(object):
|
||||
self.cache: np.ndarray
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}({self.__dict__})'
|
||||
|
||||
def __call__(self, x: np.ndarray):
|
||||
mean = x.mean(-1).unsqueeze(-1)
|
||||
std = x.std(-1).unsqueeze(-1)
|
||||
@ -98,6 +107,9 @@ class PowerToDB(object):
|
||||
def __init__(self, running_max=False):
|
||||
self.running_max = 0 if running_max else None
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}({self.__dict__})'
|
||||
|
||||
def __call__(self, x):
|
||||
if self.running_max is not None:
|
||||
self.running_max = max(np.max(x), self.running_max)
|
||||
@ -109,6 +121,9 @@ class LowPass(object):
|
||||
def __init__(self, sr=16000):
|
||||
self.sr = sr
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}({self.__dict__})'
|
||||
|
||||
def __call__(self, x):
|
||||
return butter_lowpass_filter(x, 1000, 1)
|
||||
|
||||
@ -117,6 +132,9 @@ class MelToImage(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}({self.__dict__})'
|
||||
|
||||
def __call__(self, x):
|
||||
# Source to Solution: https://stackoverflow.com/a/57204349
|
||||
mels = np.log(x + 1e-9) # add small number to avoid log(0)
|
||||
|
Reference in New Issue
Block a user