Abcdef GHI
Abcdef GHI

Reputation: 115

Stream audio with JS - audio buffer coming from Python

I have a Python script that generates an audio buffer every 170 ms. I would like to live stream this audio on a webpage.

What's the easiest way to do so? Should I create a socket between the JS and the Python codes (with 'net'?) and then treat the buffer in JS? Is there an even easier way I can't think of?

Thanks!

Upvotes: 2

Views: 1072

Answers (1)

Leo
Leo

Reputation: 1303

You can use websockets and put the data into an AudioBuffer. This will allow you to send binary data to the webpage, process it in JavaScript and play it. You can either use a library for implementing the websocket server or a library that integrates with your web framework if you're using one.

That said, an easier method could be just sending an HTTP audio stream and playing it with the <audio> tag.

Upvotes: 1

Related Questions