I want to use Amazon Polly with boto3 for TTS with Ssml support.
When I try to run this code, I get the error
botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the SynthesizeSpeech operation: The security token included in the request is invalid.
import boto3
# AWS credentials
session = boto3.Session(
aws_access_key_id='xxx',
aws_secret_access_key='xxxxx',
region_name='eu-north-1'
)
# Initialize Polly client
polly_client = session.client('polly')
# Synthesize speech
response = polly_client.synthesize_speech(
Text='Hello, this is a sample text.',
OutputFormat='mp3',
VoiceId='Joanna' # Specify voice to use
)
# Save synthesized audio to a file
with open('output.mp3', 'wb') as file:
file.write(response['AudioStream'].read())
I checked the keys and if the region is enabled in my account.
I found this but since I didn't download the Aws CLI, I don't have a .aws folder in %USERPROFILE%\.aws\credentials.
Do I really need to download and set up the Aws CLI?
Thanks for the help
I used the wrong login lol. I used the account-id and user-id from the account detailes instead of creating a key.