Docker Remote Deployment with Sound

This is a typical misunderstanding of how Streamlit works.
I am pretty sure that pyaudio does NOT use the browser to access audio devices.

Think about how that works technically for a moment:
When pyaudio wants to record/playback audio data, it accesses the audio hardware of the machine running the Streamlit application. But in the Azure container (or in any other hosted system) there is no audio-driver, no audio-hardware and no microphone. And even if there were, all you’d hear is the hiss of fans in a server rack or the scolding of a Microsoft technician. :stuck_out_tongue_winking_eye:

If you test this app locally, it happens to work because the client and server are identical, but once the Streamlit app is hosted, this approach is doomed to failure. Any user interaction in a Streamlit application must be done through the browser respectively browser APIs. That means you have to use a Streamlit component for audio recording/playback (and also any other hardware access on the clients side).

Below there are some custom Streamlit components on GitHub you might be able to use for this. I haven’t used them yet and it depends on your exact use-case.

  • streamlit-webrtc
  • streamlit-audiorecorder
  • audio-recorder-streamlit
  • streamlit_audio_recorder
  • streamlit-bokeh-events

You could also use st.file_uploader to upload an audio file or use requests to download the audio file from another source on the internet.

Here are some other threads that are also about this topic:

Maybe streamlit will also get a built-in component in the future that allows audio recording, but this is just speculation.