Skip to main content
Qwen3-TTS is a preview feature available for SambaStack users only. Preview features may change before general availability.
SambaStack provides text-to-speech (TTS) capabilities through the qwen3-tts model, which converts text input into streaming PCM audio. The model supports 11 languages.

Qwen3-TTS

  • Model ID: qwen3-tts
  • Provider: Qwen (Alibaba Cloud)
  • Endpoint: POST /v1/audio/speech
  • Status: Preview

Supported voices

The voice parameter is accepted for API compatibility but is currently ignored. Audio is always generated using the reference voice configured at deployment time.
Voice IDDescription
serenaFemale
vivianFemale
uncle_fuMale
ryanMale
aidenMale
ono_annaFemale
soheeFemale
ericMale
dylanMale

Supported languages

LanguageAccepted values
Auto (detect)auto
ChineseChinese, zh, cn, chi
EnglishEnglish, en, eng
FrenchFrench, fr, fra, fre
GermanGerman, de, ger
ItalianItalian, it, ita
JapaneseJapanese, ja, jp, jpn
KoreanKorean, ko, kor
PortuguesePortuguese, pt, por
RussianRussian, ru, rus
SpanishSpanish, es, spa
Language matching is case-insensitive. If you omit the language parameter, it defaults to english.

Request parameters

ParameterTypeRequiredDescription
modelstringYesMust be qwen3-tts.
inputstringYesText to synthesize into speech.
voicestringNoSpeaker voice ID. Accepted for API compatibility; any value is currently ignored. See Supported voices.
streambooleanYesMust be true. Non-streaming responses are not yet supported.
languagestringNoLanguage of the input text. Default: english. See Supported languages.
instructionsstringNoInstructions to influence speaking style. Maximum 512 characters.
sampling_paramsobjectNoSampling configuration. Accepted keys: temperature, top_k, top_p, seed. Example: {"temperature": 0.8, "seed": 42}.

Example usage

import base64
import json
import struct
import wave
import requests

url = "https://your-sambanova-base-url/v1/audio/speech"
headers = {
    "Authorization": "Bearer your-sambanova-api-key",
    "Content-Type": "application/json",
}
payload = {
    "model": "qwen3-tts",
    "input": "Hello, welcome to SambaNova.",
    "voice": "serena",
    "language": "english",
    "stream": True,
}

pcm_frames = []

with requests.post(url, headers=headers, json=payload, stream=True) as resp:
    resp.raise_for_status()
    for line in resp.iter_lines():
        if not line or not line.startswith(b"data: "):
            continue
        data = line[len(b"data: "):]
        if data == b"[DONE]":
            break
        event = json.loads(data)
        if event.get("finish_reason") == "error":
            raise RuntimeError(f"Stream error: {event.get('error')}")
        audio_b64 = event.get("audio_b64", "")
        if audio_b64:
            pcm_frames.append(base64.b64decode(audio_b64))
        if event.get("finish_reason") == "stop":
            break

# Write f32le PCM frames to a WAV file
pcm_bytes = b"".join(pcm_frames)
num_samples = len(pcm_bytes) // 4  # 4 bytes per f32 sample
samples = struct.unpack(f"{num_samples}f", pcm_bytes)
pcm_int16 = bytes(
    struct.pack("<h", max(-32768, min(32767, int(s * 32767)))) for s in samples
)

with wave.open("output.wav", "wb") as wf:
    wf.setnchannels(1)
    wf.setsampwidth(2)  # 16-bit
    wf.setframerate(24000)
    wf.writeframes(pcm_int16)

print("Saved output.wav")
# This command shows the raw SSE stream. Use the Python example to produce a playable audio file.
curl -X POST https://your-sambanova-base-url/v1/audio/speech \
  -H "Authorization: Bearer your-sambanova-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-tts",
    "input": "Hello, welcome to SambaNova.",
    "voice": "serena",
    "language": "english",
    "stream": true
  }'

Response format

The endpoint streams a Server-Sent Events (SSE) response. Each event is a JSON object on a data: line. Response headers
HeaderValueDescription
Content-Typetext/event-streamSSE stream
X-Audio-Formatf32le32-bit float, little-endian PCM
X-Audio-Sample-Rate2400024 kHz sample rate
X-Audio-Channels1Mono
Event fields
FieldTypeDescription
audio_b64stringBase64-encoded PCM audio chunk.
chunk_indexintegerSequential index of the audio chunk.
finish_reasonstring | nullnull while streaming; "stop" on the final chunk; "error" if the stream fails mid-way.
idstringRequest identifier.
objectstringAlways audio.speech.chunk.
createdintegerUnix timestamp.
Example event
{
  "audio_b64": "<base64-encoded PCM data>",
  "chunk_index": 0,
  "finish_reason": null,
  "id": "abc123",
  "object": "audio.speech.chunk",
  "created": 1750000000
}
Final event
{
  "audio_b64": "<base64-encoded PCM data>",
  "chunk_index": 12,
  "finish_reason": "stop",
  "id": "abc123",
  "object": "audio.speech.chunk",
  "created": 1750000000
}

Limitations

  • Streaming only: stream: false is not supported. All responses are SSE streams.
  • Concurrency: The model processes one request at a time. Concurrent requests queue behind the active request.
  • Maximum audio length: 320 seconds per request. If the input text is long enough to exceed this limit, the response ends at the cap – no error is returned. For longer audio, split the text into smaller passages and send separate requests.
  • Mid-stream audio artifacts: Longer audio clips may contain audible artifacts partway through the stream. If you encounter this, split the input into shorter passages and send separate requests.
  • No context cache: Each request is stateless.