Skip to main content

Django-Gtts

Coverage Status

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

Install:

- With pip

  • pip install Django-Gtts

- From the source:

  • git clone https://github.com/mrf345/django_gtts.git
  • cd django_gtts
  • python setup.py install

Setup:

- Add it to the settings.py in INSTALLED_APPS:

INSTALLED_APPS = [
    'gTTS',
    ...
]

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

  • python manage.py makemigrations gTTS
  • python manage.py 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 %}
<audio
    src="{% say 'en-us' 'text to say' %}"
    controls
></audio>

- To add a dynamic translation view to urls.py:

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

remove_cache()

- Options:

say(
    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'

Credit:

  • gTTS: Python Google text-to-speech

Download files

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

Source Distribution

Django-Gtts-0.4.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Django_Gtts-0.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file Django-Gtts-0.4.tar.gz.

File metadata

  • Download URL: Django-Gtts-0.4.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.9

File hashes

Hashes for Django-Gtts-0.4.tar.gz
Algorithm Hash digest
SHA256 fc25aa5c95d675d6cc7c76c154d67a094c7d77d02b04c80df61d4e6c885a8675
MD5 009814bc1de57341362d33c67fe88c58
BLAKE2b-256 89e91ed6610da0bf9fec249b850f648caa89fb91602c8a621cf06bbc23a81ca1

See more details on using hashes here.

File details

Details for the file Django_Gtts-0.4-py3-none-any.whl.

File metadata

  • Download URL: Django_Gtts-0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.9

File hashes

Hashes for Django_Gtts-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7d2302f6d8cc3fec7e8d5406ea5562ce5b114c42083008956f0f8dc2ee6869b6
MD5 2499a60c6b0ab41b952977b646bbec2f
BLAKE2b-256 f1d47610596b3fec1ca4c1c7e6d0c721e9ad0908837c59f5ee7581bd8e12c6b3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4 This release

2 files

0.3

2 files

0.2

1 file

0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page