【问题标题】:Add 1s delay to end of Polly MP3 Conversion在 Polly MP3 转换结束时添加 1s 延迟
【发布时间】:2018-02-12 15:33:48
【问题描述】:

我正在使用 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!")
            })
        }
    }
})

【问题讨论】:

    标签: node.js amazon-web-services amazon-polly


    【解决方案1】:

    看起来我只需要添加'TextType': 'ssml' 参数。此外,整个字符串需要包含在 <speak></speak> 标记中,并且在它们之间有停顿。

    【讨论】:

      【解决方案2】:

      我认为你应该在SSML Tags in Amazon Polly documentation 上查看break section

      let params = {
          'Text': `
              This is the string I'm converting to MP3
              <break strength="medium"></break>
          ` ,
          'OutputFormat': 'mp3',
          'VoiceId': 'Kimberly'
      };
      

      编辑

      也许您还必须在 &lt;speak&gt; 标记中包含所有文本?

      文档说:

      &lt;speak&gt; 标签是所有 Amazon Polly SSML 文本的根元素。全部 要朗读的 SSML 增强文本必须包含在此标记中。

      希望对你有帮助。

      【讨论】:

      • 我试过了,Polly 实际上用语言表达“断裂强度等于中等......”。
      【解决方案3】:

      Amazon Polly 界面还提供 SSML - 以及纯文本 (以及 C# 和 API 支持和 CLI。) 最简单的方法是在 SSML 窗口中输入:

      1.7 秒延迟示例: &lt;speak&gt;This is the first episode in the MP3 AWS Architect. exam series. &lt;break time="1.7s"/&gt; EC two, exam tips, Part 1.&lt;/speak&gt;

      五秒间隔示例(四舍五入)同样适用: &lt;speak&gt;This is the second episode in the MP3 AWS Architect. exam series. &lt;break time="5s"/&gt; EC two, exam tips, Part 2.&lt;/speak&gt;

      【讨论】:

        猜你喜欢
        • 2016-05-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多