Text to Speech
Generate human-grade speech from just a script and a given voice.
Text to Speech API Documentation
Use the /v1/text-to-speech endpoint to generate audio from text. This tool endpoint can be useful if you would like to test audio previews before generating the video with avatar videos tool.
API Request
The API endpoint handles heavy media rendering tasks asynchronously using a fast queue-based system, and the request immediately returns a request_id. Use the request_id to poll the status of the generation and return the result after the task is completed.
Sending Request
curl -X POST "https://api.zoice.com/v1/text-to-speech" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ZOICE_API_KEY" \
-d '{
"voice_id": "bedf6a57-c6a5-...",
"model": "elevenlabs/eleven_v3",
"script_text": "Hi, this is Sophia"
}'Response Format
{
"request_id": 'd1f47b9c-6387-49d0-a403-...',
"status": 'processing',
}Polling and Output
After submitting an asynchronous API request, you can use the request_id obtained from the response to further poll for the status of the generation and ultimately retrieve the result after the completion. Use the /v1/fetch/request_id endpoint to perform this operation.
Polling Request
curl -X GET "https://api.zoice.com/v1/fetch/{request_id}" \
-H "Authorization: Bearer $ZOICE_API_KEY"Polling Response
{
"status": 'success',
"request_id": 'd1f47b9c-6387-49d0-a403-...',
"type": "audio",
"output": {
"credits": 300,
"result": "https://assets.zoice.com/...mp3"
}
}Schema
Input
Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
voice_id | string (uuid) | Yes | - | - | Voice ID of the desired voice profile. |
model | string | No |
|
| AI model to be used for generation. |
script_text | string | Yes | - | - | Text to be converted to audio. |
Output
Field | Type | Description |
|---|---|---|
status | string | The status of the API request. Allowed values: |
request_id | string (uuid) | A unique identifier generated for tracking this specific request. |
type | string | The type of media content being processed. Allowed values: |
output | object | An object containing the generated media url and metadata. |
output.credits | number | Credits used for generation. |
output.result | string (url) | The secure HTTP URL where the generated asset can be downloaded. |