Discussions

Ask a Question
Back to All

Why cant we use a text string instead of an mp3 in the streaming API call?

talkButton.onclick = async () => {
// connectionState not supported in firefox

if (peerConnection?.signalingState === 'stable' || peerConnection?.iceConnectionState === 'connected') {
const talkResponse = await fetchWithRetries(${DID_API.url}/talks/streams/${streamId}, {
method: 'POST',
headers: {
Authorization: Basic ${DID_API.key},
'Content-Type': 'application/json',
},
body: JSON.stringify({
script: {
type: 'audio',
audio_url: 'https://demo.d1i7qazf9qm48c.amplifyapp.com/postwrap/GPTIntro.mp3',
},
driver_url: 'bank://lively/',
config: {
stitch: true,
},
session_id: sessionId,
}),
});
}
};

Should be more like the following...

talkButton.onclick = async () => {
// connectionState not supported in firefox

if (peerConnection?.signalingState === 'stable' || peerConnection?.iceConnectionState === 'connected') {
const talkResponse = await fetchWithRetries(${DID_API.url}/talks/streams/${streamId}, {
method: 'POST',
headers: {
Authorization: Basic ${DID_API.key},
'Content-Type': 'application/json',
},
body: JSON.stringify({
script: {
type: 'text',
voice_id: 'abc123'
script: 'Hello my name is bob.',
},
driver_url: 'bank://lively/',
config: {
stitch: true,
},
session_id: sessionId,
}),
});
}
};

Having to generate an mp3 before calling the streaming api is slow cumbersome and error prone.