Skip to main content

Text-to-speech

Generate audio for given content, voice and voice style (optional). Returns generated audio (mp3) file URL and duration in response.

Request

POSThttps://api.fliki.ai/v1/generate/text-to-speech

Headers

{
"Content-type": "application/json",
"Authorization": "Bearer API_KEY"
}
KeyValueDescription
Content-Typeapplication/jsonSpecifies that the request body format is JSON, allowing the server to parse the data correctly.
AuthorizationBearer YOUR_API_KEYGenerate your API Key in the account/api. section and replace YOUR_API_KEY with your actual key.

Body

Body Description

{
"content": String,
"voiceId": String,
"voiceStyleId": String | null,
"sampleRate": 8000 | 24000 | 48000,
"playbackRate": Number,
"format": "mp3" | "wav" | "ogg",
"pronunciations": Array<{ original: String, replace: String }> | undefined
}
KeyTypeDescriptionRequiredDefault
contentstringThe content to be converted, typically text. Must not exceed the character limit specified.YesN/A
voiceIdstringThe identifier for the voice to be used for the output.YesN/A
voiceStyleIdstringThe identifier for the style of the voice.-N/A
sampleRatenumberThe sample rate for the audio. Must be one of 8000, 24000, or 48000.-24000
playbackRatenumberThe playback rate for the audio. Must be between 0.5 and 3.0.-1.0
formatstringThe format of the audio file. Must be one of "mp3", "wav", or "ogg".-"mp3"
pronunciationsarrayAn optional array of objects containing original and replace strings for pronunciation adjustments.-N/A

Obtain voiceId and voiceStyleId via the voices endpoint.

Response

{
"audio": String,
"duration": Number
}
KeyTypeDescription
audiostringURL of the generated audio file
durationnumberTotal duration of the audio

Example

cURL Request
curl \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{"content": "...", "voiceId": "...", "voiceStyleId": "..."}' \
-X POST https://api.fliki.ai/v1/generate/text-to-speech