Generate speech
August 18, 2025
Table of contents
This endpoint generates high-quality speech from text using Mureka’s advanced text-to-speech technology. You can use either predefined voices or custom cloned voices created via POST /speech/voice. For multi-speaker conversations, use the conversation
parameter with different voice IDs. Speech generation typically takes 20-90 seconds depending on text length.
https://api.useapi.net/v1/mureka/speech
Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Content-Type: multipart/form-data
API token
is required, see Setup useapi.net for details.
Request Body
-
account
is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required. -
title
is optional string.
Maximum length is 500 characters. -
text
is required string when not usingconversation
. Must be used together withvoice_id
.
Maximum text length is 5000 characters. -
voice_id
is required number when not usingconversation
. Must be used together withtext
. Get available voice IDs from GET /speech/voices.
To create a cloned voice, first use POST /speech/voice to upload an audio sample and clone the voice. -
conversation
is optional JSON string. Alternative totext
andvoice_id
. Must be a JSON string array of objects withvoice_id
(number) andtext
(string) fields. Cannot be used together withtext
andvoice_id
.
Total text length across all conversation items cannot exceed 5000 characters.Example
conversation
JSON:[ {"voice_id": 12345, "text": "Hello, welcome to our service!"}, {"voice_id": 67890, "text": "Thank you for choosing us today."}, {"voice_id": 12345, "text": "Is there anything I can help you with?"} ]
Responses
-
{ "title": "Sample Speech Title", "preview": "This is a preview of the generated speech content that demonstrates the text-to-speech capabilities.", "cover": "https://static-cos.mureka.ai/cos-prod/res/cover/….png", "mp3_url": "https://static-cos.mureka.ai/cos-prod/tts-v2/….mp3", "id": 12345678901234, "duration_milliseconds": 15000, "audio_quality": 2, "state": 3 }
-
{ "error": "<Error message>", "code": 400 }
-
{ "error": "Unauthorized", "code": 401 }
Model
{ // TypeScript, all fields are optional
title: string
preview: string
cover: string
mp3_url: string
id: number
duration_milliseconds: number
audio_quality: number
state: number
}
Examples
-
curl "https://api.useapi.net/v1/mureka/speech" \ -H "Accept: application/json" \ -H "Authorization: Bearer …" \ -H "Content-Type: application/json" \ -d '{ "text": "Hello, this is a sample text for speech generation.", "voice_id": 67890 }'
-
const token = "API token"; const apiUrl = "https://api.useapi.net/v1/mureka/speech"; const response = await fetch(apiUrl, { method: "POST", headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json", }, body: JSON.stringify({ text: "Hello, this is a sample text for speech generation.", voice_id: 67890 }), }); const result = await response.json(); console.log("response", {response, result});
-
import requests token = "API token" apiUrl = "https://api.useapi.net/v1/mureka/speech" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } data = { "text": "Hello, this is a sample text for speech generation.", "voice_id": 67890 } response = requests.post(apiUrl, headers=headers, json=data) print(response, response.json())