{"id":16195245,"url":"https://github.com/mrf345/flask_gtts","last_synced_at":"2025-03-19T04:30:52.764Z","repository":{"id":57430359,"uuid":"112034949","full_name":"mrf345/flask_gtts","owner":"mrf345","description":"A Flask extension to add gTTS Google text to speech","archived":false,"fork":false,"pushed_at":"2024-07-04T22:23:26.000Z","size":69,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T03:51:14.703Z","etag":null,"topics":["extension","flask","gtts","text-to-speech"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrf345.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-25T21:15:06.000Z","updated_at":"2024-07-04T22:21:07.000Z","dependencies_parsed_at":"2024-10-27T20:17:12.470Z","dependency_job_id":"9a5193a3-9742-4af9-9c47-4650125bc302","html_url":"https://github.com/mrf345/flask_gtts","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"70c572b431a2be25e46572f99acc2eb14ade9a5b"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrf345%2Fflask_gtts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrf345%2Fflask_gtts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrf345%2Fflask_gtts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrf345%2Fflask_gtts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrf345","download_url":"https://codeload.github.com/mrf345/flask_gtts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244357492,"owners_count":20440341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","flask","gtts","text-to-speech"],"created_at":"2024-10-10T08:26:47.252Z","updated_at":"2025-03-19T04:30:52.344Z","avatar_url":"https://github.com/mrf345.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align='center'\u003eFlask-gTTS\u003c/h1\u003e\n\u003cp align='center'\u003e\n\u003ca href='https://pypi.org/project/Flask-gTTS/'\u003e\n    \u003cimg src='https://img.shields.io/github/v/tag/mrf345/flask_gtts' alt='Latest Release' /\u003e\n\u003c/a\u003e\n\u003ca href='https://github.com/mrf345/flask_gtts/actions/workflows/ci.yml'\u003e\n  \u003cimg src='https://github.com/mrf345/flask_gtts/actions/workflows/ci.yml/badge.svg'\u003e\n\u003c/a\u003e\n\u003ca href='https://github.com/mrf345/flask_gtts/actions/workflows/ci.yml'\u003e\n  \u003cimg src='https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/mrf345/bc746d7bfe356b54fbb93b2ea5d0d2a4/raw/flask_gtts__heads_master.json' alt='Coverage Percentage' /\u003e\n\u003c/a\u003e\n\u003cbr /\u003e\n\u003cimg src='https://img.shields.io/pypi/pyversions/flask_gtts' alt='Supported versions' /\u003e\n\u003cbr /\u003e\n\u003c/p\u003e\n\n\u003ch3 align='center'\u003eA Flask extension to add support for Google Text-To-Speech (TTS).\u003c/h3\u003e\n\n## Install:\n#### - With pip\n- `pip install Flask-gTTS` \u003cbr /\u003e\n\n#### - From the source:\n- `git clone https://github.com/mrf345/flask_gtts.git`\u003cbr /\u003e\n- `cd flask_gtts` \u003cbr /\u003e\n- `python setup.py install`\n\n## Setup:\n\n#### - Inside the Flask app:\n```python\nfrom flask import Flask, render_template\nfrom flask_gtts import gtts\napp = Flask(__name__)\ngtts(app)\n```\n\n#### - Inside the jinja template:\n```jinja\n{% block content %}\n  \u003caudio src=\"{{ sayit(text='Hello from Flask !')}}\"\u003e\u003c/audio\u003e\n{% endblock %}\n```\n\n#### - Dynamic read TTS example:\n```jinja\n\u003chead\u003e\n  {{ read(id='.readIt') }}\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1 class='readIt'\u003eSay something\u003c/h1\u003e\n  \u003ch1 class='readIT' language='it'\u003equalcosa da dire\u003c/h1\u003e\n\u003c/body\u003e\n```\n\n#### - Dynamic route example:\n```python\nfrom flask import Flask\nfrom flask_gtts import gtts\n\n# If we want to allow only logged in users for example.\nfrom flask_login import login_required\n\napp = Flask(__name__)\ngtts(app,\n     route=True,\n     route_decorator=login_required,\n     route_path='/gtts')\n```\n\nAnd now you can test the endpoint by accessing `http://localhost:5000/gtts/en-us/some text to test`. It will return `JSON` response:\n\n```json\n{\n    \"mp3\": \"Generated audio file path.\"\n}\n```\n\n## Settings:\n- **`gtts()`** options:\n\n```python\ndef __init__(self, app=None, temporary=True, tempdir='flask_gtts', route=False,\n                 route_path='/gtts', route_decorator=None):\n        '''Extension to help in generating Google Text-To-Speech files.\n\n        Parameters\n        ----------\n        app : Flask Application, optional\n            Flask application instance, by default None\n        temporary : bool, optional\n            Remove the audio files before existing, by default True\n        tempdir : str, optional\n            Name of the static directory to store audio files in, by default 'flask_gtts'\n        route : bool, optional\n            Enable endpoint to generate TTS file dynamically, by default False\n        route_path : str, optional\n            Endpoint route path, by default '/gtts'\n        route_decorator : callable, optional\n            Decorator to wrap route endpoint, by default None\n        failsafe : bool, optional\n            Failsafe or throw exceptions, by default False\n        '''\n```\n\n- **`sayit()`** options:\n\n```python\ndef say(self, lang='en-us', text='Flask says Hi!'):\n        '''Generate a TTS audio file.\n\n        Parameters\n        ----------\n        lang : str, optional\n            Language to produce the TTS in, by default 'en-us'\n        text : str, optional\n            Text to convert into audio, by default 'Flask says Hi!'\n\n        Returns\n        -------\n        str\n            Relative url of the generated TTS audio file.\n        '''\n```\n\n- **`read()`** options:\n```python\ndef read(self, id='.toRead', mouseover=False):\n        '''Read an HTML element inner text.\n\n        Parameters\n        ----------\n        id : str, optional\n            HTML element css selector, by default '.toRead'\n        mouseover : bool, optional\n            Read text on `mouseover` event instead of `click`, by default False\n\n        Returns\n        -------\n        str\n            Safe JavaScript to read an HTML element content.\n        '''\n```\n\n- **List of supported languages**:\n\n`\n    'af' : 'Afrikaans'\n    'sq' : 'Albanian'\n    'ar' : 'Arabic'\n    'hy' : 'Armenian'\n    'bn' : 'Bengali'\n    'ca' : 'Catalan'\n    'zh' : 'Chinese'\n    'zh-cn' : 'Chinese (Mandarin/China)'\n    'zh-tw' : 'Chinese (Mandarin/Taiwan)'\n    'zh-yue' : 'Chinese (Cantonese)'\n    'hr' : 'Croatian'\n    'cs' : 'Czech'\n    'da' : 'Danish'\n    'nl' : 'Dutch'\n    'en' : 'English'\n    'en-au' : 'English (Australia)'\n    'en-uk' : 'English (United Kingdom)'\n    'en-us' : 'English (United States)'\n    'eo' : 'Esperanto'\n    'fi' : 'Finnish'\n    'fr' : 'French'\n    'de' : 'German'\n    'el' : 'Greek'\n    'hi' : 'Hindi'\n    'hu' : 'Hungarian'\n    'is' : 'Icelandic'\n    'id' : 'Indonesian'\n    'it' : 'Italian'\n    'ja' : 'Japanese'\n    'km' : 'Khmer (Cambodian)'\n    'ko' : 'Korean'\n    'la' : 'Latin'\n    'lv' : 'Latvian'\n    'mk' : 'Macedonian'\n    'no' : 'Norwegian'\n    'pl' : 'Polish'\n    'pt' : 'Portuguese'\n    'ro' : 'Romanian'\n    'ru' : 'Russian'\n    'sr' : 'Serbian'\n    'si' : 'Sinhala'\n    'sk' : 'Slovak'\n    'es' : 'Spanish'\n    'es-es' : 'Spanish (Spain)'\n    'es-us' : 'Spanish (United States)'\n    'sw' : 'Swahili'\n    'sv' : 'Swedish'\n    'ta' : 'Tamil'\n    'th' : 'Thai'\n    'tr' : 'Turkish'\n    'uk' : 'Ukrainian'\n    'vi' : 'Vietnamese'\n    'cy' : 'Welsh'\n`\n\n## Credit:\n- [gTTS][2c6d97b1]: Python Google text-to-speech\n\n  [2c6d97b1]: https://github.com/pndurette/gTTS \"gTTs repo\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrf345%2Fflask_gtts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrf345%2Fflask_gtts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrf345%2Fflask_gtts/lists"}