diff --git a/Youtube/GPT4ALL_CoquiTTS.py b/Youtube/GPT4ALL_CoquiTTS.py new file mode 100644 index 0000000..8bfb1a6 --- /dev/null +++ b/Youtube/GPT4ALL_CoquiTTS.py @@ -0,0 +1,27 @@ +from pygpt4all.models.gpt4all_j import GPT4All_J +from TTS.api import TTS +import wave,sys,pyaudio + +def new_text_callback(text): + print(text, end="") + +model = GPT4All_J('./ggml-gpt4all-j-v1.2-jazzy.bin') +outText = model.generate("Once upon a time, ", n_predict=55, new_text_callback=new_text_callback) +print(outText) + +tts = TTS(model_name="tts_models/en/ljspeech/vits--neon") +tts.tts_to_file(text=outText) + +wf = wave.open('output.wav') +p = pyaudio.PyAudio() +chunk = 1024 +stream = p.open(format= + p.get_format_from_width(wf.getsampwidth()), + channels=wf.getnchannels(), + rate=wf.getframerate(), + output = True +) +data = wf.readframes(chunk) +while data != '': + stream.write(data) + data=wf.readframes(chunk)