curl -X POST https://api.60db.ai/tts-stream \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"text": "This is a longer text that will be streamed in real-time.",
"voice_id": "default-voice",
"speed": 1,
"wpm": 150,
"stability": 50,
"similarity": 75
}' \
--no-buffer
import { SixtyDBClient } from "60db";
const client = new SixtyDBClient("your-api-key");
await client.textToSpeechStream(
{
text: "This is a longer text that will be streamed in real-time.",
voice_id: "default-voice",
speed: 1,
wpm: 150, // optional words per minute (60–300)
stability: 50,
similarity: 75,
},
{
onChunk: (chunk) => {
console.log("Received chunk:", chunk.length, "bytes");
// Play or process the audio chunk
},
onComplete: () => {
console.log("Streaming complete");
},
onError: (error) => {
console.error("Error:", error);
},
},
);
from sixtydb import SixtyDBClient
client = SixtyDBClient('your-api-key')
def handle_chunk(chunk):
print(f"Received {len(chunk)} bytes")
# Play or process the audio chunk
def handle_complete():
print("Streaming complete")
def handle_error(error):
print(f"Error: {error}")
client.text_to_speech_stream(
text='This is a longer text that will be streamed in real-time.',
on_chunk=handle_chunk,
on_complete=handle_complete,
on_error=handle_error,
voice_id='default-voice',
speed=1,
wpm=150, # optional words per minute (60–300)
stability=50,
similarity=75
)
{"type":"chunk","result":{"audioContent":"SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4..."}}
{"type":"chunk","result":{"audioContent":"//uQxAAAAAAAAAAAAAAASW5mbwAAAA8AAAAGAAA..."}}
{"type":"complete"}
{ "type": "error", "message": "Invalid voice_id" }
Text-to-Speech
Text to Speech Stream
Stream text to speech with real-time audio chunks
POST
/
tts-stream
curl -X POST https://api.60db.ai/tts-stream \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"text": "This is a longer text that will be streamed in real-time.",
"voice_id": "default-voice",
"speed": 1,
"wpm": 150,
"stability": 50,
"similarity": 75
}' \
--no-buffer
import { SixtyDBClient } from "60db";
const client = new SixtyDBClient("your-api-key");
await client.textToSpeechStream(
{
text: "This is a longer text that will be streamed in real-time.",
voice_id: "default-voice",
speed: 1,
wpm: 150, // optional words per minute (60–300)
stability: 50,
similarity: 75,
},
{
onChunk: (chunk) => {
console.log("Received chunk:", chunk.length, "bytes");
// Play or process the audio chunk
},
onComplete: () => {
console.log("Streaming complete");
},
onError: (error) => {
console.error("Error:", error);
},
},
);
from sixtydb import SixtyDBClient
client = SixtyDBClient('your-api-key')
def handle_chunk(chunk):
print(f"Received {len(chunk)} bytes")
# Play or process the audio chunk
def handle_complete():
print("Streaming complete")
def handle_error(error):
print(f"Error: {error}")
client.text_to_speech_stream(
text='This is a longer text that will be streamed in real-time.',
on_chunk=handle_chunk,
on_complete=handle_complete,
on_error=handle_error,
voice_id='default-voice',
speed=1,
wpm=150, # optional words per minute (60–300)
stability=50,
similarity=75
)
{"type":"chunk","result":{"audioContent":"SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4..."}}
{"type":"chunk","result":{"audioContent":"//uQxAAAAAAAAAAAAAAASW5mbwAAAA8AAAAGAAA..."}}
{"type":"complete"}
{ "type": "error", "message": "Invalid voice_id" }
Request
Headers
string
required
Bearer token with your API key
string
required
application/json
Body
string
required
The text to convert to speech (max 5000 characters)
string
ID of the voice to use
boolean
default:"true"
Enable audio enhancement
number
default:"1"
Speech speed multiplier (0.5 to 2.0)
number
Words per minute (optional). Target speaking rate in WPM. Range
60–300. When omitted, the voice’s default WPM is used (returned as wpm by GET /voices); voices without a measured default fall back to 137 WPM.number
default:"50"
Voice stability 0-100 (lower = more expressive, higher = more consistent)
number
default:"75"
Voice similarity 0-100 (how closely the output matches the source voice)
Response
The response is streamed as newline-delimited JSON (NDJSON). Each line contains a JSON object:Chunk Object
string
Type of message: “chunk”, “complete”, or “error”
object
Contains the audio chunk data
string
Base64-encoded audio chunk
string
Error message (only for error type)
curl -X POST https://api.60db.ai/tts-stream \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"text": "This is a longer text that will be streamed in real-time.",
"voice_id": "default-voice",
"speed": 1,
"wpm": 150,
"stability": 50,
"similarity": 75
}' \
--no-buffer
import { SixtyDBClient } from "60db";
const client = new SixtyDBClient("your-api-key");
await client.textToSpeechStream(
{
text: "This is a longer text that will be streamed in real-time.",
voice_id: "default-voice",
speed: 1,
wpm: 150, // optional words per minute (60–300)
stability: 50,
similarity: 75,
},
{
onChunk: (chunk) => {
console.log("Received chunk:", chunk.length, "bytes");
// Play or process the audio chunk
},
onComplete: () => {
console.log("Streaming complete");
},
onError: (error) => {
console.error("Error:", error);
},
},
);
from sixtydb import SixtyDBClient
client = SixtyDBClient('your-api-key')
def handle_chunk(chunk):
print(f"Received {len(chunk)} bytes")
# Play or process the audio chunk
def handle_complete():
print("Streaming complete")
def handle_error(error):
print(f"Error: {error}")
client.text_to_speech_stream(
text='This is a longer text that will be streamed in real-time.',
on_chunk=handle_chunk,
on_complete=handle_complete,
on_error=handle_error,
voice_id='default-voice',
speed=1,
wpm=150, # optional words per minute (60–300)
stability=50,
similarity=75
)
{"type":"chunk","result":{"audioContent":"SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4..."}}
{"type":"chunk","result":{"audioContent":"//uQxAAAAAAAAAAAAAAASW5mbwAAAA8AAAAGAAA..."}}
{"type":"complete"}
{ "type": "error", "message": "Invalid voice_id" }
Use Cases
Streaming is ideal for:- Real-time applications: Voice assistants, chatbots
- Long-form content: Articles, books, documents
- Low latency: Start playing audio before generation completes
- Progressive enhancement: Display text while generating audio