Skip to main content

gTTS google text-to-speech django app

Project description


Coverage Status

A Django app to add gTTS google text-to-speech to the template and cache generated text-to-speech .mp3 files.


- With pip

  • pip install Django-Gtts

- From the source:

  • git clone
  • cd django_gtts
  • python install


- Add it to the in INSTALLED_APPS:


After adding the app make sure to do migration for caching model :

  • python makemigrations gTTS
  • python migrate gTTS

- Inside your Django Template:

NOTE: load gTTS should be used once in the begining of every template that uses say, Or once in the begining of the base template.

{% load gTTS %}
    src="{% say 'en-us' 'text to say' %}"

- To add a dynamic translation view to

from django.urls import path, include

urlpatterns = [
    # for unauthorized access dynamic translation 
    path('gtts/', include('gTTS.urls')),
    # for user authorized dynamic translation
    path('gtts_auth/', include('gTTS.urls_auth')),

now you can access http://localhost:8000/<language>/<text> and, it should return json response {'mp3': 'static mp3 link'}

- To clean up stored cache of mp3 files and modal records

from gTTS.cache import remove_cache


- Options:

    language='en-us', # language to convert text to
    text='say hi'): # text to be converted`_<br />

- List of 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'


  • gTTS: Python Google text-to-speech

Project details

Download files

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

Files for Django-Gtts, version 0.4
Filename, size File type Python version Upload date Hashes
Filename, size Django_Gtts-0.4-py3-none-any.whl (7.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size Django-Gtts-0.4.tar.gz (6.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page