Closed she7ata7 closed 3 weeks ago
from RealtimeTTS import TextToAudioStream, CoquiEngine, GTTSVoice
import time
class TTS_CoquiEngine:
def __init__(self):
self.engine = CoquiEngine()
self.stream = TextToAudioStream(self.engine)
def __dummy_generator(self):
yield "Hey guys! These here are realtime spoken sentences based on local text synthesis."
def play_stream(self):
# Record the start time
start_time = time.time()
print("Starting to play stream")
self.stream.feed(self.__dummy_generator()).play(log_synthesized_text=True)
def command_to_stream(self, text, on_audio_chunk_callback):
self.stream.feed(text)
self.stream.play(on_audio_chunk=on_audio_chunk_callback, muted=True)
def command_to_wav(self, command, file_path):
self.stream.feed(command)
self.stream.play(output_wavfile = file_path, muted= True)
return file_path
def shutdown(self):
self.engine.shutdown()
if __name__ == '__main__':
tts = TTS_CoquiEngine()
tts.play_stream()
tts.shutdown()
I'm trying to use STT but sometimes it works and sometimes no, Please tell me what I need to do to fix that.