27 lines
689 B
Python
27 lines
689 B
Python
import subprocess
|
|
|
|
PIPER_BIN = "piper"
|
|
PIPER_MODEL = "de_DE-thorsten-medium.onnx"
|
|
SAMPLE_RATE = 22050 #aplay -v assistant/audio-tts/predefined.wav so rausgefunden
|
|
|
|
def speak(text):
|
|
|
|
print(f"[TTS] {text}")
|
|
|
|
process = subprocess.Popen(
|
|
[PIPER_BIN, "--model", PIPER_MODEL, "--output-raw"],
|
|
stdin=subprocess.PIPE,
|
|
stdout=subprocess.PIPE
|
|
)
|
|
|
|
audio = process.communicate(input=text.encode("utf-8"))[0]
|
|
|
|
play = subprocess.Popen(
|
|
["aplay", "-r", str(SAMPLE_RATE), "-f", "S16_LE"],
|
|
stdin=subprocess.PIPE
|
|
)
|
|
play.communicate(audio)
|
|
|
|
|
|
text="Das Auto musste repariert werden, bevor wir weiterfahren konnten, neuer text"
|
|
speak(text) |