This add-on integrates Openai Edge TTS into your DDEV project.
Openai Edge TTS provides a local, OpenAI-compatible text-to-speech (TTS) API using edge-tts. edge-tts uses Microsoft Edge’s online text-to-speech service, so it is completely free.
ddev add-on get tyler36/ddev-openai-edge-tts
ddev restart
After installation, make sure to commit the .ddev
directory to version control.
This addon is a helper wrapper for https://github.com/travisvn/openai-edge-tts. The following features are stated as available:
/v1/audio/speech
with similar request structure and behavior.alloy
, echo
, fable
, onyx
, nova
, shimmer
) to edge-tts equivalents.mp3
, opus
, aac
, flac
, wav
, pcm
).To preview edge-tts voices, see Voice Samples.
This addon provides the service via an API endpoint.
Access | Endpoint |
---|---|
Host | https://{PROJECT_NAME}:5050/v1/audio/speech |
Container | openai-edge-tts:5050/v1/audio/speech |
OpenAI-Compatible Edge-TTS API tries to maintain compatibility with the OpenAI audio/speech
endpoint.
@see OpenAI-Compatible Edge-TTS API for all available options.
For non-English languages, set the voice to an appropriate language list on Voice Samples.
Use curl
to make request to the endpoint.
Below, is an example of a command from the host that:
input
echo
voicemp3
format1.1
speed (faster than normal)speech.mp3
.ddev exec curl -X POST openai-edge-tts:5050/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_api_key_here" \
-d '{
"input": "Hello, I am your AI assistant!",
"voice": "echo",
"response_format": "mp3",
"speed": 1.1
}' \
--output speech.mp3
[!Note] “your_api_key_here” is the default API KEY and does not need to be changed for local development.
OpenAI-php can be used with this addon.
factory()
function to generate a new $client
that points to this addon.$client
as normal. $client = \OpenAI::factory()
->withApiKey('your_api_key_here'))
->withBaseUri('http://openai-edge-tts:5050/v1/')
->make();
// This is a standard OpenAI TTS API call.
$mp3 = $client->audio()->speech([
'input' => "What can I help you with today?",
'voice' => 'echo',
'response_format' => 'mp3',
]);
Command | Description |
---|---|
ddev describe |
View service status and used ports for Openai Edge Tts |
ddev logs -s openai-edge-tts |
Check Openai Edge Tts logs |
To change the Docker image:
ddev dotenv set .ddev/.env.openai-edge-tts --openai-edge-tts-docker-image="ddev/ddev-utilities:latest"
ddev add-on get tyler36/ddev-openai-edge-tts
ddev restart
Make sure to commit the .ddev/.env.openai-edge-tts
file to version control.
All customization options (use with caution):
Variable | Flag | Default |
---|---|---|
OPENAI_EDGE_TTS_DOCKER_IMAGE |
--openai-edge-tts-docker-image |
ddev/ddev-utilities:latest |
To change the HTTP/S ports exposed to the host system:
Use DDEV dotenv command
ddev dotenv set .ddev/.env --tts-http-port="${TTS_HTTP_PORT}" # HTTP
ddev dotenv set .ddev/.env --tts-https-port="${TTS_HTTPS_PORT}" # HTTPS
or, update the .ddev/.env
file directly.
TTS_HTTP_PORT=5010
TTS_HTTPS_PORT=5011
Restart DDEV to apply the changes.
Contributed and maintained by @tyler36