rhasspy / piper

A fast, local neural text to speech system
https://rhasspy.github.io/piper-samples/
MIT License
6.55k stars 478 forks source link

Piper will not initialize on Home Assistant without an internet connection? #195

Open doctorgaul opened 1 year ago

doctorgaul commented 1 year ago

I’m trying to run my Home Assistant on a network that isn’t connected to the internet, and it seems like that’s preventing Piper from even starting up. It works fine when I run it on an internet-connected network, but if I run it on just my LAN, it fails.

Here’s the log file, which I think indicates that the program is failing because it can’t reach the internet. Any way to fix this?


s6-rc: info: service s6rc-oneshot-runner: starting

s6-rc: info: service s6rc-oneshot-runner successfully started

s6-rc: info: service fix-attrs: starting

s6-rc: info: service fix-attrs successfully started

s6-rc: info: service legacy-cont-init: starting

s6-rc: info: service legacy-cont-init successfully started

s6-rc: info: service piper: starting

s6-rc: info: service piper successfully started

s6-rc: info: service discovery: starting

Traceback (most recent call last):

File "/usr/lib/python3.11/urllib/request.py", line 1348, in do_open

h.request(req.get_method(), req.selector, req.data, headers,

File "/usr/lib/python3.11/http/client.py", line 1282, in request

self._send_request(method, url, body, headers, encode_chunked)

File "/usr/lib/python3.11/http/client.py", line 1328, in _send_request

self.endheaders(body, encode_chunked=encode_chunked)

File "/usr/lib/python3.11/http/client.py", line 1277, in endheaders

self._send_output(message_body, encode_chunked=encode_chunked)

File "/usr/lib/python3.11/http/client.py", line 1037, in _send_output

self.send(msg)

File "/usr/lib/python3.11/http/client.py", line 975, in send

self.connect()

File "/usr/lib/python3.11/http/client.py", line 1447, in connect

super().connect()

File "/usr/lib/python3.11/http/client.py", line 941, in connect

self.sock = self._create_connection(

^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/socket.py", line 827, in create_connection

for res in getaddrinfo(host, port, 0, SOCK_STREAM):

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/socket.py", line 962, in getaddrinfo

for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^

socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "", line 198, in _run_module_as_main

File "", line 88, in _run_code

File "/usr/local/lib/python3.11/dist-packages/wyoming_piper /main.py", line 193, in

asyncio.run(main())

File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run

return runner.run(main)

^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run

return self._loop.run_until_complete(task)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete

return future.result()

^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.11/dist-packages/wyoming_piper /main.py", line 161, in main

await process_manager.get_process()

File "/usr/local/lib/python3.11/dist-packages/wyoming_piper /process.py", line 114, in get_process

ensure_voice_exists(

File "/usr/local/lib/python3.11/dist-packages/wyoming_piper /download.py", line 137, in ensure_voice_exists

with urlopen(file_url) as response, open(

^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen

return opener.open(url, data, timeout)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/urllib/request.py", line 519, in open

response = self._open(req, data)

^^^^^^^^^^^^^^^^^^^^^

File "/usr/lib/python3.11/urllib/request.py", line 536, in _open

result = self._call_chain(self.handle_open, protocol, protocol +

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^

File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain

result = func(*args)

^^^^^^^^^^^

File "/usr/lib/python3.11/urllib/request.py", line 1391, in https_open

return self.do_open(http.client.HTTPSConnection, req,

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^

File "/usr/lib/python3.11/urllib/request.py", line 1351, in do_open

raise URLError(err)

urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>

[16:22:26] INFO: Service exited with code 1 (by signal 0)

synesthesiam commented 1 year ago

The Piper add-on does not include any voices. It will download the default voice the first time it's run, and from then on you can use it without an internet connection. On Home Assistant OS, you may also manually download voices to /share/piper

doctorgaul commented 1 year ago

I appreciate the response! I've left my Home Assistant instance running online for over 24 hours, and I've confirmed everything is working as intended. I have just switched it back to the LAN-only network, and it continues refusing to start, with the same error.

Clearly Piper is checking the internet on every single startup, not just the first one. Here's a current log file. As Piper runs, it's just repeating this every 4-5 seconds. Thoughts on next steps?


Traceback (most recent call last): File "/usr/lib/python3.11/urllib/request.py", line 1348, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/usr/lib/python3.11/http/client.py", line 1282, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.11/http/client.py", line 1328, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.11/http/client.py", line 1277, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.11/http/client.py", line 1037, in _send_output self.send(msg) File "/usr/lib/python3.11/http/client.py", line 975, in send self.connect() File "/usr/lib/python3.11/http/client.py", line 1447, in connect super().connect() File "/usr/lib/python3.11/http/client.py", line 941, in connect self.sock = self._create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/socket.py", line 827, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/socket.py", line 962, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ socket.gaierror: [Errno -3] Temporary failure in name resolution During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/local/lib/python3.11/dist-packages/wyoming_piper/main.py", line 193, in asyncio.run(main()) File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/wyoming_piper/main.py", line 161, in main await process_manager.get_process() File "/usr/local/lib/python3.11/dist-packages/wyoming_piper/process.py", line 114, in get_process ensure_voice_exists( File "/usr/local/lib/python3.11/dist-packages/wyoming_piper/download.py", line 137, in ensure_voice_exists with urlopen(file_url) as response, open( ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen return opener.open(url, data, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/urllib/request.py", line 519, in open response = self._open(req, data) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/urllib/request.py", line 536, in _open result = self._call_chain(self.handle_open, protocol, protocol + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain result = func(*args) ^^^^^^^^^^^ File "/usr/lib/python3.11/urllib/request.py", line 1391, in https_open return self.do_open(http.client.HTTPSConnection, req, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/urllib/request.py", line 1351, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution> [10:28:41] INFO: Service exited with code 1 (by signal 0)

doctorgaul commented 1 year ago

I've copied the entire English voice collection into /share/piper/piper-voices/. Screenshot below:

image

image

Piper still doesn't seem to be recognizing them. Is this the right directory structure?

Also, in case it's useful, here's a log file for a successful startup while connected to the internet. Note that it downloads _enUS-lessac-medium.onnx and _enUS-lessac-medium.onnx.json on every boot. If I change to a different voice, it tries to download that one instead.


s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service piper: starting s6-rc: info: service piper successfully started s6-rc: info: service discovery: starting INFO:wyoming_piper.download:Downloaded /data/en_US-lessac-medium.onnx (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx) INFO:wyoming_piper.download:Downloaded /data/en_US-lessac-medium.onnx.json (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json) INFO:main:Ready [14:13:18] INFO: Successfully send discovery information to Home Assistant. s6-rc: info: service discovery successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started