Open sgasser opened 7 years ago
That would be an excellent addition, thank you!
This would be great. Were you able to do it? Alternatively, is there a way to adjust a setting to use ssml/etc. Thanks!
I was able to add SSML support by adding the following single line of code. Currently this is non-selectable:
// Make request to Amazon polly
function requestSpeechFromAWS(message) {
return new Promise(function (successCallback, errorCallback) {
var polly = new AWS.Polly();
var params = {
OutputFormat: 'mp3',
Text: message,
VoiceId: settings.pollyVoiceId,
TextType: 'ssml' // ADD THIS LINE
}
polly.synthesizeSpeech(params, function (error, data) {
if (error) {
errorCallback(error)
} else {
saveSpeechToLocalCache(message, data.AudioStream);
successCallback(data.AudioStream);
}
});
});
}
To make this selectable could you just parameterize the TextType into the function like this, requestSpeechFromAWS(message, textType="text") //to default to text unless otherwise stated?
I have added a PR to enable SSML support by default. It does not break existing code but now you can easily add the common SSML tags supported by Polly.
SSML not working: http://docs.aws.amazon.com/polly/latest/dg/ssml-to-speech-console.html
kathy.Speak('<speak>He was caught up in the game.<break time="1s"/> In the middle of the 10/3/2014 <sub alias="World Wide Web Consortium">W3C</sub> meeting he shouted, "Score!" quite loudly. When his boss stared at him, he repeated <amazon:effect name="whispered">"Score"</amazon:effect> in a whisper.</speak>');
On line 111 the TextType has to be set: `` Text: message,
TextType: 'ssml',
VoiceId: settings.pollyVoiceId ``
I will add a PR with a regex to check if message is ssml and set TextType to ssml.