eshaz / icecast-metadata-js

Browser and NodeJS packages for playing and reading Icecast compatible streaming audio with realtime metadata updates.
164 stars 20 forks source link

Audio stream from a POST call #201

Open Bilal-io opened 3 months ago

Bilal-io commented 3 months ago

I am curious if there is a way to use the player by providing a ReadableStream instead of an endpoint like it's shown in the demo.

My goal is to make a POST call with a payload to a backend that does TTS then provides a chunked response.

eshaz commented 3 months ago

There is currently no way to provide your own ReadableStream, vs. having the library make the HTTP request for you. I'm not sure it would be possible to add this functionality since it would break some of the reconnect logic that relies on being able to create new ReadableStreams (i.e. connections) based on a stream URL. Also, a POST request to get the streaming audio is not Icecast compatible, and I don't plan on adding that functionality. The request to get the streaming data should always be a GET request.

You can get this to work as-is by changing your backend / design to provide an Icecast compatible stream URL that works with a GET request, then use that to instantiate the player.

What's TTS? Text to speech?