POST
/
v1
/
realtime
/
tts-stream
fetch('https://api.tryhamsa.com/v1/realtime/tts-stream', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Token YOUR_API_KEY'
},
body: JSON.stringify({ speaker: 'Ali', dialect: 'pls', text: 'Hello, world!', mulaw: false })
})
.then(response => {
const reader = response.body.getReader();
const chunks = [];

function read() {
reader.read().then(({ done, value }) => {
if (done) {
// Concatenate chunks and play entire stream
const blob = new Blob(chunks, { type: 'audio/wav' });
const url = URL.createObjectURL(blob);
const audio = new Audio(url);
audio.play();
return;
}

chunks.push(value);
read();
});
}

read();
})
.catch(console.error);
This response does not have an example.

Authorizations

Authorization
string
header
required

Pass the API key in the Authorization header, You need to put Token keyword before the API key. e.g. 'Authorization: Token <api-key>'

Body

application/json

Response

200
stream

Streamed Successful Response - Chunked

The response is of type file.