gTTS-1.2.0/0000755000175000017500000000000013074475036013206 5ustar travistravis00000000000000gTTS-1.2.0/bin/0000755000175000017500000000000013074475036013756 5ustar travistravis00000000000000gTTS-1.2.0/bin/gtts-cli0000755000175000017500000000016013074475007015425 0ustar travistravis00000000000000#!/bin/bash DIR="$( cd "$( dirname "$0" )" && pwd )" PYTHON=$(which python) exec $PYTHON $DIR/gtts-cli.py "$@" gTTS-1.2.0/bin/gtts-cli.py0000755000175000017500000000326213074475007016062 0ustar travistravis00000000000000#! /usr/bin/python from __future__ import print_function from gtts import gTTS from gtts import __version__ import sys import argparse import os import codecs def languages(): """Sorted pretty printed string of supported languages""" return ", ".join(sorted("{}: '{}'".format(gTTS.LANGUAGES[k], k) for k in gTTS.LANGUAGES)) # Args desc = "Creates an mp3 file from spoken text via the Google Text-to-Speech API ({v})".format(v=__version__) parser = argparse.ArgumentParser(description=desc, formatter_class=argparse.RawTextHelpFormatter) text_group = parser.add_mutually_exclusive_group(required=True) text_group.add_argument('text', nargs='?', help="text to speak") text_group.add_argument('-f', '--file', help="file to speak") parser.add_argument("-o", '--destination', help="destination mp3 file", action='store') parser.add_argument('-l', '--lang', default='en', help="ISO 639-1/IETF language tag to speak in:\n" + languages()) parser.add_argument('--slow', action="store_true", help="slower read speed") parser.add_argument('--debug', action="store_true") args = parser.parse_args() try: if args.text: if args.text == "-": text = sys.stdin.read() else: text = args.text else: with codecs.open(args.file, "r", "utf-8") as f: text = f.read() # TTSTF (Text to Speech to File) tts = gTTS(text=text, lang=args.lang, slow=args.slow, debug=args.debug) if args.destination: tts.save(args.destination) else: tts.write_to_fp(os.fdopen(sys.stdout.fileno(), "wb")) except Exception as e: if args.destination: print(str(e)) else: print("ERROR: ", e, file=sys.stderr) gTTS-1.2.0/gTTS.egg-info/0000755000175000017500000000000013074475036015521 5ustar travistravis00000000000000gTTS-1.2.0/gTTS.egg-info/PKG-INFO0000644000175000017500000001273513074475036016626 0ustar travistravis00000000000000Metadata-Version: 1.1 Name: gTTS Version: 1.2.0 Summary: Create an mp3 file from spoken text via the Google TTS (Text-to-Speech) API Home-page: https://github.com/pndurette/gTTS Author: Pierre Nicolas Durette Author-email: pndurette@gmail.com License: MIT Description: # 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](https://travis-ci.org/pndurette/gTTS.svg?branch=master)](https://travis-ci.org/pndurette/gTTS) [![PyPI version](https://badge.fury.io/py/gTTS.svg)](https://badge.fury.io/py/gTTS) ## 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', slow=True) ``` ###### _Parameters:_ * `text` - String - Text to be spoken. * `lang` - String - [ISO 639-1 language code](#lang_list) (supported by the Google _Text to Speech_ API) to speak in. * `slow` - Boolean - Speak slowly. Default `False` (Note: only two speeds are provided by the API). ##### 3. Write to a file * _To disk_ using `save(file_name)` ``` >> tts.save("hello.mp3") ``` * _To a file pointer_ using `write_to_fp(file_object)` ``` >> 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] [--slow] [--debug] [-o destination_file] ``` ###### _Example:_ ``` $ # Read the string 'Hello' in English to hello.mp3 $ gtts-cli "Hello" -l 'en' -o hello.mp3 $ # Read the string 'Hello' in English (slow speed) to hello.mp3 $ gtts-cli "Hello" -l 'en' -o hello.mp3 --slow $ # Read the contents of file 'hello.txt' in Czech to hello.mp3: $ gtts-cli -f hello.txt -l 'cs' -o hello.mp3 $ # Read the string 'Hello' from stdin in English to hello.mp3 $ echo "Hello" | gtts-cli -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' * 'km' : 'Khmer (Cambodian)' * 'ko' : 'Korean' * 'la' : 'Latin' * 'lv' : 'Latvian' * 'mk' : 'Macedonian' * 'no' : 'Norwegian' * 'pl' : 'Polish' * 'pt' : 'Portuguese' * 'ro' : 'Romanian' * 'ru' : 'Russian' * 'sr' : 'Serbian' * 'si' : 'Sinhala' * 'sk' : 'Slovak' * 'es' : 'Spanish' * 'es-es' : 'Spanish (Spain)' * 'es-us' : 'Spanish (United States)' * 'sw' : 'Swahili' * 'sv' : 'Swedish' * 'ta' : 'Tamil' * 'th' : 'Thai' * 'tr' : 'Turkish' * 'uk' : 'Ukrainian' * 'vi' : 'Vietnamese' * 'cy' : 'Welsh' ## Contributing 1. _Fork_ [pndurette/gTTS](https://github.com/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 `master` branch. 4. Thank you! Platform: UNKNOWN Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: Unix Classifier: Operating System :: POSIX Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Multimedia :: Sound/Audio :: Speech gTTS-1.2.0/gTTS.egg-info/SOURCES.txt0000644000175000017500000000040013074475036017377 0ustar travistravis00000000000000CHANGELOG.md MANIFEST.in README.md setup.py bin/gtts-cli bin/gtts-cli.py gTTS.egg-info/PKG-INFO gTTS.egg-info/SOURCES.txt gTTS.egg-info/dependency_links.txt gTTS.egg-info/requires.txt gTTS.egg-info/top_level.txt gtts/__init__.py gtts/tts.py gtts/version.pygTTS-1.2.0/gTTS.egg-info/dependency_links.txt0000644000175000017500000000000113074475036021567 0ustar travistravis00000000000000 gTTS-1.2.0/gTTS.egg-info/requires.txt0000644000175000017500000000003013074475036020112 0ustar travistravis00000000000000six requests gtts_token gTTS-1.2.0/gTTS.egg-info/top_level.txt0000644000175000017500000000000513074475036020246 0ustar travistravis00000000000000gtts gTTS-1.2.0/gtts/0000755000175000017500000000000013074475036014167 5ustar travistravis00000000000000gTTS-1.2.0/gtts/__init__.py0000644000175000017500000000006713074475007016301 0ustar travistravis00000000000000from .version import __version__ from .tts import gTTS gTTS-1.2.0/gtts/tts.py0000644000175000017500000001436413074475007015361 0ustar travistravis00000000000000# -*- coding: utf-8 -*- import re, requests, warnings from six.moves import urllib from requests.packages.urllib3.exceptions import InsecureRequestWarning from gtts_token.gtts_token import Token class gTTS: """ gTTS (Google Text to Speech): an interface to Google's Text to Speech API """ # Google TTS API supports two read speeds # (speed <= 0.3: slow; speed > 0.3: normal; default: 1) class Speed: SLOW = 0.3 NORMAL = 1 GOOGLE_TTS_URL = 'https://translate.google.com/translate_tts' MAX_CHARS = 100 # Max characters the Google TTS API takes at a time 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', 'km' : 'Khmer (Cambodian)', 'ko' : 'Korean', 'la' : 'Latin', 'lv' : 'Latvian', 'mk' : 'Macedonian', 'no' : 'Norwegian', 'pl' : 'Polish', 'pt' : 'Portuguese', 'ro' : 'Romanian', 'ru' : 'Russian', 'sr' : 'Serbian', 'si' : 'Sinhala', 'sk' : 'Slovak', 'es' : 'Spanish', 'es-es' : 'Spanish (Spain)', 'es-us' : 'Spanish (United States)', 'sw' : 'Swahili', 'sv' : 'Swedish', 'ta' : 'Tamil', 'th' : 'Thai', 'tr' : 'Turkish', 'uk' : 'Ukrainian', 'vi' : 'Vietnamese', 'cy' : 'Welsh' } def __init__(self, text, lang = 'en', slow = False, debug = False): self.debug = debug if lang.lower() not in self.LANGUAGES: raise Exception('Language not supported: %s' % lang) else: self.lang = lang.lower() if not text: raise Exception('No text to speak') else: self.text = text # Read speed if slow: self.speed = self.Speed().SLOW else: self.speed = self.Speed().NORMAL # Split text in parts if self._len(text) <= self.MAX_CHARS: text_parts = [text] else: text_parts = self._tokenize(text, self.MAX_CHARS) # Clean def strip(x): return x.replace('\n', '').strip() text_parts = [strip(x) for x in text_parts] text_parts = [x for x in text_parts if len(x) > 0] self.text_parts = text_parts # Google Translate token self.token = Token() def save(self, savefile): """ Do the Web request and save to `savefile` """ with open(savefile, 'wb') as f: self.write_to_fp(f) def write_to_fp(self, fp): """ Do the Web request and save to a file-like object """ for idx, part in enumerate(self.text_parts): payload = { 'ie' : 'UTF-8', 'q' : part, 'tl' : self.lang, 'ttsspeed' : self.speed, 'total' : len(self.text_parts), 'idx' : idx, 'client' : 'tw-ob', 'textlen' : self._len(part), 'tk' : self.token.calculate_token(part)} headers = { "Referer" : "http://translate.google.com/", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" } if self.debug: print(payload) try: # Disable requests' ssl verify to accomodate certain proxies and firewalls # Filter out urllib3's insecure warnings. We can live without ssl verify here with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=InsecureRequestWarning) r = requests.get(self.GOOGLE_TTS_URL, params=payload, headers=headers, proxies=urllib.request.getproxies(), verify=False) if self.debug: print("Headers: {}".format(r.request.headers)) print("Request url: {}".format(r.request.url)) print("Response: {}, Redirects: {}".format(r.status_code, r.history)) r.raise_for_status() for chunk in r.iter_content(chunk_size=1024): fp.write(chunk) except Exception as e: raise def _len(self, text): """ Get char len of `text`, after decoding if Python 2 """ try: # Python 2 return len(text.decode('utf8')) except AttributeError: # Python 3 return len(text) def _tokenize(self, text, max_size): """ Tokenizer on basic roman punctuation """ punc = "¡!()[]¿?.,;:—«»\n" punc_list = [re.escape(c) for c in punc] pattern = '|'.join(punc_list) parts = re.split(pattern, text) min_parts = [] for p in parts: min_parts += self._minimize(p, " ", max_size) return min_parts def _minimize(self, thestring, delim, max_size): """ Recursive function that splits `thestring` in chunks of maximum `max_size` chars delimited by `delim`. Returns list. """ if self._len(thestring) > max_size: idx = thestring.rfind(delim, 0, max_size) return [thestring[:idx]] + self._minimize(thestring[idx:], delim, max_size) else: return [thestring] if __name__ == "__main__": pass gTTS-1.2.0/gtts/version.py0000644000175000017500000000002613074475007016222 0ustar travistravis00000000000000__version__ = '1.2.0' gTTS-1.2.0/CHANGELOG.md0000644000175000017500000001125413074475007015020 0ustar travistravis00000000000000# Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). This file adheres to [Keep a CHANGELOG](http://keepachangelog.com). ## [Unreleased] ## [1.2.0] - 2017-04-15 ### Added - Option for slower read speed (`slow=True` for `gTTS()`, `--slow` for `gtts-cli`) - System proxy settings are passed transparently to all http requests - Language: 'km', 'Khmer (Cambodian)' - Language: 'si', 'Sinhala' - Language: 'uk', 'Ukrainian' - More debug output ### Removed - Language: 'pt-br' : 'Portuguese (Brazil)' (it was the same as 'pt' and not Brazilian) ### Fixed - The text to read is now cut in proper chunks in Python 2 unicode. This broke reading for many languages such as Russian. - Disabled SSL verify on http requests to accommodate certain firewalls and proxies. - Better Python 2/3 support in general - Various fixes and cleanups ## [1.1.8] - 2017-01-15 ### Added - Added stdin support (w/ `text` set to `-`) to `gtts-cli.py`/`gtts-cli` (#56 thanks @WyohKnott) ## [1.1.7] - 2016-12-14 ### Changed - Added utf-8 support to `gtts-cli.py`/`gtts-cli` (#52 thanks @bakaiadam) ## [1.1.6] - 2016-07-20 ### Added - 'bn' : 'Bengali' (thanks @sakibiqbal, @mshubhankar) ### Removed - 'ht' : 'Haitian Creole' (removed by Google) - 'token-script.js' (clean up) ## [1.1.5] - 2016-05-13 ### Fixed - Fixed HTTP 403s by updating the client argument to reflect new API usage ## [1.1.4] - 2016-02-22 ### Changed - Token calculation moved to now spun-off module [gTTS-Token](https://github.com/Boudewijn26/gTTS-token) maintained by @Boudewijn26 ## [1.1.3] - 2016-01-24 ### Added - Contributing section to README.md, ### Changed - Better CHANGELOG.md replacing CHANGES.txt ### Fixed - Made `gtts-cli` work w/ Python 3.x, from @desbma - Handle non-ASCII chars correctly (a wrong token would get generated resulting in a HTTP 403), from @Boudewijn26, h/t @desbma ### Removed - Dropped Python 3.2 support and in .travis.yml ## [1.1.2] - 2016-01-13 - Packaging and Travis CI changes ## 1.1.1 - 2016-01-13 [YANKED] ### Changed - Packaging and Travis CI changes ## [1.1.0] - 2016-01-13 [YANKED] ### Added - Google Translate API token (`tk`) generation like translate.google.com to fix the constant HTTP 403 errors (for now), from @Boudewijn26 ## [1.0.7] - 2015-10-07 ### Changed - `gtts-cli` can be piped, arguments made more standard, from @Dr-Horv. ## [1.0.6] - 2015-07-30 ### Added: - Raise an exception on bad HTTP response (4xx or 5xx). ### Fixed - New required 'client=t' parameter for the api HTTP request, h/t @zainkhan_ on Twitter. ## [1.0.5] - 2015-07-15 ### Added: - Option to use `write_to_fp()` to write to a file-like object instead of only to a file, from @Holzhaus. ## [1.0.4] - 2015-05-11 ### Added - `gtts-cli` shows the version and pretty printed and sorted available languages. - `zh-yue` : 'Chinese (Cantonese)'. - `en-uk` : 'English (United Kingdom)'. - `pt-br` : 'Portuguese (Brazil)'. - `es-es` : 'Spanish (Spain)'. - `es-us` : 'Spanish (United StateS)' ## Changed - Language code are now case insensitive. - Same voices but renamed for uniformity, better description: - `zh-CN` : 'Mandarin (simplified)' is now `zh-cn` : 'Chinese (Mandarin/China)'. - `zh-TW` : 'Mandarin (traditional)' is now `zh-tw` : 'Chinese (Mandarin/Taiwan)'. ## [1.0.3] - 2014-11-21 ### Added - 'en-us' : 'English (United States)' from @leo-labs. - 'en-au' : 'English (Australia)'. from @leo-labs. ## [1.0.2] - 2014-05-15 ### Changed - Python 3.x support. ## 1.0.1 - 2014-05-15 [YANKED] ### Added - Travis CI changes - Following [SemVer](http://semver.org/). ## 1.0 - 2014-05-08 ### Added - Initial release [Unreleased]: https://github.com/pndurette/gTTS/compare/v1.2.0...master [1.2.0]: https://github.com/pndurette/gTTS/compare/v1.1.8...v1.2.0 [1.1.8]: https://github.com/pndurette/gTTS/compare/v1.1.7...v1.1.8 [1.1.7]: https://github.com/pndurette/gTTS/compare/v1.1.6...v1.1.7 [1.1.6]: https://github.com/pndurette/gTTS/compare/v1.1.5...v1.1.6 [1.1.5]: https://github.com/pndurette/gTTS/compare/v1.1.4...v1.1.5 [1.1.4]: https://github.com/pndurette/gTTS/compare/v1.1.3...v1.1.4 [1.1.3]: https://github.com/pndurette/gTTS/compare/v1.1.2...v1.1.3 [1.1.2]: https://github.com/pndurette/gTTS/compare/v1.1.0...v1.1.2 [1.1.0]: https://github.com/pndurette/gTTS/compare/v1.0.7...v1.1.0 [1.0.7]: https://github.com/pndurette/gTTS/compare/v1.0.6...v1.0.7 [1.0.6]: https://github.com/pndurette/gTTS/compare/v1.0.5...v1.0.6 [1.0.5]: https://github.com/pndurette/gTTS/compare/v1.0.4...v1.0.5 [1.0.4]: https://github.com/pndurette/gTTS/compare/v1.0.3...v1.0.4 [1.0.3]: https://github.com/pndurette/gTTS/compare/v1.0.2...v1.0.3 [1.0.2]: https://github.com/pndurette/gTTS/compare/v1.0...v1.0.2 gTTS-1.2.0/MANIFEST.in0000644000175000017500000000004713074475007014743 0ustar travistravis00000000000000include README.md include CHANGELOG.md gTTS-1.2.0/README.md0000644000175000017500000000672613074475007014476 0ustar travistravis00000000000000# 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](https://travis-ci.org/pndurette/gTTS.svg?branch=master)](https://travis-ci.org/pndurette/gTTS) [![PyPI version](https://badge.fury.io/py/gTTS.svg)](https://badge.fury.io/py/gTTS) ## 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', slow=True) ``` ###### _Parameters:_ * `text` - String - Text to be spoken. * `lang` - String - [ISO 639-1 language code](#lang_list) (supported by the Google _Text to Speech_ API) to speak in. * `slow` - Boolean - Speak slowly. Default `False` (Note: only two speeds are provided by the API). ##### 3. Write to a file * _To disk_ using `save(file_name)` ``` >> tts.save("hello.mp3") ``` * _To a file pointer_ using `write_to_fp(file_object)` ``` >> 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] [--slow] [--debug] [-o destination_file] ``` ###### _Example:_ ``` $ # Read the string 'Hello' in English to hello.mp3 $ gtts-cli "Hello" -l 'en' -o hello.mp3 $ # Read the string 'Hello' in English (slow speed) to hello.mp3 $ gtts-cli "Hello" -l 'en' -o hello.mp3 --slow $ # Read the contents of file 'hello.txt' in Czech to hello.mp3: $ gtts-cli -f hello.txt -l 'cs' -o hello.mp3 $ # Read the string 'Hello' from stdin in English to hello.mp3 $ echo "Hello" | gtts-cli -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' * 'km' : 'Khmer (Cambodian)' * 'ko' : 'Korean' * 'la' : 'Latin' * 'lv' : 'Latvian' * 'mk' : 'Macedonian' * 'no' : 'Norwegian' * 'pl' : 'Polish' * 'pt' : 'Portuguese' * 'ro' : 'Romanian' * 'ru' : 'Russian' * 'sr' : 'Serbian' * 'si' : 'Sinhala' * 'sk' : 'Slovak' * 'es' : 'Spanish' * 'es-es' : 'Spanish (Spain)' * 'es-us' : 'Spanish (United States)' * 'sw' : 'Swahili' * 'sv' : 'Swedish' * 'ta' : 'Tamil' * 'th' : 'Thai' * 'tr' : 'Turkish' * 'uk' : 'Ukrainian' * 'vi' : 'Vietnamese' * 'cy' : 'Welsh' ## Contributing 1. _Fork_ [pndurette/gTTS](https://github.com/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 `master` branch. 4. Thank you! gTTS-1.2.0/setup.py0000644000175000017500000000245713074475007014726 0ustar travistravis00000000000000try: from setuptools import setup except ImportError: from distutils.core import setup exec(open('gtts/version.py').read()) setup( name='gTTS', version=__version__, author='Pierre Nicolas Durette', author_email='pndurette@gmail.com', url='https://github.com/pndurette/gTTS', packages=['gtts'], scripts=['bin/gtts-cli', 'bin/gtts-cli.py'], license='MIT', description='Create an mp3 file from spoken text via the Google TTS (Text-to-Speech) API', long_description=open('README.md').read(), install_requires=[ "six", "requests", "gtts_token" ], classifiers=[ 'Environment :: Console', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Operating System :: MacOS :: MacOS X', 'Operating System :: Unix', 'Operating System :: POSIX', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Topic :: Software Development :: Libraries', 'Topic :: Multimedia :: Sound/Audio :: Speech' ], ) gTTS-1.2.0/PKG-INFO0000644000175000017500000001273513074475036014313 0ustar travistravis00000000000000Metadata-Version: 1.1 Name: gTTS Version: 1.2.0 Summary: Create an mp3 file from spoken text via the Google TTS (Text-to-Speech) API Home-page: https://github.com/pndurette/gTTS Author: Pierre Nicolas Durette Author-email: pndurette@gmail.com License: MIT Description: # 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](https://travis-ci.org/pndurette/gTTS.svg?branch=master)](https://travis-ci.org/pndurette/gTTS) [![PyPI version](https://badge.fury.io/py/gTTS.svg)](https://badge.fury.io/py/gTTS) ## 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', slow=True) ``` ###### _Parameters:_ * `text` - String - Text to be spoken. * `lang` - String - [ISO 639-1 language code](#lang_list) (supported by the Google _Text to Speech_ API) to speak in. * `slow` - Boolean - Speak slowly. Default `False` (Note: only two speeds are provided by the API). ##### 3. Write to a file * _To disk_ using `save(file_name)` ``` >> tts.save("hello.mp3") ``` * _To a file pointer_ using `write_to_fp(file_object)` ``` >> 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] [--slow] [--debug] [-o destination_file] ``` ###### _Example:_ ``` $ # Read the string 'Hello' in English to hello.mp3 $ gtts-cli "Hello" -l 'en' -o hello.mp3 $ # Read the string 'Hello' in English (slow speed) to hello.mp3 $ gtts-cli "Hello" -l 'en' -o hello.mp3 --slow $ # Read the contents of file 'hello.txt' in Czech to hello.mp3: $ gtts-cli -f hello.txt -l 'cs' -o hello.mp3 $ # Read the string 'Hello' from stdin in English to hello.mp3 $ echo "Hello" | gtts-cli -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' * 'km' : 'Khmer (Cambodian)' * 'ko' : 'Korean' * 'la' : 'Latin' * 'lv' : 'Latvian' * 'mk' : 'Macedonian' * 'no' : 'Norwegian' * 'pl' : 'Polish' * 'pt' : 'Portuguese' * 'ro' : 'Romanian' * 'ru' : 'Russian' * 'sr' : 'Serbian' * 'si' : 'Sinhala' * 'sk' : 'Slovak' * 'es' : 'Spanish' * 'es-es' : 'Spanish (Spain)' * 'es-us' : 'Spanish (United States)' * 'sw' : 'Swahili' * 'sv' : 'Swedish' * 'ta' : 'Tamil' * 'th' : 'Thai' * 'tr' : 'Turkish' * 'uk' : 'Ukrainian' * 'vi' : 'Vietnamese' * 'cy' : 'Welsh' ## Contributing 1. _Fork_ [pndurette/gTTS](https://github.com/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 `master` branch. 4. Thank you! Platform: UNKNOWN Classifier: Environment :: Console Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: MacOS :: MacOS X Classifier: Operating System :: Unix Classifier: Operating System :: POSIX Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Multimedia :: Sound/Audio :: Speech gTTS-1.2.0/setup.cfg0000644000175000017500000000007313074475036015027 0ustar travistravis00000000000000[egg_info] tag_svn_revision = 0 tag_build = tag_date = 0