rhasspy / wyoming

Peer-to-peer protocol for voice assistants
MIT License
138 stars 20 forks source link

Updated wyoming package broke wyoming-piper tts #9

Open jerblack opened 9 months ago

jerblack commented 9 months ago

I reinstalled the requirements.txt for wyoming-piper last night and it installed a new version of the wyoming package, and now I am no longer able to use TTS from the HA interface and my piper service is logging the following:

Feb 19 08:09:11 wyoming python3[19699]: ERROR:asyncio:Task exception was never retrieved
Feb 19 08:09:11 wyoming python3[19699]: future: <Task finished name='Task-10' coro=<AsyncEventHandler.run() done, defined at /home/jeremy/wyoming-piper/.venv/lib/python3.10/site-packages/wyoming/server.py:28> exception=FileNotFoundError(2, 'No such file or directory')>
Feb 19 08:09:11 wyoming python3[19699]: Traceback (most recent call last):
Feb 19 08:09:11 wyoming python3[19699]:   File "/home/jeremy/wyoming-piper/.venv/lib/python3.10/site-packages/wyoming/server.py", line 35, in run
Feb 19 08:09:11 wyoming python3[19699]:     if not (await self.handle_event(event)):
Feb 19 08:09:11 wyoming python3[19699]:   File "/home/jeremy/wyoming-piper/wyoming_piper/handler.py", line 98, in handle_event
Feb 19 08:09:11 wyoming python3[19699]:     wav_file: wave.Wave_read = wave.open(output_path, "rb")
Feb 19 08:09:11 wyoming python3[19699]:   File "/usr/lib/python3.10/wave.py", line 509, in open
Feb 19 08:09:11 wyoming python3[19699]:     return Wave_read(f)
Feb 19 08:09:11 wyoming python3[19699]:   File "/usr/lib/python3.10/wave.py", line 159, in __init__
Feb 19 08:09:11 wyoming python3[19699]:     f = builtins.open(f, 'rb')
Feb 19 08:09:11 wyoming python3[19699]: FileNotFoundError: [Errno 2] No such file or directory: ''

Here's the command line I am using in my wyoming-piper service, and I didn't see any other flags to specify another folder, so I don't know what it's looking for in the error. Any ideas? :

ExecStart=/home/jeremy/wyoming-piper/.venv/bin/python3 -m wyoming_piper \
  --piper '/home/jeremy/.local/bin/piper' \
  --uri 'tcp://0.0.0.0:10200' \
  --data-dir /config/piper_data/data \
  --download-dir /config/piper_data/download \
  --voice en_US-libritts_r-medium \
  --max-piper-procs 16 \
  --update-voices
synesthesiam commented 9 months ago

The error suggests that the piper executable isn't generating WAV files.

jerblack commented 9 months ago

The following troubleshooting changed nothing.

In the end, what fixed it was just restarting Home Assistant on my Pi. Now libritts_r works and the error above no longer occurs. Closing issue.

jerblack commented 9 months ago

Update: Thinking that the problem might be resolved fully by the reboot, I removed the working Docker instance of Piper from the Wyoming integration and moved back to my LXD install of Piper, and the problem occurred again with that FileNotFoundError error. This persisted even after another HA reboot.

This was my setup process in LXD (which I use just like a regular Linux VM). I am just cloning the repo and running script/setup for each of the three components:

git clone https://github.com/rhasspy/wyoming-faster-whisper.git
cd wyoming-faster-whisper
script/setup
cd ~
git clone https://github.com/rhasspy/wyoming-piper.git
~/wyoming-piper/script/setup
script/setup
cd~
git clone https://github.com/rhasspy/piper.git
~/piper/src/python_run
script/setup

And then from ~/piper/src/python_run I run the following to verify Piper is working:

echo the time is now 3 15 pm | script/piper --cuda --model /config/piper_data/data/en_US-libritts_r-medium.onnx --output_file time.wav

This works fine, and generates the appropriate wav file, which I verified matches the text I gave, so Piper is definitely able to generate TTS audio. I'm not doing any other special configuration beyond my service file, which looks like this:

# /etc/systemd/system/piper.service
[Unit]
Description=Piper
After=network.target

[Service]
Type=simple
User=jeremy
WorkingDirectory=/home/jeremy/wyoming-piper
ExecStart=/home/jeremy/wyoming-piper/script/run \
  --piper '/home/jeremy/piper/src/python_run/script/piper' \
  --uri 'tcp://0.0.0.0:10200' \
  --data-dir /config/piper_data/data \
  --download-dir /config/piper_data/download \
  --voice en_US-libritts_r-medium \
  --max-piper-procs 16 \
  --update-voices
Restart=always

[Install]
WantedBy=multi-user.target

The main difference as far as I understand at the moment is that the older Docker version is running an older version of wyoming-piper that works, and what I'm using in LXD is just the latest from your repo, which is where the FileNoteFoundError is generated. All of this is probably putting the cart before the horse though since the main reason I wanted to do any of this was to get Cuda support in Piper, but the merge request to add it looks like it's been sitting idle waiting on final approval for the last two months now. Why is that by the way?

synesthesiam commented 9 months ago

All of this is probably putting the cart before the horse though since the main reason I wanted to do any of this was to get Cuda support in Piper, but the merge request to add it looks like it's been sitting idle waiting on final approval for the last two months now. Why is that by the way?

I'd love to get CUDA support in, but I have a lot on my TODO list. For wyoming-piper and CUDA, I think a better approach than https://github.com/rhasspy/wyoming-piper/pull/5 would be to switch over to the Python version of piper and install onnxruntime-gpu into the container.

OCT0PUSCRIME commented 8 months ago

@jerblack

Did you ever figure this out? I am having the same issue. The wav files do not seem to be coming into the /tmp directory as they are supposed to. I followed the same process in my LXC that you did. I believe it worked the first command I sent, but after a couple changes it no longer seems to be working. Another note, from homeassistant > media > TTS > Piper I can send a request like "test". I get the same logs as you with file not found. If I try to send "test" again I don't even get any further logs. I have to change the message to something new, like "testing" to see the file not found error again.

Edit: I guess just not using piper-tts in the python env works fine. For now I will use the binary. Also following on the CUDA support.

ms1design commented 7 months ago

FYI @synesthesiam @jerblack here's how I got it to work in our Home Assistant integration project on Jetson devices: https://github.com/dusty-nv/jetson-containers/pull/481/commits/4ba5dc4d20e8fb92f3059e16cc4cfd3648aa88be