Python API - working streaming example? #213
Unanswered
pilgrimwebshop
asked this question in
Q&A
Replies: 1 comment
|
hi, those two names are placeholders for whatever audio sink you're using, not Piper functions you import. I tried the streaming path with the repo's test voice, and writing chunks like this produced the same WAV bytes as import wave
from piper import PiperVoice
voice = PiperVoice.load("/path/to/voice.onnx")
with wave.open("out.wav", "wb") as wav:
first = True
for chunk in voice.synthesize("text to speak"):
if first:
wav.setframerate(chunk.sample_rate)
wav.setsampwidth(chunk.sample_width)
wav.setnchannels(chunk.sample_channels)
first = False
wav.writeframes(chunk.audio_int16_bytes)So If you want actual speaker playback instead of a WAV file, #85 has a PyAudio version that does the same thing: #85 (comment) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I've looked at the documentation and found the following code:
set_audio_format() and write_raw_data() both are undefined. Is there something I need to import, or can I get some help defining these functions?
Thank you!
All reactions