Skip to main content

Create an mp3 file from spoken text via the Google TTS (Text-to-Speech) API

Project description

gTTS (Google Text to Speech): a Python interface to Google’s Text to Speech API. Create an mp3 file with the gTTS module or gtts-cli command line utility.

Module

Initialize a new GoogleTTS:

>> from gtts import gTTS >> tts = gTTS(text=’Hello’, lang=’en’) >> tts.save(“hello.mp3”)

Parameters:

  • text is the text to speak to file;
  • lang is the language to speak in. A ISO 639-1 language code supported by the Google Text to Speech API.

Command line utility

Invoke gtts-cli:

gtts-cli –help usage: gtts-cli.py [-h] (-t TEXT | -f FILE) [-l LANG] [–debug] destination

(Ex.) Read the string ‘Hello’ in English to hello.mp3

$ gtts-cli -t “Hello” -l ‘en’ hello.mp3

(Ex.) Read the contents of file ‘hello.txt’ in Czech to hello.mp3:

$ gtts-cli -f hello.txt -l ‘cs’ hello.mp3

Supported Languages

  • ‘af’ : ‘Afrikaans’
  • ‘sq’ : ‘Albanian’
  • ‘ar’ : ‘Arabic’
  • ‘hy’ : ‘Armenian’
  • ‘ca’ : ‘Catalan’
  • ‘zh-CN’ : ‘Mandarin (simplified)’
  • ‘zh-TW’ : ‘Mandarin (traditional)’
  • ‘hr’ : ‘Croatian’
  • ‘cs’ : ‘Czech’
  • ‘da’ : ‘Danish’
  • ‘nl’ : ‘Dutch’
  • ‘en’ : ‘English’
  • ‘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’
  • ‘ro’ : ‘Romanian’
  • ‘ru’ : ‘Russian’
  • ‘sr’ : ‘Serbian’
  • ‘sk’ : ‘Slovak’
  • ‘es’ : ‘Spanish’
  • ‘sw’ : ‘Swahili’
  • ‘sv’ : ‘Swedish’
  • ‘ta’ : ‘Tamil’
  • ‘th’ : ‘Thai’
  • ‘tr’ : ‘Turkish’
  • ‘vi’ : ‘Vietnamese’
  • ‘cy’ : ‘Welsh’

Project details


Release history Release notifications

History Node

2.0.0

History Node

1.2.2

History Node

1.2.1

History Node

1.2.0

History Node

1.1.8

History Node

1.1.7

History Node

1.1.6

History Node

1.1.5

History Node

1.1.4

History Node

1.1.3

History Node

1.1.2

History Node

1.0.7

History Node

1.0.6

History Node

1.0.5

History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

This version
History Node

1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
gTTS-1.0.tar.gz (3.9 kB) Copy SHA256 hash SHA256 Source None May 15, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page