elevenlabs-python icon indicating copy to clipboard operation
elevenlabs-python copied to clipboard

Stream function error: MPV can't access audio drivers (Streamlit web app)

Open SuibhneOFoighil opened this issue 1 year ago • 2 comments

Is there any way to use the stream function on the cloud-deployed web app?

I'm using it in a very simple Streamlit app. Although it works on my local device, the stream function doesn't play any sound on Streamlit cloud or within a Docker container. Specifically, this line just doesn't work: mpv_process.stdin.write(chunk) # type: ignore. It seems like MPV cannot access the system's audio drivers in streamlit cloud or in a Docker container. Here's the stderror output for the mpv_process on Streamlit cloud:

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'\nALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory\nALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings\nALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory\nALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name\nALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory\nALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory\nALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default\nCannot connect to server socket err = No such file or directory\nCannot connect to server request channel\njack server is not running or cannot be started\nJackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock\nJackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock\nALSA lib confmisc.c:767:(parse_card) cannot find card '0'\nALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory\nALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings\nALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory\nALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name\nALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory\nALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory\nALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default\nALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card\ncouldn't open play stream: No such file or directory\n

On streamlit cloud, when i list the audio devices with mpv --audio-device=help", this is what I receive:

List of detected audio devices: 
'auto' (Autoselect device) '
alsa' (Default (alsa)) 
'jack' (Default (jack)) '
sdl' (Default (sdl)) 
'sndio' (Default (sndio))

Any advice here? I want to 'hear' the audio on a deployed webapp. It doesn't have to be on streamlit cloud but I want the stream function to work.

SuibhneOFoighil avatar Sep 18 '23 16:09 SuibhneOFoighil

I tested locally on streamlit but only the source machine plays the audio...not sure if the 2 are connected from your issue.

I'm curious to this thread as I'm planning to spin up a cloud instance (debating providers now) I'm wondering if some providers have issues ... streamlit being one since I also am testing on streamlit.

I'll let you now what I find

nafets33 avatar Sep 24 '23 22:09 nafets33

Hey guys, did you find a fix to this? trying to do something similar

faisal-saddique avatar Mar 03 '24 14:03 faisal-saddique