Amazon Polly TTS Slow Response

For the past several weeks, when I call the Amazon Polly TTS service and I use message text that hasn’t been cached, it takes 40-60 seconds before it speaks.

I’m not seeing anything in my home_assistant.log when there’s a delay.

Any ideas?

Seems to be an issue specifically with Amazon Polly. I switched over to Google Translate’s TTS and everything’s been great for the last couple of days.

I’d like to get this sorted because Google’s TTS always sounds sarcastic to me. Like that old Kids in the Hall sketch: I reallly wanna be your friend.

I also have the same issue, very slow response from Amazon Polly.

What I noticed is that the delay is only their when I trigger the tts service using an automation. If I use the developer tools to manually fire the service, the response is almost instant.

If anyone has a suggestion on how to debug this, I’m more than happy to help!

Update: upgrading to version 0.108.* seems to have fixed the issue for me :slight_smile:

I still have this issue on 108.6. Any idea how to fix this?

I just got around to updating to .109.3 (from .106.6 - I got lazy for a bit)
I updated my speak-routine to use Polly again. I’ll give it a go for a few days and see if I still see the slow-down.

1 Like

Yup. Problem still persists for me on .109.3

Is anyone else that’s experiencing the problem using the Alexa Media Player component? Wonder if that has any bearing on the issue.

Thanks for confirming. I do not use the Alexa Media player. I guess we will need to turn on debug logging and raise an issue on Github.

Issue is created on Github: https://github.com/home-assistant/core/issues/35258

If you can contribute a useful log, that would be great.

1 Like

The issue is still present for me on 0.110.4. How about you guys?

Still experiencing this on .118

I’d love to switch back to Polly…

The issue causing this is that the boto3 python client library used to connect with Amazon AWS has been optimized to do a high volume of transactions. It maintains a pool of persistent network to connections to AWS and after certain period of time on inactivity those network connections become unresponsive. So the long delay is a result of the client waiting on a 60 second network read timeout. This could be firewall/NAT related.

I created a pull request that has been merged into dev which limits the number of connections in the pool to one and changes the read timeout to 5 seconds. This should eventually make it into a home assistant release. This should make using Amazon Polly more tolerable, but when the network connection becomes unresponsive there is still a 5-7 second delay in the TTS. Cached TTS queries will still be instant.

The next step in attempting to fully squash the bug is to enable TCP keepalive on the network connections and setting a maximum idle time. However these settings in the boto3 client aren’t exposed via the python API. I made a feature request to the boto3 developers to implement this. If they implement it, I can see if enabling these features will result in an improvement.

1 Like