mirror of https://github.com/coqui-ai/TTS.git
save_wav with a custom sampling rate
This commit is contained in:
parent
9fefc79f0c
commit
00e0933f43
|
@ -219,7 +219,7 @@ def main():
|
||||||
str.maketrans('', '', string.punctuation.replace('_', ''))) + '.wav'
|
str.maketrans('', '', string.punctuation.replace('_', ''))) + '.wav'
|
||||||
out_path = os.path.join(args.out_path, file_name)
|
out_path = os.path.join(args.out_path, file_name)
|
||||||
print(" > Saving output to {}".format(out_path))
|
print(" > Saving output to {}".format(out_path))
|
||||||
synthesizer.save_wav(wav, out_path)
|
synthesizer.save_wav(wav, out_path,)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -342,9 +342,10 @@ class AudioProcessor(object):
|
||||||
x = self.sound_norm(x)
|
x = self.sound_norm(x)
|
||||||
return x
|
return x
|
||||||
|
|
||||||
def save_wav(self, wav, path):
|
def save_wav(self, wav, path, sample_rate=None):
|
||||||
|
sample_rate = self.sample_rate if sample_rate is None else sample_rate
|
||||||
wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav))))
|
wav_norm = wav * (32767 / max(0.01, np.max(np.abs(wav))))
|
||||||
scipy.io.wavfile.write(path, self.sample_rate, wav_norm.astype(np.int16))
|
scipy.io.wavfile.write(path, sample_rate, wav_norm.astype(np.int16))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mulaw_encode(wav, qc):
|
def mulaw_encode(wav, qc):
|
||||||
|
|
Loading…
Reference in New Issue