Small Commit
This commit is contained in:
27
test_tts.py
Normal file
27
test_tts.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user