python - python boto3文本到语音'polly'
问题描述
我正在使用 python 3,当我尝试运行我的代码时,出现错误:
raise NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.
我的代码:
import boto3
client = boto3.client('polly')
output = client.synthesize_speech (
Text = "Some random text I want to convert", OutputFormat = "mp3", VoiceId = 'Aditi'
)
print(output['AudioStream'])
file = open('speech.mp3', 'wb')
file.write(output['AudioStream'].read())
file.close()
解决方案
您需要尝试在客户端类中的某处添加区域名称。
IE
polly_client = boto3.Session(
aws_access_key_id=,
aws_secret_access_key=,
region_name='us-west-2').client('polly')
这不一定是你想要的,但你明白了。该区域必须包含在某处
推荐阅读
- vue.js - 具有 vuetify 依赖项的 Vue 库
- c# - 确定使用 Zzz 实体框架扩展和 BulkInsert 时插入的记录数
- html - 选中一个或多个复选框并提交后,复选框的一部分消失
- html - 超链接到 about:blank
- typescript - 带有异步和等待的打字稿:在分配之前使用变量.ts(2454)
- python - 使用 tf.keras.utils.Sequence 和 model.fit_generator 和 use_multiprocessing=True 生成警告
- python-3.x - xmlrpc 抛出 http.client.badstatusline 后如何查看响应
- c++ - 重载输入运算符。简单分数类
- powershell - 将数据提取到 CSV 但只需要前 4 个字符 - Powershell
- html - 为什么我开始输入时我的输入框变大了