By using AWS re:Post, you agree to the Terms of Use

Polly: GetSpeechSynthesisTask return length of audio


can we get the duration of the audio returned in the success response

asked 18 days ago21 views
2 Answers

Hi! Amazon Polly does not currently return the length of the audio. You would have to use third party libraries such as ffmpeg or mutagen to obtain the length from the file! Hope this helps! :)

answered 16 days ago
  • Hey, did this work for you? Remember to accept the answer if it has helped you (^_^)


I can provide an alternative to Dani's suggestion. There is an approach which will allow you to determine the length of generated Polly audio by using nothing more than the Polly API, though it is a little non-obvious. You can request that Polly return "speech marks" - metadata which describes the synthesized speech. One type of speech mark data you can request are "visemes". These are timestamped descriptions of the face and mouth movements that a human would use to make each component sound found in the generated audio. The viseme data will always end with a viseme labelled "sil" which represents silence. The time-stamp of this last viseme represents the end of the final sound in the generated audio.

Here's the viseme metadata returned for the phrase "Hello, world"...


Viseme timestamps are expressed in milliseconds. So we can see that, given the voice I selected when generating the audio, the generated audio is 1.212 seconds in duration.

answered 7 days 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.

Guidelines for Answering Questions