Code Monkey home page Code Monkey logo

google-text-to-speech's Introduction

Google-Text-To-Speech

A python script for using Google's text to speech feature to save text to an MP3 file.

usage: GoogleTextToSpeech.py [-h] [-o [OUTPUT]] [-l [LANGUAGE]]
                    (-f FILE | -s STRING [STRING ...])

Google Text To Speech.

optional arguments:
  -h, --help            show this help message and exit
  -o [OUTPUT], --output [OUTPUT]
                        Filename to output audio to
  -l [LANGUAGE], --language [LANGUAGE]
                        Language to output text to.
  -f FILE, --file FILE  File to read text from.
  -s STRING [STRING ...], --string STRING [STRING ...]
                        A string of text to convert to speech.
  -p, --play            Play the speech if your computer allows it.

Examples

To convert text from a file:

$ python GoogleTextToSpeech.py -f text.txt

To convert text from the commandline:

$ python GoogleTextToSpeech.py -l en -o audio.mp3 -s "hello world"

To convert text and play the mp3 audio

$ python GoogleTextToSpeech.py -l en -s "hello world" -p

Requierments

Audio

To play the mp3 you need to have some packages installed on your system.

Linux

For Linux, the script is using the play command included in the sox package.

In case the sox package is not installed on your system:

$ sudo aptitude install sox

You may also need to install extra packages to gain support for MP3

$ sudo aptitude install libsox-fmt-mp3

Mac

For Mac, the script is using the afplay command which should already been installed on your system.

Thanks

Many thanks to Hung Truong (http://www.hung-truong.com/blog/) who helped me to build this Python script. First for given me the clue to send more than 100 characters for a mp3 and secondly for the Pyhton lessons I learned from his own scripts.

google-text-to-speech's People

Contributors

juliend avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-text-to-speech's Issues

Audio is garbled

Thanks for this GIT! I had orginally used Hung's version, but it seems that both his and your s has the same issue. In all instances, from command line or using a txt file, the mp3 that is returned is garbled. Any suggestions?

Error 503

It gives me an Error 53: service unaviable. Do you know why?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.