Amazon AWS Polly忽略了VoiceId-Javascript SDK

时间:2018-08-31 18:16:01

标签: aws-sdk amazon-polly

我已经集成了Javascript AWS开发工具包,并在没有服务器的情况下向API发送了请求。一切正常,但问题是,端点“忽略”了VoiceId。

问题:端点始终返回带有VoiceID'Ivy'的mp3。

使用voice例如我发送Justin

JS

   getVoice(text, voice) {

   let awsCredentials = new AWS.Credentials("XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXX");
   let settings = {
       awsCredentials: awsCredentials,
       awsRegion: "us-west-2",
       pollyVoiceId: voice,
       cacheSpeech: false
   }

   AWS.config.credentials = settings.awsCredentials;
   AWS.config.region = settings.awsRegion;

   let speechfile = new Promise(function (successCallback, errorCallback) {
        var polly = new AWS.Polly();
        var params = {
            OutputFormat: 'mp3',
            TextType: "ssml",
            Text: text,
            VoiceId: settings.pollyVoiceId
        }
        polly.synthesizeSpeech(params, function (error, data) {
            if (error) {
                errorCallback(error)
            } else {
                let audiostream = data.AudioStream;
                successCallback(audiostream);
            }
        });
    });
    return speechfile;
 }

1 个答案:

答案 0 :(得分:0)

发现了问题。我不允许在服务中使用var'voice'。

-(UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    //return your preferred orientation 
    return UIInterfaceOrientationMaskPortrait;
}