【问题标题】:How to use AWS polly in boto3 for pause如何在 boto3 中使用 AWS polly 进行暂停
【发布时间】:2020-10-22 13:24:11
【问题描述】:

我的代码如下:

import boto3
polly_client = boto3.Session().client('polly')    

response = polly_client.synthesize_speech(
    VoiceId='Joanna',
    OutputFormat='mp3', 
    Text = sentence
)
audio = response['AudioStream']

我尝试过使用以下句子:

sentence = '''<speak><s>Mary had a little lamb</s> <s>Whose fleece was white as snow</s>And everywhere that Mary went, the lamb was sure to go.</speak>'''

但生成的音频没有停顿,它只是读出文本。

【问题讨论】:

标签: amazon-web-services amazon-polly


【解决方案1】:

这会为短语“Hello world”生成一个音频文件,单词之间有 2 秒的停顿:

import boto3
polly_client = boto3.Session().client('polly')

sentence = '''<speak>Hello <break time='2000ms'/> World</speak>'''

response = polly_client.synthesize_speech(
    VoiceId='Joanna',
    OutputFormat='mp3',
    TextType='ssml',
    Text=sentence
)

file = open('speech.mp3', 'wb')
file.write(response['AudioStream'].read())
file.close()

有关更多详细信息,请参阅 Using SSML 下的 aws 文档小节。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多