Nikola Mitic
Posted on June 5, 2024
For our case this part was easy, as all we need to do is:
- Get buffered chunk
- Write to response object
And it looks like this.
onChunkReceived: (chunk) => {
const buffer = Buffer.from(chunk, "base64");
res.write(buffer);
},
I will talk more about onChunkReceived method in the next section. Long story short, it it accepts a callback with chunk that come from web socket api. This is implementation details of how to work with Eleven Labs API.
Each time web socket sends an event that chunk is received it will write to response object and return chunk to the client.
This is the simplest way to combine express js with web socket api.
❤️If you would like to stay it touch please feel free to connect❤️
💖 💪 🙅 🚩
Nikola Mitic
Posted on June 5, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.