This commit is contained in:
yumoqing 2024-02-03 12:16:05 +08:00
parent 194fbb4f10
commit 69a6658e17

View File

@ -4,6 +4,7 @@ from TTS.utils.synthesizer import Synthesizer
import numpy as np import numpy as np
# from logmmse import logmmse # from logmmse import logmmse
from scipy.io.wavfile import write from scipy.io.wavfile import write
from appPublic.worker import awaitify
from ahserver.serverenv import ServerEnv from ahserver.serverenv import ServerEnv
class CoquiTTS: class CoquiTTS:
@ -15,7 +16,7 @@ class CoquiTTS:
model_path, config_path, None, None, None, model_path, config_path, None, None, None,
) )
def generate(self, text): def _generate(self, text):
""" """
wavs = self.synthesizer.tts(text) wavs = self.synthesizer.tts(text)
enhanced = logmmse(np.array(wavs, dtype=np.float32), enhanced = logmmse(np.array(wavs, dtype=np.float32),
@ -36,3 +37,5 @@ class CoquiTTS:
b.seek(0,0) b.seek(0,0)
buf = b.read() buf = b.read()
return buf return buf
self.generate = awaitify(self._generate)