I want to lower the speed at which the tts speaks at, I searched around for a couple of hours, but can't find the answer. Please help. Thank You in advance.
CodePudding user response:
From Voice Speed - Amazon Polly:
Amazon Polly helps you slow down the rate of speech using the SSML tag, as in:
<speak>
In some cases, it might help your audience to <prosody rate="85%">slow
the speaking rate slightly to aid in comprehension.</prosody>
</speak>
or
<speak>
In some cases, it might help your audience to <prosody rate="slow">slow
the speaking rate slightly to aid in comprehension.</prosody>
</speak>
Python can use the boto3 AWS SDK, which has a synthesize_speech()
API call that accepts a Text
field with the text to convert into speech. If you also set TextType='ssml'
, then the text can include SSML as shown in the example above.
CodePudding user response:
I got it, here is an example for all of those who don't get it either.
import boto3
polly_client = boto3.Session(
aws_access_key_id='your_access_key_id',
aws_secret_access_key='your_secret_access_key',
region_name='your_region').client('polly')
response = polly_client.synthesize_speech(
VoiceId='Joanna',
OutputFormat='mp3',
Engine = 'neural',
TextType = "ssml",
Text = "<speak><prosody rate='90%'>The Quick Brown Fox Jumps Over the Lazy Dog</prosody></speak>") # prosody rate changes the speed of the speech.
with open('folder/speech.mp3', 'wb') as file: #the folder part is here if you want to create the mp3 in a specific folder, if you don't want that, just remove it.
file.write(response['AudioStream'].read())