Update Uptated-Prototype/TTS-Script-PiperTTS.py

This commit is contained in:
2025-11-16 09:18:29 -08:00
parent c1da331c03
commit b97ee3d377

View File

@@ -4,8 +4,11 @@ import pyaudio
import os import os
import subprocess import subprocess
texttospeak = subprocess.Popen(["xsel"], text=True) result = subprocess.Popen(["xsel"], text=True)
print(texttospeak) print(result)
texttospeak = str(result)
# texttospeak = "Welcome to the world of speech synthesis! This is an example of text-to-speech using Piper TTS." # texttospeak = "Welcome to the world of speech synthesis! This is an example of text-to-speech using Piper TTS."
@@ -15,7 +18,7 @@ voicedir = os.path.expanduser('~') #Where onnx model files are stored on my mach
model = voicedir+"/en_GB-alba-medium.onnx" model = voicedir+"/en_GB-alba-medium.onnx"
voice = PiperVoice.load(model) voice = PiperVoice.load(model)
chunks = voice.synthesize(str(texttospeak)) # Set up Piper to stream audio from TextToSpeak chunks = voice.synthesize(texttospeak) # Set up Piper to stream audio from TextToSpeak
first_chunk = next(chunks) # Get the first chunk to set up audio stream configuration first_chunk = next(chunks) # Get the first chunk to set up audio stream configuration
p = pyaudio.PyAudio() p = pyaudio.PyAudio()