Skip to content

AWS Polly python synthesize_speech delayed response

0

I'm not sure if I'm doing things incorrectly, but sometimes it takes almost precisely a minute (60-61 secs) to get a response back. Most of the time it is < 1 sec, but sometimes it gets to 60.x secs - never longer, never shorter, always around that 1 minute mark. Some background:
I'm using it in a Django application, and in a helper file, towards the top I initiate things:

session = Session(
        region_name="us-east-1",
        aws_access_key_id=...
        aws_secret_access_key=...
        )
polly = session.client("polly")

Then down in a function (in the helper file):

def some_function():
    time1 = time.time()
    response = polly.synthesize_speech(
                            Text=<....>,
                            OutputFormat="mp3",
                            VoiceId="Justin",
                            TextType="ssml"
                        )
    time2 = time.time()

Then in a views file (since this is used in Django), it will call on "some_function" when requests arrive.

As mentioned, time2 - time1 is usually < 1 sec, but from time to time, it gets to 60-61 secs... I initially thought it was some sort of rate limiting, but I looked up the limits for AWS polly and it seems like I am far away from any throttling limits. I'm out of ideas, so any inspiration is much welcome! Thanks in advance!

Also, not sure if relevant, but the Django app is hosted on Azure - would that cause any random in occurrence, but consistent in duration delays?

asked 6 years ago761 views
3 Answers
0
Accepted Answer

Hi Mfxuus,

Thank you for reaching out to us. It looks like the problem you are facing is related to the default boto3 timeout setting. You can change this setting and test if it helps with your issue.

Here is a guide on how to change timeout setting:
https://aws.amazon.com/premiumsupport/knowledge-center/lambda-function-retry-timeout-sdk/

Please reach out to us, in case this does not solve your issue.

Thanks,
Fatih

answered 6 years ago
  • We seem to be facing this issue or something very similar.

    Other interesting details:

    • We've only seen this issue occur if our service has been idle for over 24hrs
    • We always make 2 requests at once in different threads (audio & marks)
    • The request is always JUST over 60s, so much so it can't be a coincidence and some sort of retry timeout is very likely
    • It only ever seems to be one request that takes a long time (one pair of audio and marks, we don't log which was the long one atm) This is leading me to believe this is a client bug. A 5 second delay is unacceptable for our use-case (conversational AI), so I would rather fix the problem instead of tweaking retry timings.

    I will add some logging to try and understand if response["ResponseMetadata"]["RetryAttempts"] is non-zero for the 60s requests.

0

Thank you! That does sound consistent with what we're experiencing. Will set a custom timeout and see if that fixes things!

answered 6 years ago
0

Hi Fatih,

Following up on this issue - I think it is indeed the timeout setting, and more specifically, it is the "read_timeout" causing the issue. Do you by any chance know if this "read_timeout" refers to the total time spent reading the response, or simply "time til I start reading some response"? Just trying to figure out if setting it to say 5 secs would break anything in my app.

Thanks again!

Michael

answered 6 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.