Closed TLsolutionstg closed 2 months ago
Hi @TLsolutionstg , try this:
model = "/home/loomi/Desktop/FlaskTest/en_en_GB_aru_medium_en_GB-aru-medium.onnx"
voice_config = "/home/loomi/Desktop/FlaskTest/en_en_GB_aru_medium_en_GB-aru-medium.onnx.json"
voice = PiperVoice.load(model,voice_config)
wav_file = wave.open("message1.wav","w")
audio = voice.synthesize(message, wav_file)
The PiperVoice object is created with the load method. Hope this works for you.
Hi @TLsolutionstg , try this:
model = "/home/loomi/Desktop/FlaskTest/en_en_GB_aru_medium_en_GB-aru-medium.onnx" voice_config = "/home/loomi/Desktop/FlaskTest/en_en_GB_aru_medium_en_GB-aru-medium.onnx.json" voice = PiperVoice.load(model,voice_config) wav_file = wave.open("message1.wav","w") audio = voice.synthesize(message, wav_file)
The PiperVoice object is created with the load method. Hope this works for you.
Thank you @wirthul. That was the fix. For future reference, I was also pointing to the wrong path for the .onnx file. This did not affect the original error, but it was another error that I fixed quickly.
I am writing a python program on raspberry pi using piper tts for text to speech. my code segment is (message is pulled from an outside str variable): model = "/home/loomi/Desktop/FlaskTest/en_en_GB_aru_medium_en_GB-aru-medium.onnx" voice_config = "/home/loomi/Desktop/FlaskTest/en_en_GB_aru_medium_en_GB-aru-medium.onnx.json" voice = PiperVoice(model,voice_config) wav_file = wave.open("message1.wav","w") audio = voice.synthesize(message, wav_file)
The error I am getting is: File "/home/loomi/Desktop/FlaskTest/app.py", line 81, in message_setup audio = voice.synthesize(message, wav_file) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/loomi/Desktop/FlaskTest/venv/lib/python3.11/site-packages/piper/voice.py", line 91, in synthesize wav_file.setframerate(self.config.sample_rate) ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'sample_rate' Exception ignored in: <function Wave_write.del at 0x7fff3d1d6660> Traceback (most recent call last): File "/usr/lib/python3.11/wave.py", line 447, in del self.close() File "/usr/lib/python3.11/wave.py", line 565, in close self._ensure_header_written(0) File "/usr/lib/python3.11/wave.py", line 583, in _ensure_header_written raise Error('# channels not specified') wave.Error: # channels not specified
Is this an issue with my code, or an issue with the repository?