{"id":22280936,"url":"https://github.com/pedroetb/tts-api","last_synced_at":"2025-07-28T19:32:56.844Z","repository":{"id":48028531,"uuid":"74288125","full_name":"pedroetb/tts-api","owner":"pedroetb","description":"Text to speech REST API for multiple TTS engines","archived":false,"fork":false,"pushed_at":"2024-03-19T04:07:50.000Z","size":228,"stargazers_count":25,"open_issues_count":6,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-14T11:42:14.796Z","etag":null,"topics":["api","docker","docker-swarm","espeak","festival","googlespeech","gtts","rest-api","speech","swarm","text-to-speech","tts","tts-api","voice"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/pedroetb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"pedroetb"}},"created_at":"2016-11-20T16:40:42.000Z","updated_at":"2024-05-13T06:53:54.000Z","dependencies_parsed_at":"2024-03-19T01:59:24.051Z","dependency_job_id":null,"html_url":"https://github.com/pedroetb/tts-api","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedroetb%2Ftts-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedroetb%2Ftts-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedroetb%2Ftts-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedroetb%2Ftts-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pedroetb","download_url":"https://codeload.github.com/pedroetb/tts-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227951784,"owners_count":17846345,"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":["api","docker","docker-swarm","espeak","festival","googlespeech","gtts","rest-api","speech","swarm","text-to-speech","tts","tts-api","voice"],"created_at":"2024-12-03T16:10:28.900Z","updated_at":"2025-07-28T19:32:56.834Z","avatar_url":"https://github.com/pedroetb.png","language":"JavaScript","readme":"# TTS-API\n\nText to speech REST API for multiple TTS engines.\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![Sponsor](https://img.shields.io/badge/-Sponsor-fafbfc?logo=GitHub%20Sponsors)](https://github.com/sponsors/pedroetb)\n\nYou can send a text to be converted into audio, using different TTS engines and sound effects. Then, you will be listening to it on your local audio device, or receiving the resultant audio file.\n\n## Setup\n\nFirst, you should install the supported TTS engines:\n\n### GoogleSpeech setup\n\n```sh\napt install python3 sox libsox-fmt-mp3\npip install google_speech\n```\n\n### gTTS setup\n\n```sh\napt install python3 sox libsox-fmt-mp3\npip install gTTS\n```\n\n### Festival setup\n\n```sh\napt install festival festvox-ellpc11k\n```\n\n### eSpeak setup\n\n```sh\napt install espeak\n```\n\nYou also need to install **nodejs** and **npm**, and then, simply run `npm install` and `npm start`.\nThe API should now be running at `http://localhost:3000`.\n\nOr you can just use [pedroetb/tts-api](https://hub.docker.com/r/pedroetb/tts-api) **Docker** image, which already has all dependencies configured.\n\n## Setup using Docker\n\nThe only requirement is to have **Docker** installed. Then, you can run:\n\n```sh\ndocker run --rm -d --name tts-api --device /dev/snd -p 3000:3000 pedroetb/tts-api\n```\n\nThe API will be running and accessible at `http://localhost:3000`.\n\nAlternatively, you can deploy it in a **Docker Swarm** cluster using `docker compose` (already included in Docker if using modern version) and `docker swarm` (create Swarm cluster first):\n\n```sh\ncd deploy\n\n# Deploy Caddy service\nenv $(grep -v '^[#| ]' .env | xargs) \\\n TRAEFIK_DOMAIN=change.me \\\n docker stack deploy \\\n -c compose.caddy.yaml \\\n tts-api\n\n# Run TTS-API container\ndocker compose \\\n -f compose.tts-api.yaml \\\n -p tts-api \\\n up -d\n```\n\nThe service is prepared to be reverse-proxied with **Traefik**, and accessible at `tts.${TRAEFIK_DOMAIN}` domain. How to run **Traefik** is not described here, check its [official site](https://traefik.io).\n\nThe proxy needs a little help from **Caddy**, because Docker Swarm is not compatible with devices configuration (required to use sound capabilities) and Traefik cannot work with Docker containers and Docker Swarm services all at once. This way, only **Caddy** service is exposed using **Traefik** and `tts-api` container is only accessible through reverse-proxy provided by **Caddy** (same way **Traefik** is reverse-proxing to **Caddy**).\n\nBoth, Docker container and service, can be running on different hosts, because they are able to communicate through a Docker overlay network. Run `tts-api` Docker container on host which has speakers, so you can listen speech.\n\nDon't forget to edit `TRAEFIK_DOMAIN` environment variable before deploying.\n\n## Usage\n\nWhen running, the API will receive POST requests at `http://localhost:3000`.\nYou can use your favourite REST client to send a request, or use the built-in form.\n\nBoth modes (playing or downloading audio) are available using different voice codes, select one according to your needs.\n\n### Built-in form\n\nGo to `http://localhost:3000` with your browser, fill the form with data and submit it. Just that.\n\n### Send POST request\n\nYou can send a POST request to `http://localhost:3000` following this scheme:\n\n* **Headers**\n  * **Content-Type**: `application/json`\n* **Body**\n  * `{ \"voice\": \"google_speech\", \"textToSpeech\": \"hello world\", \"language\": \"en\", \"speed\": \"1\" }`\n\nFor example, using `curl`:\n\n```sh\n# Play audio\ncurl http://localhost:3000 \\\n -d '{ \"voice\": \"google_speech\", \"textToSpeech\": \"hello world\", \"language\": \"en\", \"speed\": \"1\" }' \\\n -H 'Content-Type: application/json'\n\n# Download audio file\ncurl http://localhost:3000 \\\n -d '{ \"voice\": \"gtts_file\", \"textToSpeech\": \"hello world\", \"language\": \"en\", \"speed\": \"1\" }' \\\n -H 'Content-Type: application/json' \\\n -o 'output.mp3'\n```\n\n## Available TTS engines\n\n### GoogleSpeech engine\n\nGoogle Speech is a simple multiplatform command line tool to read text using Google Translate TTS (Text To Speech) API.\n\nYou need to be online to communicate with Google servers.\n\nLearn more at \u003chttps://github.com/desbma/GoogleSpeech\u003e\n\n### gTTS engine\n\nGoogle Text-to-Speech (gTTS) is a Python library and CLI tool to interface with Google Translate's text-to-speech API.\n\nYou need to be online to communicate with Google servers.\n\nLearn more at \u003chttps://github.com/pndurette/gTTS\u003e\n\n### Festival engine\n\nFestival is a free software multi-lingual speech synthesis workbench that runs on multiple-platforms offering black box text to speech, as well as an open architecture for research in speech synthesis.\n\nIt works offline.\n\nLearn more at \u003chttp://www.cstr.ed.ac.uk/projects/festival/\u003e and \u003chttp://festvox.org/festival/\u003e\n\n### eSpeak engine\n\neSpeak is a compact open source software speech synthesizer for English and other languages, for Linux and Windows.\n\nIt works offline.\n\nLearn more at \u003chttp://espeak.sourceforge.net/\u003e\n\n## License\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\nThis project is released under the [MIT License](LICENSE).\n","funding_links":["https://github.com/sponsors/pedroetb"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedroetb%2Ftts-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpedroetb%2Ftts-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedroetb%2Ftts-api/lists"}