Coder Social home page Coder Social logo

muskanmahajan37 / gtts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from salvatoretrimarchi/gtts

0.0 0.0 0.0 64 KB

Module and command line utility to save spoken text to mp3 via the Google Text to Speech (TTS) API

License: MIT License

Shell 1.05% Python 98.95%

gtts's Introduction

#gTTS

gTTS (Google Text to Speech): a Python interface for Google's Text to Speech API. Create an mp3 file with the gTTS module or gtts-cli command line utility. It allows unlimited lengths to be spoken by tokenizing long sentences where the speech would naturally pause.

Build Status

Install

pip install gTTS

Usage

You may either use gTTS as a python module or as a command-line utility

A. Module

1. Import gTTS
>> from gtts import gTTS
2. Create an instance
>> tts = gTTS(text='Hello', lang='en')
Parameters:
  • text - Text to be spoken (written to file instead)
  • lang - ISO 639-1 language code (supported by the Google Text to Speech API) to speak in
3. Write to a file
>> tts.save("hello.mp3")
>> from gtts import gTTS
>> from tempfile import TemporaryFile
>> tts = gTTS(text='Hello', lang='en')
>> f = TemporaryFile()
>> tts.write_to_fp(f)
>> f.close()

B. Command line utility

Command
gtts-cli.py [-h] (["text to speak"] | -f FILE) [-l LANG] [--debug] [-o destination_file]
Example:
$ # Read the string 'Hello' in English to hello.mp3
$ gtts-cli.py "Hello" -l 'en' -o hello.mp3

$ # Read the contents of file 'hello.txt' in Czech to hello.mp3:
$ gtts-cli.py -f hello.txt -l 'cs' -o hello.mp3

$ # Read the string 'Hello' from stdin in English to hello.mp3
$ echo "Hello" | gtts-cli.py -l 'en' -o hello.mp3 -

##Supported Languages

  • 'af' : 'Afrikaans'
  • 'sq' : 'Albanian'
  • 'ar' : 'Arabic'
  • 'hy' : 'Armenian'
  • 'bn' : 'Bengali'
  • 'ca' : 'Catalan'
  • 'zh' : 'Chinese'
  • 'zh-cn' : 'Chinese (Mandarin/China)'
  • 'zh-tw' : 'Chinese (Mandarin/Taiwan)'
  • 'zh-yue' : 'Chinese (Cantonese)'
  • 'hr' : 'Croatian'
  • 'cs' : 'Czech'
  • 'da' : 'Danish'
  • 'nl' : 'Dutch'
  • 'en' : 'English'
  • 'en-au' : 'English (Australia)'
  • 'en-uk' : 'English (United Kingdom)'
  • 'en-us' : 'English (United States)'
  • 'eo' : 'Esperanto'
  • 'fi' : 'Finnish'
  • 'fr' : 'French'
  • 'de' : 'German'
  • 'el' : 'Greek'
  • 'hi' : 'Hindi'
  • 'hu' : 'Hungarian'
  • 'is' : 'Icelandic'
  • 'id' : 'Indonesian'
  • 'it' : 'Italian'
  • 'ja' : 'Japanese'
  • 'ko' : 'Korean'
  • 'la' : 'Latin'
  • 'lv' : 'Latvian'
  • 'mk' : 'Macedonian'
  • 'no' : 'Norwegian'
  • 'pl' : 'Polish'
  • 'pt' : 'Portuguese'
  • 'pt-br' : 'Portuguese (Brazil)'
  • 'ro' : 'Romanian'
  • 'ru' : 'Russian'
  • 'sr' : 'Serbian'
  • 'sk' : 'Slovak'
  • 'es' : 'Spanish'
  • 'es-es' : 'Spanish (Spain)'
  • 'es-us' : 'Spanish (United States)'
  • 'sw' : 'Swahili'
  • 'sv' : 'Swedish'
  • 'ta' : 'Tamil'
  • 'th' : 'Thai'
  • 'tr' : 'Turkish'
  • 'vi' : 'Vietnamese'
  • 'cy' : 'Welsh'

Contributing

  1. Fork pndurette/gTTS on GitHub and clone it locally
  2. Make sure you write tests for new features or modify the existing ones if necessary
  3. Open a new Pull Request from your feature branch to the develop branch.
  4. Thank you!

gtts's People

Contributors

pndurette avatar boudewijn26 avatar dr-horv avatar anselm94 avatar thijstriemstra avatar desbma avatar bakaiadam avatar holzhaus avatar leo-labs avatar wyohknott avatar

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.