|
|
|
@ -307,9 +307,6 @@ class IStft():
|
|
|
|
|
center=self.center, )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from paddlespeech.s2t.utils.log import Log
|
|
|
|
|
logger = Log(__name__).getlog()
|
|
|
|
|
|
|
|
|
|
class LogMelSpectrogramKaldi():
|
|
|
|
|
def __init__(
|
|
|
|
|
self,
|
|
|
|
@ -347,22 +344,22 @@ class LogMelSpectrogramKaldi():
|
|
|
|
|
self.dither = dither
|
|
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
|
return ("{name}(fs={fs}, n_mels={n_mels}, n_fft={n_fft}, "
|
|
|
|
|
"n_shift={n_shift}, win_length={win_length}, window={window}, "
|
|
|
|
|
"fmin={fmin}, fmax={fmax}, eps={eps}, preemph={preemph}, window={window}, dither={dither}))".format(
|
|
|
|
|
name=self.__class__.__name__,
|
|
|
|
|
fs=self.fs,
|
|
|
|
|
n_mels=self.n_mels,
|
|
|
|
|
n_fft=self.n_fft,
|
|
|
|
|
n_shift=self.n_shift,
|
|
|
|
|
win_length=self.win_length,
|
|
|
|
|
window=self.window,
|
|
|
|
|
fmin=self.fmin,
|
|
|
|
|
fmax=self.fmax,
|
|
|
|
|
eps=self.eps,
|
|
|
|
|
preemph=self.preemph,
|
|
|
|
|
window=self.window,
|
|
|
|
|
dither=self.dither))
|
|
|
|
|
return (
|
|
|
|
|
"{name}(fs={fs}, n_mels={n_mels}, n_fft={n_fft}, "
|
|
|
|
|
"n_shift={n_shift}, win_length={win_length}, preemph={preemph}, window={window}, "
|
|
|
|
|
"fmin={fmin}, fmax={fmax}, eps={eps}, dither={dither}))".format(
|
|
|
|
|
name=self.__class__.__name__,
|
|
|
|
|
fs=self.fs,
|
|
|
|
|
n_mels=self.n_mels,
|
|
|
|
|
n_fft=self.n_fft,
|
|
|
|
|
n_shift=self.n_shift,
|
|
|
|
|
preemph=self.preemph,
|
|
|
|
|
win_length=self.win_length,
|
|
|
|
|
window=self.window,
|
|
|
|
|
fmin=self.fmin,
|
|
|
|
|
fmax=self.fmax,
|
|
|
|
|
eps=self.eps,
|
|
|
|
|
dither=self.dither, ))
|
|
|
|
|
|
|
|
|
|
def __call__(self, x):
|
|
|
|
|
"""
|
|
|
|
@ -379,12 +376,10 @@ class LogMelSpectrogramKaldi():
|
|
|
|
|
if x.ndim != 1:
|
|
|
|
|
raise ValueError("Not support x: [Time, Channel]")
|
|
|
|
|
|
|
|
|
|
logger.info(f"in {x}")
|
|
|
|
|
if x.dtype in np.sctypes['float']:
|
|
|
|
|
# PCM32 -> PCM16
|
|
|
|
|
bits = np.iinfo(np.int16).bits
|
|
|
|
|
x = x * 2**(bits - 1)
|
|
|
|
|
logger.info(f"b {x}")
|
|
|
|
|
|
|
|
|
|
# logfbank need PCM16 input
|
|
|
|
|
y = logfbank(
|
|
|
|
@ -400,7 +395,4 @@ class LogMelSpectrogramKaldi():
|
|
|
|
|
remove_dc_offset=self.remove_dc_offset,
|
|
|
|
|
preemph=self.preemph,
|
|
|
|
|
wintype=self.window)
|
|
|
|
|
logger.info(f"a {y}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return y
|
|
|
|
|