Forum Discussion

RonLinder-4c1a3's avatar
RonLinder-4c1a3
Community Member
2 years ago

Using Google TTS as an audio.src

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.

No RepliesBe the first to reply