我已经集成了我的 Javascript AWS SDK,并在没有服务器的情况下向 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;
}