我使用Polly生成文本到语音的MP3文件。我想在每个文件的末尾添加一个1秒的暂停。我该怎么做?
以下是我正在使用的内容:
// Load the SDK
const AWS = require('aws-sdk')
const Fs = require('fs')
AWS.config.loadFromPath('config.json');
// Create an Polly client
const Polly = new AWS.Polly({
signatureVersion: 'v4',
region: 'us-east-1'
})
let params = {
'Text': "This is the string I'm converting to MP3" ,
'OutputFormat': 'mp3',
'VoiceId': 'Kimberly'
}
Polly.synthesizeSpeech(params, (err, data) => {
if (err) {
console.log(err.code)
} else if (data) {
if (data.AudioStream instanceof Buffer) {
Fs.writeFile("./myverse.mp3", data.AudioStream, function(err) {
if (err) {
return console.log(err)
}
console.log("The file was saved!")
})
}
}
})
答案 0 :(得分:0)
我认为你应该在break section上查看SSML Tags in Amazon Polly documentation。
let params = {
'Text': `
This is the string I'm converting to MP3
<break strength="medium"></break>
` ,
'OutputFormat': 'mp3',
'VoiceId': 'Kimberly'
};
修改强>
也许您还必须将所有文字都包含在<speak>
代码中?
文档说:
<speak>
标记是所有Amazon Polly SSML文本的根元素。所有 要使用的SSML增强文本必须包含在此标记中。
希望它有所帮助。
答案 1 :(得分:0)
看起来我只需要添加'TextType': 'ssml'
参数。此外,整个字符串需要包含在<speak></speak>
标记中,暂停在这些标记之间。
答案 2 :(得分:0)
Amazon Polly界面还提供SSML - 以及纯文本 (以及C#和API支持和CLI。) 最简单的方法是输入SSML窗口,这里:
1.7秒延迟示例:
<speak>This is the first episode in the MP3 AWS Architect. exam series. <break time="1.7s"/> EC two, exam tips, Part 1.</speak>
五秒差距示例(四舍五入)同样有效:
<speak>This is the second episode in the MP3 AWS Architect. exam series. <break time="5s"/> EC two, exam tips, Part 2.</speak>