Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrf345/django_gtts
Django app extension to add gTTS google text-to-speech
https://github.com/mrf345/django_gtts
django google gtts text-to-speech
Last synced: 17 days ago
JSON representation
Django app extension to add gTTS google text-to-speech
- Host: GitHub
- URL: https://github.com/mrf345/django_gtts
- Owner: mrf345
- License: mit
- Created: 2018-07-07T09:51:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-22T17:43:08.000Z (about 3 years ago)
- Last Synced: 2024-10-11T08:26:48.252Z (about 1 month ago)
- Topics: django, google, gtts, text-to-speech
- Language: Python
- Size: 33.2 KB
- Stars: 7
- Watchers: 1
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Django-Gtts
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`:
```python
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](https://docs.djangoproject.com/en/2.2/topics/templates/):
> 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.
```jinja
{% load gTTS %}```
#### - To add a dynamic translation view to `urls.py`:
```python
from django.urls import path, includeurlpatterns = [
...
# 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//` and, it should return json response `{'mp3': 'static mp3 link'}`#### - To clean up stored cache of mp3 files and modal records
```python
from gTTS.cache import remove_cacheremove_cache()
```## - Options:
```python
say(
language='en-us', # language to convert text to
text='say hi'): # text to be converted`_
```#### - 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][2c6d97b1]: Python Google text-to-speech[2c6d97b1]: https://github.com/pndurette/gTTS "gTTs repo"