Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

yatts - yet another text to speech converter (and translator)

Project Description

yatts is a text to speech converter (and translator) using Google’s TTS API

yatts allows you to easily take input from stdin or one or more files, translate input into another language, convert input to audio, and write audio to stdout or a file.

Examples

mpv is used in this example, but any media player capable of reading from stdin should work just fine.

$ echo "Hello, world." | yatts | mpv -

To translate that to French, we would do

$ echo "Hello, world." | yatts --translate-to='fr' | mpv -

The default Language is English (if not changed in the configuration file). To process another language (German in this example), we would do

$ echo "Hallo Welt." | yatts --lang='de' --translate-to='en' | mpv -

Output from yatts can also be written directly to a file

$ echo "Hello, world." | yatts --fout=hello_world.mp3

yatts can also read input from a file or files

yatts inputfile1.txt inputfile2.txt | mpv -
yatts *.txt | mpv -

You can also use yatts directly in your python project.

>>> from yatts.google import TTS
>>> tts = TTS(text='Hello, world.', language='en', translate_to='fr')
>>> tts.save('hello_world.mp3')
>>>
>>> from yatts.google import Translator
>>> translator = Translator(language_from='en', language_to='la')
>>> for tt in translator.translate('Hello, world.'):
...     print tt.text
...     print tt.original_text
...
Salve, universitas.
Hello, world.

Configuration

A config file can be used to avoid having to pass in non-default arguments to yatts. The default location for the config file is ~/.yatts.cfg. If you want to store your file somewhere else, pass in the path to –config.

Here is an example of a config file with all of the currently available options. Lines that start with a “#” are considered comments and are not read by yatts.

language = de
translate_to_lang = fr
http_proxy = http://user:password@localhost:1080

Values passed in as an argument to yatts will override settings in the config file.

Arguments

usage: yatts.py [-h] [-f FOUT] [-l LANG] [--tt TRANSLATE_TO_LANG] [--lc]
                [--http-proxy HTTP_PROXY] [--config CONFIG_FILE]
                [file [file ...]]

yatts - yet another text to speech converter (and translator) using Google's
TTS API

positional arguments:
  file                  input file to be processed. if - or empty, stdin will
                        be read (default: ['-'])

optional arguments:
  -h, --help            show this help message and exit
  -f FOUT, --fout FOUT  name of output file. if None, data is written to
                        stdout (default: None)
  -l LANG, --lang LANG, --language LANG
                        Language code (see --language-codes for a complete
                        list) (default: None)
  --tt TRANSLATE_TO_LANG, --translate-to TRANSLATE_TO_LANG
                        Language to translate to (default: None)
  --lc, --language-codes
                        display a full list of language codes (default: False)
  --http-proxy HTTP_PROXY
                        http proxy to route traffic through.
                        http://[user:password@]proxyhost:port (default: None)
  --config CONFIG_FILE  path to config file (default: ~/.yatts.cfg)

Installation

pip install yatts

Supported Languages

Languages with TTS Support

code   language
====== ========
af     Afrikaans
sq     Albanian
ar     Arabic
hy     Armenian
ca     Catalan
zh-yue Chinese (Cantonese)
zh-cn  Chinese (Simplified)
zh-tw  Chinese (Traditional)
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
ht     Haitian Creole
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

Languages with Text Translatation Support

code   language
====== ========
az     Azerbaijani
eu     Basque
be     Belarusian
bn     Bengali
bs     Bosnian
bg     Bulgarian
ceb    Cebuano
ny     Chichewa
et     Estonian
tl     Filipino
gl     Galician
ka     Georgian
gu     Gujarati
ha     Hausa
iw     Hebrew
hmn    Hmong
ig     Igbo
ga     Irish
jw     Javanese
kn     Kannada
kk     Kazakh
km     Khmer
lo     Lao
lt     Lithuanian
mg     Malagasy
ms     Malay
ml     Malayalam
mt     Maltese
mi     Maori
mr     Marathi
mn     Mongolian
my     Myanmar (Burmese)
ne     Nepali
fa     Persian
pa     Punjabi
st     Sesotho
si     Sinhala
sl     Slovenian
so     Somali
su     Sundanese
tg     Tajik
te     Telugu
uk     Ukrainian
ur     Urdu
uz     Uzbek
yi     Yiddish
yo     Yoruba
zu     Zulu

Release History

0.2.3 (2015-08-27)

  • Updated available languages
  • Added to tests to make sure all languages can be downloaded
  • General cleanup and restructuring

0.2.2 (2015-08-23)

  • Added save method to TTS to make saving audio to file easier
  • Updated list of supported TTS languages

0.2.1 (2015-07-15)

  • Fixed bug where too many args were being passed to TranslatedText

0.2.0 (2015-06-21)

  • Added support for translating input into another language
  • Moved TTS logic into the google module to allow for easier reuse by others
  • Added support for buffering the downloading of audio segments to avoid delays in playback

0.1.5 (2015-04-30)

  • Added support for connecting through an HTTP proxy

0.1.4 (2015-04-26)

  • Updated available languages

0.1.3 (2015-04-24)

  • Added a config file option to store default language

0.1.2 (2015-04-23)

  • Minor bug and formatting fixes

0.1.2 (2015-04-23)

  • Python 3.4 compatibility
  • tox testing support

Bugfixes

  • Fixed import error of nltk in test_yatts.py

0.1.1 (2015-04-22)

Bugfixes

  • Added MANIFEST.in so that all files will be included

0.1.0 (2015-04-22)

  • First Release
Release History

Release History

This version
History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

History Node

0.2.0

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
yatts-0.2.3.tar.gz (11.3 kB) Copy SHA256 Checksum SHA256 Source Aug 27, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting