POST
/
synthesis
/
text-to-speech
/
stream-async
Streaming async TTS
import requests
import json

# Step 1: Initiate streaming async TTS
url = "https://api.upliftai.org/v1/synthesis/text-to-speech/stream-async"

payload = json.dumps({
  "voiceId": "v_meklc281",
  "text": "سلام، یہ پاکستان کی تاریخ کے بارے میں ہے۔",
  "outputFormat": "MP3_22050_128"
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_KEY'
}

response = requests.post(url, headers=headers, data=payload)
result = response.json()

# Step 2: Stream audio with ~300ms first chunk
media_id = result['mediaId']
token = result['token']

audio_url = f"https://api.upliftai.org/v1/synthesis/stream-audio/{media_id}?token={token}"

# This URL supports chunked streaming
# First chunk arrives in ~300ms
{
  "mediaId": "media_abc123xyz",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Authorizations

Authorization
string
header
required

API key with format "Bearer sk_api_..."

Body

application/json

Request for asynchronous text-to-speech synthesis

Response

200
application/json

Successfully initiated streaming synthesis

Response containing mediaId and token for retrieving synthesized audio