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"
}' \
--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",
},
{
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'
)
{"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"
}' \
--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",
},
{
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'
)
{"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.0"
Speech speed (0.5 to 2.0)
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"
}' \
--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",
},
{
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'
)
{"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