DEV Community

Cover image for Making your CV talk 🤖 How to send audio stream from Express JS?
Nikola Mitic
Nikola Mitic

Posted on

Making your CV talk 🤖 How to send audio stream from Express JS?

For our case this part was easy, as all we need to do is:

  1. Get buffered chunk
  2. Write to response object

And it looks like this.

    onChunkReceived: (chunk) => {
      const buffer = Buffer.from(chunk, "base64");
      res.write(buffer);
    },
Enter fullscreen mode Exit fullscreen mode

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❤️

  1. X
  2. Linkedin
  3. nikola.mitic.dev@gmail.com

Top comments (0)