mirror of https://github.com/coqui-ai/TTS.git
fix windows support
This commit is contained in:
parent
a6cd04456e
commit
c125b71f36
|
@ -103,11 +103,10 @@ class AudioProcessor(object):
|
||||||
self.do_sound_norm = do_sound_norm
|
self.do_sound_norm = do_sound_norm
|
||||||
self.stats_path = stats_path
|
self.stats_path = stats_path
|
||||||
# setup exp_func for db to amp conversion
|
# setup exp_func for db to amp conversion
|
||||||
exec(f"self.log_func = {log_func}") # pylint: disable=exec-used
|
if log_func == "np.log":
|
||||||
if self.log_func.__name__ == "log":
|
self.base = np.e
|
||||||
self.exp_func = np.exp
|
elif log_func == "np.log10":
|
||||||
elif self.log_func.__name__ == "log10":
|
self.base = 10
|
||||||
self.exp_func = lambda x: 10 ** x
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(" [!] unknown `log_func` value.")
|
raise ValueError(" [!] unknown `log_func` value.")
|
||||||
# setup stft parameters
|
# setup stft parameters
|
||||||
|
@ -246,11 +245,11 @@ class AudioProcessor(object):
|
||||||
### DB and AMP conversion ###
|
### DB and AMP conversion ###
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
def _amp_to_db(self, x):
|
def _amp_to_db(self, x):
|
||||||
return self.spec_gain * self.log_func(np.maximum(1e-5, x))
|
return self.spec_gain * log_(np.maximum(1e-5, x), self.base)
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
def _db_to_amp(self, x):
|
def _db_to_amp(self, x):
|
||||||
return self.exp_func(x / self.spec_gain)
|
return exp_(x / self.spec_gain, self.base)
|
||||||
|
|
||||||
### Preemphasis ###
|
### Preemphasis ###
|
||||||
def apply_preemphasis(self, x):
|
def apply_preemphasis(self, x):
|
||||||
|
@ -429,3 +428,13 @@ class AudioProcessor(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def dequantize(x, bits):
|
def dequantize(x, bits):
|
||||||
return 2 * x / (2 ** bits - 1) - 1
|
return 2 * x / (2 ** bits - 1) - 1
|
||||||
|
|
||||||
|
def log_(x, base):
|
||||||
|
if base == 10:
|
||||||
|
return np.log(x)
|
||||||
|
return np.log10(x)
|
||||||
|
|
||||||
|
def exp_(x, base):
|
||||||
|
if base == np.e:
|
||||||
|
return np.exp(x)
|
||||||
|
return base ** x
|
||||||
|
|
Loading…
Reference in New Issue