POST
/
synthesis
/
text-to-speech
/
stream
Stream text to speech Example JS
async function streamTextToSpeech() {
  try {
    const response = await fetch('https://api.upliftai.org/v1/synthesis/text-to-speech/stream', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_API_KEY'
      },
      body: JSON.stringify({
        voiceId: "v_8eelc901",
        text: "سلام، آپ اِس وقت اوریٹر کی آواز سن رہے ہیں۔",
        outputFormat: "MP3_22050_128"
      })
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status: ${response.status}`);
    }

    // Get the reader from the stream
    const reader = response.body.getReader();
    
    // Process each chunk as it arrives
    while (true) {
      const { done, value } = await reader.read();
      
      if (done) {
        break;
      }
      
      // Process each chunk
      // you can stream this audio to your to your clients etc.
    }
    
  } catch (error) {
    console.error('Error:', error);
  }
}
This response does not have an example.

Authorizations

Authorization
string
header
required

API key with format "Bearer sk_api_..."

Body

application/json

Request for text-to-speech synthesis

Response

200
audio/*

Successful audio synthesis

The response is of type file.