sounddevice.OutputStream as api response
Hello! I have created an flask api app that is supposed to send an audio stream as a response to client's post request. Client sends input text, my app receives the text, triggers my Text to Speech engine, gets the generated audio as a numpy array.
Now I want to create audio from this numpy array and send audio stream back to user on the fly without writing a wav/mp3 file on the disk.
Can I use sounddevice.OutputStream in this case. If so, how can I do this?!
I'd very much appreciate any kind of suggestion / help!
Thanks in advance!
I'm not sure if I understand this.
You are talking about a server application running in Python (using Flask).
But what's running on the client?
If the client is just a web browser, I guess the answer is "no". You would have to use some browser technology (e.g. JavaScript?) to play the sound on the client side.
If you client is a Python program, the answer might be "yes". If that's the case, can you please provide a few more details?
If you use sounddevice.OutputStream on the server, the sound will be played on the servers audio hardware (if there is any), which is probably not what you want?
@mgeier Thanks for your response! Yes It's a server application. The client is a JavaScript application which is capable of sending an api request , get the data and play the audio. I also use a curl request for testing the api app. I just need to get an http 200 message! Just need to get ensured that I am getting the data. And yes I don't want to play audio on server hardware!
The client is a JavaScript application which is capable of sending an api request , get the data and play the audio.
OK, since you are not using Python, you will not be able to use sounddevice.OutputStream.
I just need to get an http 200 message! Just need to get ensured that I am getting the data.
You will have to do this with JavaScript, right?
So the question is off topic here.