I've integrated my Javascript AWS SDK and send a request without a server to the API. Everything works fine but the problem is, the endpoint 'ignores' the VoiceId.
Problem: The endpoints allways returns a mp3 with the VoiceID 'Ivy'.
With voice
for e.g. I send 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;
}
Found the issue. I´m not allowed the var 'voice' in my service.
getVoice(text, currentVoice) {
let voi = currentVoice;
let awsCredentials = new AWS.Credentials("xxxxxxxxxx", "xxxxxxxx");
let settings = {
awsCredentials: awsCredentials,
awsRegion: "us-west-1",
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 = {
LanguageCode: "en-US",
OutputFormat: 'mp3',
TextType: "ssml",
Text: text,
VoiceId: voi
}
polly.synthesizeSpeech(params, function (error, data) {
if (error) {
errorCallback(error)
} else {
//alert(text + data.AudioStream);
let audiostream = data.AudioStream;
successCallback(audiostream);
}
});
});
return speechfile;
// end getVoice
}