I am using Bing text to speech api in javascript and generating random numbers for addition. Just for support I wanted to integrate bing text-to-speech to my code but I am not able to find a documentation on microsoft page which says that you can pass dynamic parameter to api. By far it is able to to this:
var bingClientTTS = newBingSpeech.TTSClient("API KEY");
document.getElementById("speakBtn").addEventListener("click", function () {
bingClientTTS.synthesize("5 + 7");
});
But when I do this it gives Type error:
var randomNum1 = getRandom(),
var randomNum2 = getRandom();
total =randomNum1 + randomNum2;
$( "#question" ).text( randomNum1 + " + " + randomNum2 + "=" );
document.getElementById("speakBtn").addEventListener("click", function () {
bingClientTTS.synthesize(randomNum1.value);
});
TypeError: Cannot read property 'encodeHTML' of undefined
Is there any way to pass variable to bing tts api or should I use google tts.
To avoid api calls I have used a javascript client librarygithub link
答案 0 :(得分:0)
If it works with a string, it does not matter how you obtain that string.
Try randomNum1
instead of randomNum1.value
.