Skip to content

Very simple API to convert text to speech using gTTS.

Notifications You must be signed in to change notification settings

DVerdeV/Text-to-Speech-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Text-to-Speech API

This is a simple Text-to-Speech API using Flask and the Google Text-to-Speech (gTTS) library.

Installation

  1. Install the required packages:
pip install Flask gTTS

Usage

  1. Run the app.py file:
python app.py

The API will be available at: http://localhost:8089/tts

  1. To use the API, make a POST request with a form containing the 'text' parameter.

Example using cURL:

curl -X POST -F "text=Hello, World!" http://localhost:8089/tts --output output.mp3

This will generate an output.mp3 file with the spoken text.

API Endpoint

  • POST /tts

    Convert the input text to speech.

    • Form parameters:

      • text (required): The text to be converted to speech.
    • Returns:

      • A response with the audio/mpeg content type containing the generated speech as an MP3 file.
    • Error handling:

      • If the 'text' parameter is missing in the request form, the API will return a 400 status code with the message "Missing 'text' parameter in request form".
      • If the input text is empty or contains only whitespace, the API will return a 400 status code with the message "Input text cannot be empty".

License

This project is released under the MIT License.

About

Very simple API to convert text to speech using gTTS.

Topics

Resources

Stars

Watchers

Forks

Languages