I just launched a new course on ES6! Use the code WESBOS for $10 off.

Strengthen your core JavaScript skills and master all that ES6 has to offer. Start Now →

Easy JavaScript text-to-speech with google translate

Hey everyone – a little trick here today with the HTML5 audio element and the Google translate API.

Turns out you can use this query string to dynamically create an audio element. We can then encode our text, pop that url into an audio element and play it with a few lines of JavaScript.

It’s worth noting that this isn’t the real way to do text to speech, but its a very simple, cross browser solution that can help you out in a pinch.

Here is a quick video detailing how it works – I’d love to see what you all do with this.

This entry was posted in HTML5, JavaScript, Other. Bookmark the permalink.

One Response to Easy JavaScript text-to-speech with google translate

  1. vishnu says:

    I tried with the same code as described in the video. But it is not working at all.

Leave a Reply

Your email address will not be published. Required fields are marked *