Using Google TTS as an audio.src
Jan 11, 2023
By
Ron Linder
Is there a way to get an audio to play inside a slide via JScript using an external source such as google TTS?
i.e.:
audio.src='https://translate.google.com.vn/translate_tts?ie=UTF-8&q=Hello+World+&tl=en&client=tw-ob';
audio.play();
I am trying to make the string part dynamic, something like this:
var strings = "Hello how are you".split(" ");
var index = 1;
audio.src='http://translate.google.com/translate_tts?&tl=en&q=' + strings[0];
audio.play();
audio.onended = function() {
if(index < strings.length){
audio.src='http://translate.google.com/translate_tts?&tl=en&q=' + strings[index];
audio.play();
index++;
}
};
where a variable "strings" can be incorporated into the src.
Be the first to reply