Al Lot
This commit is contained in:
@ -76,9 +76,9 @@ class NormalizeMelband(object):
|
||||
|
||||
|
||||
class AudioToMel(object):
|
||||
def __init__(self, amplitude_to_db=False, power_to_db=False, **kwargs):
|
||||
def __init__(self, amplitude_to_db=False, power_to_db=False, **mel_kwargs):
|
||||
assert not all([amplitude_to_db, power_to_db]), "Choose amplitude_to_db or power_to_db, not both!"
|
||||
self.mel_kwargs = kwargs
|
||||
self.mel_kwargs = mel_kwargs
|
||||
self.amplitude_to_db = amplitude_to_db
|
||||
self.power_to_db = power_to_db
|
||||
|
||||
|
@ -59,9 +59,9 @@ class ShiftTime(object):
|
||||
# Set to silence for heading/ tailing
|
||||
shift = int(shift)
|
||||
if shift > 0:
|
||||
augmented_data[:, :shift] = 0
|
||||
augmented_data[:shift, :] = 0
|
||||
else:
|
||||
augmented_data[:, shift:] = 0
|
||||
augmented_data[shift:, :] = 0
|
||||
return augmented_data
|
||||
else:
|
||||
return x
|
||||
|
21
audio_toolset/mel_transforms.py
Normal file
21
audio_toolset/mel_transforms.py
Normal file
@ -0,0 +1,21 @@
|
||||
from typing import Union
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Normalize(object):
|
||||
|
||||
def __init__(self, min_db_level: Union[int, float]):
|
||||
self.min_db_level = min_db_level
|
||||
|
||||
def __call__(self, s: np.ndarray) -> np.ndarray:
|
||||
return np.clip((s - self.min_db_level) / -self.min_db_level, 0, 1)
|
||||
|
||||
|
||||
class DeNormalize(object):
|
||||
|
||||
def __init__(self, min_db_level: Union[int, float]):
|
||||
self.min_db_level = min_db_level
|
||||
|
||||
def __call__(self, s: np.ndarray) -> np.ndarray:
|
||||
return (np.clip(s, 0, 1) * -self.min_db_level) + self.min_db_level
|
Reference in New Issue
Block a user