General Introduction
OpenAI Edge TTS is an open source project that provides an OpenAI-compatible native text-to-speech (TTS) API that uses Microsoft Edge's online text-to-speech service to allow users to generate high-quality speech output.OpenAI Edge TTS supports a wide range of speech options and playback speeds, and is capable of generating a wide range of audio formats. OpenAI Edge TTS supports a wide range of speech options and playback speeds, and can generate multiple audio formats. The service can be deployed via Docker or Python for quick and easy access.
Related items:edge-tts: Text-to-Speech Python Module | Free Text-to-Speech Service ,Edge TTS Worker: Deploying Microsoft Speech Synthesis APIs with Cloudflare, OpenAI Compatible Format and Wrapped Web Interface
Function List
- OpenAI Compatible Endpoints: Supports the same request structure and behavior as OpenAI TTS endpoints.
- Multiple voice support: Mapping OpenAI speech to Edge TTS equivalent speech.
- Flexible Audio Formats: Supports MP3, Opus, AAC, FLAC, WAV, PCM and many other audio formats.
- Adjustable playback speed: The playback speed can be adjusted from 0.25x to 4.0x.
- Direct selection of Edge TTS voice: You can use OpenAI voice mapping or specify any Edge TTS voice directly.
Using Help
Installation process
Deploying with Docker (recommended)
- clone warehouse::
git clone https://github.com/travisvn/openai-edge-tts.git
cd openai-edge-tts
- Creating an environment variable file: Create the following in the project root directory
.env
file containing the following variables:
API_KEY=your_api_key_here
PORT=5050
DEFAULT_VOICE=en-US-AndrewNeural
DEFAULT_RESPONSE_FORMAT=mp3
DEFAULT_SPEED=1.2
DEFAULT_LANGUAGE=en-US
REQUIRE_API_KEY=True
REMOVE_FILTER=False
EXPAND_API=True
- Run Docker Compose::
docker compose up --build
To run in the background, use the -d
Parameters:
docker compose up -d
Deploying with Python
- clone warehouse::
git clone https://github.com/travisvn/openai-edge-tts.git
cd openai-edge-tts
- Setting up a virtual environment::
python3 -m venv venv
source venv/bin/activate
- Installation of dependencies::
pip install -r requirements.txt
- Creating an environment variable file: Create the following in the project root directory
.env
file containing the above variables. - Operations Server::
python app/main.py
Instructions for use
- Accessing the API: After deployment is complete, the server will run
http://localhost:5050
The API endpoint can be accessed by sending an HTTP request. API endpoints can be accessed by sending HTTP requests/v1/audio/speech
The - Generate Speech: sends a POST request to
/v1/audio/speech
The request body contains the following JSON data:
{
"text": "Hello, world!",
"voice": "en-US-AndrewNeural",
"format": "mp3", "speed": 1.0
"speed": 1.0
}
- Adjusting the playback speed: Modification
speed
parameter, ranging from 0.25 to 4.0. - Select Voice: Use
voice
parameter specifies the voice, supported voices includealloy
,echo
,fable
,onyx
,nova
,shimmermer
etc. - audio format: Use
format
parameter specifies the audio format, which supportsmp3
,opus
,aac
,flac
,wav
,pcm
etc.
By following these steps, users can easily deploy and use the OpenAI Edge TTS service to generate high-quality text-to-speech output.