Spaces:
Sleeping
Sleeping
Upload src/backends/piper.py with huggingface_hub
Browse files- src/backends/piper.py +7 -1
src/backends/piper.py
CHANGED
|
@@ -80,7 +80,13 @@ class PiperTTSBackend(TTSBackend):
|
|
| 80 |
tmp_path = Path(tmp.name)
|
| 81 |
try:
|
| 82 |
with wave.open(str(tmp_path), "wb") as wav_file:
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
audio, src_rate = read_wav_file(tmp_path)
|
| 85 |
finally:
|
| 86 |
tmp_path.unlink(missing_ok=True)
|
|
|
|
| 80 |
tmp_path = Path(tmp.name)
|
| 81 |
try:
|
| 82 |
with wave.open(str(tmp_path), "wb") as wav_file:
|
| 83 |
+
# piper-tts >= 1.3 renames the WAV writer to ``synthesize_wav``;
|
| 84 |
+
# the old ``synthesize(text, wav_file)`` no longer sets the WAV
|
| 85 |
+
# header (raising "# channels not specified"). Support both.
|
| 86 |
+
if hasattr(model, "synthesize_wav"):
|
| 87 |
+
model.synthesize_wav(text, wav_file)
|
| 88 |
+
else:
|
| 89 |
+
model.synthesize(text, wav_file)
|
| 90 |
audio, src_rate = read_wav_file(tmp_path)
|
| 91 |
finally:
|
| 92 |
tmp_path.unlink(missing_ok=True)
|