in lib/main.js [960:992]
function speakDetectedTextFromWebcam(detectedText, language) {
setLanguage();
var voiceId = pollyVoiceMap.get(language);
// Create the JSON parameters for getSynthesizeSpeechUrl
var speechParams = {
OutputFormat: "mp3",
SampleRate: "16000",
Text: "",
TextType: "text",
VoiceId: voiceId,
Engine: "standard"
};
if (pollyNeuralVoices.includes(voiceId))
speechParams.Engine = "neural";
speechParams.Text = detectedText;
// Create the Polly service object and presigner object
var polly = new AWS.Polly({ apiVersion: "2016-06-10" });
var signer = new AWS.Polly.Presigner(speechParams, polly);
// Create presigned URL of synthesized speech file
signer.getSynthesizeSpeechUrl(speechParams, function (error, url) {
if (error) {
console.log(error);
} else {
document.getElementById("audioSource").src = url;
document.getElementById("audioPlayback").load();
}
});
}