Error for some requests with Watson TTS

Hey there!
I recently switched to Watson TTS for German speech synthesis and it works great most of the time!
But if I haven’t let Mycroft say something for a longer interval of time, the first thing he says will always fail for some reason, meaning that he simply has no audio output, but the answer is still visible in the CLI.
The error in the audio.log file looks as follows:

2022-03-22 18:16:59.354 | ERROR    |   699 | mycroft.audio.speech:mute_and_speak:134 | TTS execution failed.
Traceback (most recent call last):
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1352, in getresponse
    response.begin()
  File "/usr/lib/python3.7/http/client.py", line 310, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.7/http/client.py", line 271, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.7/ssl.py", line 1052, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.7/ssl.py", line 911, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/requests/adapters.py", line 450, in send
    timeout=timeout
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 786, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 770, in reraise
    raise value
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 710, in urlopen
    chunked=chunked,
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 451, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 341, in _raise_timeout
    self, url, "Read timed out. (read timeout=%s)" % timeout_value
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.eu-de.text-to-speech.watson.cloud.ibm.com', port=443): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/mycroft-core/mycroft/tts/remote_tts.py", line 54, in execute
    self.__play(req)
  File "/home/pi/mycroft-core/mycroft/tts/remote_tts.py", line 83, in __play
    resp = req.result()
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/requests/adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.eu-de.text-to-speech.watson.cloud.ibm.com', port=443): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/mycroft-core/mycroft/audio/speech.py", line 129, in mute_and_speak
    tts.execute(utterance, ident, listen)
  File "/home/pi/mycroft-core/mycroft/tts/remote_tts.py", line 56, in execute
    LOG.error(e.message)
AttributeError: 'ReadTimeout' object has no attribute 'message'

Maybe someone understands how to possibly fix this :frowning:

Best regards,
Elias.

Seems to be related to your network according to this message:

requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.eu-de.text-to-speech.watson.cloud.ibm.com', port=443): Read timed out. (read timeout=10)

Mycroft is not able to reach the TTS.

1 Like

Thanks for your answer, but it can’t be related to the network, as utterances that require web information to be retrieved work just fine. Their output is visible, but the audio output fails…

From your Mycroft instance, are you able to ping api.eu-de.text-to-speech.watson.cloud.ibm.com?

Yes, it is working just as expected in all instances.

I did some tests and it works fine for me.

Voice: en-US_AllisonV3Voice
Region: us-south

No timeouts.

10:46:28.293 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.us-south.text-to-speech.watson.cloud.ibm.com:443
2022-03-23 10:46:29.303 | DEBUG    |     1 | urllib3.connectionpool | https://api.us-south.text-to-speech.watson.cloud.ibm.com:443 "GET /instances/XXXXXXXXXXXXX/v1/synthesize?accept=audio%2Fwav&LOCALE=en-us&voice=en-US_AllisonV3Voice&X-Watson-Learning-Opt-Out=true&text=It%27s+currently+0+degrees. HTTP/1.1" 200 None
10:46:29.303 - urllib3.connectionpool - DEBUG - https://api.us-south.text-to-speech.watson.cloud.ibm.com:443 "GET /instances/XXXXXXXXXXXXX/v1/synthesize?accept=audio%2Fwav&LOCALE=en-us&voice=en-US_AllisonV3Voice&X-Watson-Learning-Opt-Out=true&text=It%27s+currently+0+degrees. HTTP/1.1" 200 None

Do you have any firewall rules?

Weird :frowning: I just checked and I don’t have any firewall rules…
I really have no idea what seems to be the problem, as a second request right after the first one fails always works…