Discussions
Investigating Missing Text Display Issue in Talk Streams Example with Modified Code Using For Loop to Create Talk Streams
10 months ago by Jacob
I modified some code in the Talk streams example and found that some words are not displayed when creating a talk stream in a for loop. I'm seeking the reason and solution for this issue.
startButton.onclick = async () => {
if (peerConnection?.signalingState === 'stable' || peerConnection?.iceConnectionState === 'connected')
{
const messagesList = [
"The concept of remote work has been steadily gaining traction over the past decade, but recent global events have catapulted it into the mainstream. ",
"The COVID-19 pandemic forced organizations worldwide to adapt quickly to remote work arrangements, accelerating a trend that was already underway.",
"Remote work, once seen as a perk offered by forward-thinking companies, has now become a necessity for many. ",
]
for(let message of messagesList) {
await sendMessage(message)
}
}
}
const sendMessage = async (message) => {
const playResponse = await fetchWithRetries(`${DID_API.url}/${DID_API.service}/streams/${streamId}`, {
method: 'POST',
headers: {
Authorization: `Basic ${DID_API.key}`,
'Content-Type': 'application/json',
"x-api-key-external": "{\"elevenlabs\": \"xxxxxxxxw\"}"
},
body: JSON.stringify({
script: {
"type":"text",
"input": message,
"provider":{
"type":"elevenlabs",
"voice_id":"21m00Tcm4TlvDq8ikWAM",
"model_id": "eleven_multilingual_v2"
},
},
...(DID_API.service === 'clips' && {
background: {
color: '#FFFFFF'
}
}),
config: {
stitch: true,
fluent: true,
auto_match: true,
pad_audio: 4.0,
},
session_id: sessionId,
}),
});
}