A Text-To-Speech (TTS) API implemented using Flask. This repository provides a Docker setup to easily get up and running.
- Docker and Docker Compose installed on your machine.
- Production only:
- Clone this repository:
git clone <repository-url> cd <repository-dir>
- IMPORTANT - Set the API_KEY enviroment variable, this helps to prevent your API from unauthorized ussage. You can use any UUID online generator for this, like this UUID Generator:
export API_KEY=value
- Build and start the Docker containers
If you are running with
docker-compose up --build -d
sudo
. You should run the below, otherwise it can not load the env variable:sudo -E docker-compose up --build -d
Note: If you want to change the API_KEY for any reason:
1. SSH to your server
2. sudo docker-compose stop
3. export API_KEY=new_value
4. sudo -E docker-compose up --build -d
To use the TTS API, make a POST request to the API endpoint with the text you want to convert:
rate
is the reading speed. Its value range is [-100, 100]volume
is the voice volume in the output file. Its value range is [-100,100]voice
is the the voice in the output file. You can check for more voices in the filevoice_list.txt
curl --location 'https://yourdomain.com/tts' \
--header 'x-api-key: sample_api_key' \
--header 'Content-Type: application/json' \
--data '{
"text": "Hello world, this is a test",
"voice": "en-US-ChristopherNeural",
"rate": 20,
"volume": -50
}'