【问题标题】:How to use aws polly api to tts a webpage and save in aws s3如何使用aws polly api对网页进行tts并保存在aws s3中
【发布时间】:2019-08-28 05:58:52
【问题描述】:

我正在尝试让 AWS Polly 保存 URL 内容的 mp3 音频转录。我已经尝试了几个预烘焙的脚本,但它们似乎都不起作用。

这是我的目标蓝图: (1) 拉姆达函数 - 调用 polly api StartSpeechSynthesisTask - 用作文本,URL 的内容 - 将音频文件保存在 s3 中

这是我在 Lambda 中尝试过的

var request = require("request");

request({uri: "https://www.canalmeio.com.br/ultima-edicao/"}, /*this is the URL where I pick up the text */
    function(error, response, body) {
    console.log(body);
  });
});

var params = {
  OutputFormat: mp3, 
  OutputS3BucketName: 'BUCKETNAMEXXXX'', 
  Text: console.log, 
  VoiceId: Cristiano, 
  Engine: standard,
  LanguageCode: pt-BR,
  OutputS3KeyPrefix: 'meio',
  SampleRate: '22050',
  TextType: text
};
polly.startSpeechSynthesisTask(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

我希望输出是保存在我的 s3 存储桶中的 MP3 文件。

【问题讨论】:

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


    【解决方案1】:

    您好,欢迎使用 stackoverflow,

    您似乎有一些语法错误(尤其是在params 内)+ 您需要将polly. startSpeechSynthesisTask 包装在请求的回调中,因为您依赖于请求的响应。

    根据您最初的帖子,我假设您在 AWS Lambda 中工作。所以试试下面的

    var request = require('request');
    
    exports.handler = () => {
        request({ uri: 'https://www.canalmeio.com.br/ultima-edicao/' }, function (error, response, body) {
            var params = {
                OutputFormat: 'mp3',
                OutputS3BucketName: 'BUCKETNAMEXXXX',
                Text: body,
                VoiceId: 'Cristiano',
                Engine: 'standard',
                LanguageCode: 'pt-BR',
                OutputS3KeyPrefix: 'meio',
                SampleRate: '22050',
                TextType: 'text'
            };
            polly.startSpeechSynthesisTask(params, function (error) {
                if (error) {
                    throw new Error(error);
                }
                return 'Success';
            });
        });
    };
    
    

    免责声明:未经测试!

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2020-02-18
      • 2020-02-06
      • 1970-01-01
      • 2021-06-29
      • 1970-01-01
      • 2016-11-03
      相关资源
      最近更新 更多