'Polly' 对象没有属性 'start_speech_synthesis_task'

'Polly' object has no attribute 'start_speech_synthesis_task'

我正在尝试通过以下代码使用 AWS Polly 的 StartSpeechSynthesisTask

client = boto3.client('polly')
response = client.start_speech_synthesis_task(
            OutputFormat= "mp3",
            Text = text,
            TextType = "ssml",
            VoiceId= VOICE, 
            OutputS3BucketName=BUCKET,
            OutputS3KeyPrefix=filename)

但是,它抛出这个错误:

'Polly' object has no attribute 'start_speech_synthesis_task'

我也用boto3.Session(...).client(...)实例化了客户端——同样的错误。

我尝试更新 boto3,但没有成功。 similar post in the AWS forums 似乎没有答案。

我该如何解决这个问题?

提前致谢!

解决了。我必须用 region_name:

实例化
client = boto3.Session(region_name='eu-west-2').client('polly')