curl --request POST \
--url https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream \
--header 'Content-Type: application/json' \
--header 'PersoPlatform-APIKey: <api-key>' \
--header 'xi-api-key: <api-key>' \
--data '
{
"text": "Hello, this is a streaming text to speech test.",
"model_id": "perso_multilingual_v1"
}
'import requests
url = "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream"
payload = {
"text": "Hello, this is a streaming text to speech test.",
"model_id": "perso_multilingual_v1"
}
headers = {
"PersoPlatform-APIKey": "<api-key>",
"xi-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'PersoPlatform-APIKey': '<api-key>',
'xi-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Hello, this is a streaming text to speech test.',
model_id: 'perso_multilingual_v1'
})
};
fetch('https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Hello, this is a streaming text to speech test.',
'model_id' => 'perso_multilingual_v1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"PersoPlatform-APIKey: <api-key>",
"xi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream"
payload := strings.NewReader("{\n \"text\": \"Hello, this is a streaming text to speech test.\",\n \"model_id\": \"perso_multilingual_v1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("PersoPlatform-APIKey", "<api-key>")
req.Header.Add("xi-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream")
.header("PersoPlatform-APIKey", "<api-key>")
.header("xi-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Hello, this is a streaming text to speech test.\",\n \"model_id\": \"perso_multilingual_v1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["PersoPlatform-APIKey"] = '<api-key>'
request["xi-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Hello, this is a streaming text to speech test.\",\n \"model_id\": \"perso_multilingual_v1\"\n}"
response = http.request(request)
puts response.read_body"<string>"Stream Text to Speech
Convert text to speech with streaming response for real-time playback.
Prerequisites
You must have at least one cloned voice. Use Create Voice (POST /v1/voices/add) to create a voice, then retrieve its voice_id from List Voices (GET /v2/voices).
Authenticate using the PersoPlatform-APIKey header.
--header 'PersoPlatform-APIKey: <your-api-key>'
URL Path Parameters
Replace {voice_id} in the URL with your voice ID. Retrieve available voice IDs from List Voices (GET /v2/voices).
POST /v1/text-to-speech/{voice_id}/stream
Request Parameters
| Parameter | Required | Description |
|---|---|---|
text | Yes | Text to convert to speech |
model_id | No | Default: perso_multilingual_v1 |
Query Parameters
| Parameter | Required | Description |
|---|---|---|
output_format | Yes | Audio format for streaming. Default: wav_24000 (see formats below) |
How It Works
Audio chunks are streamed as they are generated, enabling:
- Lower latency for first audio
- Real-time playback during generation
- Reduced memory usage for long text
Example
Select “TextToSpeechStreamRequest” from the Examples dropdown to see a request example.
curl -X POST "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream?output_format=mp3_44100_192" -H "PersoPlatform-APIKey: <your-api-key>" -H "Content-Type: application/json" -H "Accept: */*" -d '{"text": "Hello, this is a streaming test."}' --output audio.mp3
curl --request POST \
--url https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream \
--header 'Content-Type: application/json' \
--header 'PersoPlatform-APIKey: <api-key>' \
--header 'xi-api-key: <api-key>' \
--data '
{
"text": "Hello, this is a streaming text to speech test.",
"model_id": "perso_multilingual_v1"
}
'import requests
url = "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream"
payload = {
"text": "Hello, this is a streaming text to speech test.",
"model_id": "perso_multilingual_v1"
}
headers = {
"PersoPlatform-APIKey": "<api-key>",
"xi-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'PersoPlatform-APIKey': '<api-key>',
'xi-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Hello, this is a streaming text to speech test.',
model_id: 'perso_multilingual_v1'
})
};
fetch('https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Hello, this is a streaming text to speech test.',
'model_id' => 'perso_multilingual_v1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"PersoPlatform-APIKey: <api-key>",
"xi-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream"
payload := strings.NewReader("{\n \"text\": \"Hello, this is a streaming text to speech test.\",\n \"model_id\": \"perso_multilingual_v1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("PersoPlatform-APIKey", "<api-key>")
req.Header.Add("xi-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream")
.header("PersoPlatform-APIKey", "<api-key>")
.header("xi-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Hello, this is a streaming text to speech test.\",\n \"model_id\": \"perso_multilingual_v1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://platform.perso.ai/api/speech/v1/text-to-speech/{voice_id}/stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["PersoPlatform-APIKey"] = '<api-key>'
request["xi-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Hello, this is a streaming text to speech test.\",\n \"model_id\": \"perso_multilingual_v1\"\n}"
response = http.request(request)
puts response.read_body"<string>"Authorizations
Use this header if you want to call the API with an ElevenLabs-compatible SDK. Pass your Perso API key as the xi-api-key header value.
Path Parameters
The ID of the voice to use for speech generation. Retrieve available voice IDs from List Voices (GET /v2/voices).
Query Parameters
The desired audio output format.
mp3_44100, pcm_24000, pcm_44100, wav_24000, wav_44100 Body
Text to synthesize and stream as speech.
1 - 50001Optional dict of voice tuning parameters (e.g. stability, similarity_boost) compatible with ElevenLabs voice settings.
Show child attributes
Show child attributes
Response
Streaming audio binary. Content-Type depends on output_format: audio/wav, audio/mpeg, or audio/L16.
The response is of type file.

