Skip to main content
#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)

## 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](#lang_list) (supported by the Google _Text to Speech_ API) to speak in

##### 3. Write to a file

* Using [`save(file_name)`](https://github.com/pndurette/gTTS/blob/master/gtts/tts.py#L91)

```
>> tts.save("hello.mp3")
```

* Using [`write_to_fp(file_object)`](https://github.com/pndurette/gTTS/blob/master/gtts/tts.py#L97)

```
>> 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
```

##Supported Languages<a name="lang_list"></a>

* '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](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 `develop` branch.
4. Thank you!

Release files for gTTS 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gTTS 1.1.6
File Size Uploaded
gTTS-1.1.6.tar.gz 6.8 kB Details

Release files / gTTS-1.1.6.tar.gz

Download URL gTTS-1.1.6.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
114eb83b8c629260b2cc162a7d954b12e4a9819f5ddcf5e068c0b71c2c6104c2
BLAKE2b-256 checksum
How to use checksums
339de60e1f3594d4370cc19b856e6ae7aa4202a683a188b78ae8fe0af8af83ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.5.4

2 release files

2.5.3

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.0

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.4

1 release file

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.2

2 release files

2.1.1

3 release files

2.1.0

3 release files

2.0.4

3 release files

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.8

1 release file

1.1.7

1 release file

This release

1.1.6 This release

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page