#ive got this to work but now when i get audio back i just hear static: ```javascript con
1 messages · Page 1 of 1 (latest)
AI-generated Answer for dussk_
It looks like you are correctly streaming the audio data, but hearing static could be due to the audio format not being correctly handled. Ensure that the audio format you are using is compatible with the client receiving the stream. For example, Twilio often uses the μ-law format (ulaw) with an 8kHz sample rate.
Here's a revised version of your code snippet to ensure the audio format is set correctly:
const stsResponse = await elevenlabs.speechToSpeech.convertAsStream(
audioSample,
voices.female,
{
output_format: "ulaw_8000", // Ensure the correct audio format
}
);
console.log(stsResponse);
// Stream the audio data to the client
stsResponse.on("data", (chunk) => {
if (streamSid && textProcessing === finalTranscript.text) {
ws.send(
JSON.stringify({
streamSid,
event: "media",
media: {
payload: chunk.toString("base64"),
},
})
);
}
});
stsResponse.on("end", () => {
console.log("Audio stream ended");
textProcessing = null;
});
stsResponse.on("error", (error) => {
console.error("Error in audio stream", error);
});
Make sure to replace "ulaw_8000" with the appropriate format if you are using a different one. This should help resolve the issue of hearing static.
there doesnt seem to be a type of "output_format" on that function?