Text To Speech Stream
curl --request POST \
--url https://api.deepinfra.com/v1/text-to-speech/{voice_id}/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"text": "I'm beginnin' to feel like a Rap God, Rap God\nAll my people from the front to the back nod, back nod\nNow, who thinks their arms are long enough to slap box, slap box?\nThey said I rap like a robot, so call me Rap-bot",
"model_id": "hexgrad/Kokoro-82M",
"output_format": "mp3",
"language_code": "<string>"
}
EOFimport requests
url = "https://api.deepinfra.com/v1/text-to-speech/{voice_id}/stream"
payload = {
"text": "I'm beginnin' to feel like a Rap God, Rap God
All my people from the front to the back nod, back nod
Now, who thinks their arms are long enough to slap box, slap box?
They said I rap like a robot, so call me Rap-bot",
"model_id": "hexgrad/Kokoro-82M",
"output_format": "mp3",
"language_code": "<string>"
}
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: 'I\'m beginnin\' to feel like a Rap God, Rap God\nAll my people from the front to the back nod, back nod\nNow, who thinks their arms are long enough to slap box, slap box?\nThey said I rap like a robot, so call me Rap-bot',
model_id: 'hexgrad/Kokoro-82M',
output_format: 'mp3',
language_code: '<string>'
})
};
fetch('https://api.deepinfra.com/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://api.deepinfra.com/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' => 'I\'m beginnin\' to feel like a Rap God, Rap God
All my people from the front to the back nod, back nod
Now, who thinks their arms are long enough to slap box, slap box?
They said I rap like a robot, so call me Rap-bot',
'model_id' => 'hexgrad/Kokoro-82M',
'output_format' => 'mp3',
'language_code' => '<string>'
]),
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.deepinfra.com/v1/text-to-speech/{voice_id}/stream"
payload := strings.NewReader("{\n \"text\": \"I'm beginnin' to feel like a Rap God, Rap God\\nAll my people from the front to the back nod, back nod\\nNow, who thinks their arms are long enough to slap box, slap box?\\nThey said I rap like a robot, so call me Rap-bot\",\n \"model_id\": \"hexgrad/Kokoro-82M\",\n \"output_format\": \"mp3\",\n \"language_code\": \"<string>\"\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.deepinfra.com/v1/text-to-speech/{voice_id}/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"I'm beginnin' to feel like a Rap God, Rap God\\nAll my people from the front to the back nod, back nod\\nNow, who thinks their arms are long enough to slap box, slap box?\\nThey said I rap like a robot, so call me Rap-bot\",\n \"model_id\": \"hexgrad/Kokoro-82M\",\n \"output_format\": \"mp3\",\n \"language_code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/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["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"I'm beginnin' to feel like a Rap God, Rap God\\nAll my people from the front to the back nod, back nod\\nNow, who thinks their arms are long enough to slap box, slap box?\\nThey said I rap like a robot, so call me Rap-bot\",\n \"model_id\": \"hexgrad/Kokoro-82M\",\n \"output_format\": \"mp3\",\n \"language_code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Text to Speech
Text To Speech Stream
POST
/
v1
/
text-to-speech
/
{voice_id}
/
stream
Text To Speech Stream
curl --request POST \
--url https://api.deepinfra.com/v1/text-to-speech/{voice_id}/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"text": "I'm beginnin' to feel like a Rap God, Rap God\nAll my people from the front to the back nod, back nod\nNow, who thinks their arms are long enough to slap box, slap box?\nThey said I rap like a robot, so call me Rap-bot",
"model_id": "hexgrad/Kokoro-82M",
"output_format": "mp3",
"language_code": "<string>"
}
EOFimport requests
url = "https://api.deepinfra.com/v1/text-to-speech/{voice_id}/stream"
payload = {
"text": "I'm beginnin' to feel like a Rap God, Rap God
All my people from the front to the back nod, back nod
Now, who thinks their arms are long enough to slap box, slap box?
They said I rap like a robot, so call me Rap-bot",
"model_id": "hexgrad/Kokoro-82M",
"output_format": "mp3",
"language_code": "<string>"
}
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: 'I\'m beginnin\' to feel like a Rap God, Rap God\nAll my people from the front to the back nod, back nod\nNow, who thinks their arms are long enough to slap box, slap box?\nThey said I rap like a robot, so call me Rap-bot',
model_id: 'hexgrad/Kokoro-82M',
output_format: 'mp3',
language_code: '<string>'
})
};
fetch('https://api.deepinfra.com/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://api.deepinfra.com/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' => 'I\'m beginnin\' to feel like a Rap God, Rap God
All my people from the front to the back nod, back nod
Now, who thinks their arms are long enough to slap box, slap box?
They said I rap like a robot, so call me Rap-bot',
'model_id' => 'hexgrad/Kokoro-82M',
'output_format' => 'mp3',
'language_code' => '<string>'
]),
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.deepinfra.com/v1/text-to-speech/{voice_id}/stream"
payload := strings.NewReader("{\n \"text\": \"I'm beginnin' to feel like a Rap God, Rap God\\nAll my people from the front to the back nod, back nod\\nNow, who thinks their arms are long enough to slap box, slap box?\\nThey said I rap like a robot, so call me Rap-bot\",\n \"model_id\": \"hexgrad/Kokoro-82M\",\n \"output_format\": \"mp3\",\n \"language_code\": \"<string>\"\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.deepinfra.com/v1/text-to-speech/{voice_id}/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"I'm beginnin' to feel like a Rap God, Rap God\\nAll my people from the front to the back nod, back nod\\nNow, who thinks their arms are long enough to slap box, slap box?\\nThey said I rap like a robot, so call me Rap-bot\",\n \"model_id\": \"hexgrad/Kokoro-82M\",\n \"output_format\": \"mp3\",\n \"language_code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deepinfra.com/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["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"I'm beginnin' to feel like a Rap God, Rap God\\nAll my people from the front to the back nod, back nod\\nNow, who thinks their arms are long enough to slap box, slap box?\\nThey said I rap like a robot, so call me Rap-bot\",\n \"model_id\": \"hexgrad/Kokoro-82M\",\n \"output_format\": \"mp3\",\n \"language_code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Query Parameters
Body
application/json
Text to convert to speech
Example:
"I'm beginnin' to feel like a Rap God, Rap God\nAll my people from the front to the back nod, back nod\nNow, who thinks their arms are long enough to slap box, slap box?\nThey said I rap like a robot, so call me Rap-bot"
Model ID to use for the conversion
Output format for the speech
Available options:
mp3, opus, flac, wav, pcm Examples:
"mp3"
"opus"
"flac"
"wav"
"pcm"
ISO 639-1, 2-letter language code
Response
Successful Response