Text to speech
Generate spoken audio from text
Text to speech converts text into playable audio. NaviGator AI Toolkit provides an OpenAI-compatible speech endpoint using kokoro.
Generate speech
Before running an example, complete Getting Started, configure the documented environment variables and confirm that your key can use kokoro. The Python and JavaScript examples need the openai package from OpenAI-compatible SDKs.
curl "$NAVIGATOR_API_BASE_URL/audio/speech" \
--header "Authorization: Bearer $NAVIGATOR_TOOLKIT_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "kokoro",
"input": "Hello. I am NaviGator AI Toolkit. Nice to meet you.",
"voice": "af_heart",
"response_format": "mp3",
"speed": 1.0
}' \
--output speech.mp3A successful request creates a playable speech.mp3 file in the current folder.
Request options
- Voice: Select a voice supported by the model.
- Response format: Choose a supported audio format such as MP3.
- Speed: Adjust playback speed within the model's accepted range.
The examples use the af_heart voice, MP3 output and normal 1.0 speed with kokoro. Other available voices, formats and speed values are model-specific; do not substitute values without an authoritative model-specific reference.
Responsible use
- Tell listeners when synthetic speech could reasonably be mistaken for a person.
- Do not use generated audio to impersonate someone or misrepresent authorization.
- Review pronunciation of names, abbreviations and specialized terminology.
- Check the selected model's approved data classifications before submitting text.