PHP Script – Text to Speech using Google API

In this tutorial we are going to see how to a do a Text to Speech PHP Script using Google Speech API. Its pretty easy and very good If you want to have a ‘Text to Speech’ functionality in your website.

Lets see which Google API helps us for that:

The above URL is the one we are going to use. All we have to do is just pass the text to query string ?q=your+text

Run this URL in browser and you will know how it works (Please use Chrome/Firefox/Latest IE )

Here is the entire script to play around. And more over I have given a DEMO and DOWNLOAD link at the bottom of this post.

Just read the comments in the script, you will be able to understand the script. This script actually get the content from the Google API and store it as a MP3 file in a folder (audio). Make sure audio folder is writable.

I have used HTML5 Player in this script which works only in Modern Browsers. You can use any other Player which can be able to Play MP3 file.

 

Here is the DEMO and DOWNLOAD for you:

DemoDownload

5 Comments

Add a Comment

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