From 73019d610762b81aeb42382f4b018fb24172c060 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 31 Jan 2024 16:50:21 +0800 Subject: [PATCH] bugfix --- coquitts/coqui.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/coquitts/coqui.py b/coquitts/coqui.py index 74984d4..78b7c60 100644 --- a/coquitts/coqui.py +++ b/coquitts/coqui.py @@ -2,14 +2,13 @@ from io import BytesIO from TTS.utils.manage import ModelManager from TTS.utils.synthesizer import Synthesizer import numpy as np -from logmmse import logmmse +# from logmmse import logmmse from scipy.io.wavfile import write from ahserver.serverenv import ServerEnv class CoquiTTS: def __init__(self, model_name): - manager = ModelManager() - # model_path, config_path, model_item = manager.download_model("tts_models/zh-CN/baker/tacotron2-DDC-GST") + self.manager = ModelManager() model_path, config_path, model_item = manager.download_model(model_name) print(f'reult={model_path=}, {config_path=}, {model_item=}') self.synthesizer = Synthesizer( @@ -17,6 +16,7 @@ class CoquiTTS: ) def generate(self, text): + """ wavs = self.synthesizer.tts(text) enhanced = logmmse(np.array(wavs, dtype=np.float32), self.synthesizer.output_sample_rate, @@ -28,4 +28,11 @@ class CoquiTTS: write(b, self.synthesizer.output_sample_rate, enhanced) b.seek(0,0) buf = b.read() + """ + wavs = self.synthesizer.tts(text) + data = np.array(wavs, dtype=np.float32) + b = BytesIO() + write(b, self.synthesizer.output_sample_rate, data) + b.seek(0,0) + buf = b.read() return buf