Google's Text to Speech API : A PHP Wrapper Class

It’s really amazing how Google is providing cool APIs for every this and that! And here comes another one that impressed me 😀 I am talking about the Text To Speech API by Google. It’s fantastic! I wrote a php wrapper class that would help you create mp3 files from texts 🙂 Of course, using Google as the medium!

Here’s the source code:

And here’s demo :

You can alternatively pass the text to the constructor of the object like this:

That is simple, isn’t that? Hope you like it!


31 Comments Google's Text to Speech API : A PHP Wrapper Class

  1. Pingback: Twitted by masnun

  2. Pingback: Tweets that mention Google’s Text to Speech API : A PHP Wrapper Class | maSnun.com -- Topsy.com

  3. Pingback: Google's Text to Speech API : A PHP Wrapper Class | maSnun.com | Coder Online

  4. Fabio

    Hello, if i would speech a text without limit of 100 char, how can i split the text and speech all one next another?

    Let me know plz and sorry for my english.

    Reply
  5. Fabio

    Yes, my problem is how execute one after another the link that i have created.

    how do I know when the execution of the first link is completed to start the second?

    Thanks

    Reply
  6. bhawika

    i have modified this so it can support French, but when i tried to add some unique character in French like “Et vous êtes?” it won’t working correctly.. it sounds weird..

    Reply
  7. Pingback: Anonymous

  8. Pingback: Create Text to speech using Google service | Little Tech World

  9. Dale Hay

    They haven’t blocked it, you just need to include the variable “tl=en” within the address.

    So instead of it being:
    file_get_contents("http://translate.google.com/translate_tts?q={$text}");

    You will have to use:
    file_get_contents("http://translate.google.com/translate_tts?tl=en&q={$text}");

    That should work. 🙂

    Reply
  10. imran

    assalamualekum ,

    can you please tell me how we convert our text to voice carrying more than 100 strings can you please help me with a proper procedure on it .

    thankyou

    Reply
  11. Rizwan

    ( ! ) Parse error: syntax error, unexpected ‘World’ (T_STRING) in C:\wamp\www\t2s\index.php on line 5
    This gives an error. Please find some solution as soon as possible.

    Reply

Leave a Reply

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