Stream TTS Audio with Final URL
curl --request POST \
--url https://api.sunbird.ai/tasks/modal/tts/stream-with-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"speaker_id": 248,
"response_mode": "url"
}
'import requests
url = "https://api.sunbird.ai/tasks/modal/tts/stream-with-url"
payload = {
"text": "<string>",
"speaker_id": 248,
"response_mode": "url"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', speaker_id: 248, response_mode: 'url'})
};
fetch('https://api.sunbird.ai/tasks/modal/tts/stream-with-url', 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://api.sunbird.ai/tasks/modal/tts/stream-with-url",
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' => '<string>',
'speaker_id' => 248,
'response_mode' => 'url'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.sunbird.ai/tasks/modal/tts/stream-with-url"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"speaker_id\": 248,\n \"response_mode\": \"url\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.sunbird.ai/tasks/modal/tts/stream-with-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"speaker_id\": 248,\n \"response_mode\": \"url\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sunbird.ai/tasks/modal/tts/stream-with-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"speaker_id\": 248,\n \"response_mode\": \"url\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Legacy Text to Speech
Stream TTS Audio with Final URL
deprecated
Stream audio chunks and return a signed URL at completion. DEPRECATED: use POST /tasks/audio/speech with response_mode=‘both’.
POST
/
tasks
/
modal
/
tts
/
stream-with-url
Stream TTS Audio with Final URL
curl --request POST \
--url https://api.sunbird.ai/tasks/modal/tts/stream-with-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "<string>",
"speaker_id": 248,
"response_mode": "url"
}
'import requests
url = "https://api.sunbird.ai/tasks/modal/tts/stream-with-url"
payload = {
"text": "<string>",
"speaker_id": 248,
"response_mode": "url"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: '<string>', speaker_id: 248, response_mode: 'url'})
};
fetch('https://api.sunbird.ai/tasks/modal/tts/stream-with-url', 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://api.sunbird.ai/tasks/modal/tts/stream-with-url",
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' => '<string>',
'speaker_id' => 248,
'response_mode' => 'url'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://api.sunbird.ai/tasks/modal/tts/stream-with-url"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"speaker_id\": 248,\n \"response_mode\": \"url\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.sunbird.ai/tasks/modal/tts/stream-with-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"speaker_id\": 248,\n \"response_mode\": \"url\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sunbird.ai/tasks/modal/tts/stream-with-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"speaker_id\": 248,\n \"response_mode\": \"url\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
Body
application/json
Request model for TTS generation.
Text to convert to speech
Required string length:
1 - 10000Example:
"Hello, this is a text-to-speech test."
Speaker voice for TTS generation
Available options:
241, 242, 243, 245, 246, 248 Examples:
248
246
How to return the audio: 'url' for signed URL, 'stream' for streaming, 'both' for streaming with final URL
Available options:
url, stream, both Response
Successful Response
⌘I

