Friday 25 July 2014

Convert text via Google to voice using Jquery and PHP

This tutorial teaches you how to convert Text To Speech via Google API using Jquery and PHP.

The system sends a HTTP GET request to Google Speech URL that does the conversion of text to an MP3 audio file as an out put.

Below is a sample URL through which the request to Google is made.

http://translate.google.com/translate_tts?ie=UTF-8&q=The text to convert&tl=en&total=4&textlen=19

Explanation for the above URL is shown below:

(1) ie -> This is the encoding format used. The default as seen in the URL above is: UTF-8
(2) q -> This is the query string. URL encoding is a necessity for this field especially when the string contains special characters.
(3) tl -> This is the language to which the conversion will be done. This means the mp3 audio file will be read in this language. You can get the list of Google supported languages here https://developers.google.com/translate/v2/using_rest#language-params
(4) total -> This is the total of words to be converted.
(5) textlen -> This is the lenghth of text to be converted. The maximum is 100 characters.


No comments:

Post a Comment