mirror of
https://github.com/wassname/TTS.git
synced 2026-09-09 11:16:00 +08:00
save_wav with a custom sampling rate
This commit is contained in:
@@ -219,7 +219,7 @@ def main():
|
||||
str.maketrans('', '', string.punctuation.replace('_', ''))) + '.wav'
|
||||
out_path = os.path.join(args.out_path, file_name)
|
||||
print(" > Saving output to {}".format(out_path))
|
||||
synthesizer.save_wav(wav, out_path)
|
||||
synthesizer.save_wav(wav, out_path,)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+3
-2
@@ -342,9 +342,10 @@ class AudioProcessor(object):
|
||||
x = self.sound_norm(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))))
|
||||
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
|
||||
def mulaw_encode(wav, qc):
|
||||
|
||||
Reference in New Issue
Block a user