Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何使用aws polly api对网页进行tts并保存在aws s3中_Node.js_Amazon Web Services_Amazon Polly - Fatal编程技术网

Node.js 如何使用aws polly api对网页进行tts并保存在aws s3中

Node.js 如何使用aws polly api对网页进行tts并保存在aws s3中,node.js,amazon-web-services,amazon-polly,Node.js,Amazon Web Services,Amazon Polly,我试图让AWS Polly保存URL内容的mp3音频转录。我试过几个预先制作好的脚本,但似乎都不管用 这是我的目标蓝图: (1) lambda函数 -调用polly api StartSpeechsSynthesisTask -将URL的内容用作文本 -在s3中保存音频文件 这是我在Lambda试过的 var request = require("request"); request({uri: "https://www.canalmeio.com.br/ultima-edicao/"}, /

我试图让AWS Polly保存URL内容的mp3音频转录。我试过几个预先制作好的脚本,但似乎都不管用

这是我的目标蓝图: (1) lambda函数 -调用polly api StartSpeechsSynthesisTask -将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文件。

您好,欢迎来到stackoverflow

似乎您有一些语法错误(特别是在
参数
中)+您需要包装
polly。在请求的回调中启动SpeechSynthesisTask
,因为您依赖于请求的响应

根据您最初的帖子,我假设您正在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';
        });
    });
};


免责声明:未经测试大家好,欢迎来到stackoverflow

似乎您有一些语法错误(特别是在
参数
中)+您需要包装
polly。在请求的回调中启动SpeechSynthesisTask
,因为您依赖于请求的响应

根据您最初的帖子,我假设您正在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';
        });
    });
};

免责声明:未经测试