Skip to content
Discussion options

You must be logged in to vote

This is an edge case in the current synthesize_wav implementation, rather than an intentional WAV representation.

voice.synthesize() skips empty phoneme lists, so punctuation-only input can produce zero AudioChunks (source). synthesize_wav() initializes the WAV format only when it receives the first chunk (source). With ". . . " there is no first chunk, so Python's wave writer reaches close() without nchannels ever being set and raises the error you saw.

If your desired contract is “always create a valid WAV, even when it has zero frames”, initialize the format yourself and tell Piper not to set it lazily:

import wave
from piper import PiperVoice

voice = PiperVoice.load("pipermodels/en_G…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by floorwarior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants