Selecting audio input or output device

Hello @Ayush_Kumar_Shah, welcome to the forums !

This is a super use case you have here :smiley: I had a similar usecase where I wanted to record my voice via Streamlit and then make a “chipymunk” version of it.

I think I remember why I had to put it down for now :

  • My initial take was to select the recording audio device through sounddevice, or in your case through pyaudio, but this selects the recording device on Streamlit’s server, not on the user facing web page. So if your app is deployed, selecting the recording device for the server is not very interesting

  • My second take would be to use some HTML5 input audio capture, but I think this needs some JS processing, and Streamlit does not support that yet.
    • That could be an interesting Custom Component to write.
    • If you a super courageous, though this is more of a hack that I have yet to test, you can run ipywidgets in Bokeh 2 so you could try ipywebrtc inside st.bokeh_chart, have the output file streamed in a temporary folder and have Streamlit watch that folder

  • You could cheat the system by pre-recording your guitar play and send it through the file uploader in the meantime (that’s ultimately what I did when translating the DDSP Colab demo to Streamlit
)
    • Did not skim the Streamlit File Uploader source code but maybe it’s possible to enhance it with audio capture capabilities ? There are github issues here and here, we can add our use cases there and see if more people are interested in this feature natively in Streamlit or as a custom component. I would be a big fan for audio/video input in native Streamlit though, because “Deep Learning”

Hope this helps a bit :upside_down_face:

2 Likes