Audio drivers, problems with playing the sound

I’m struggling with playing the url content. Locally it works perfect, but on Render deployment I’m getting error messages connected with ALSA libraries.
Is there any general solution how to solve the issues connected with audio drivers on the web server?

function:
def play_audio_from_url(url):
response = requests.get(url)
if response.status_code == 200:
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
temp_file.write(response.content)
temp_file.flush()
audio = AudioSegment.from_file(temp_file.name, format=“mp3”)
play(audio)
else:
print(“Error: Failed to download audio file”)

Error messages:
Jul 8 10:39:35 AM Home directory not accessible: Permission denied
Jul 8 10:39:35 AM nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
Input #0, wav, from ‘/tmp/tmpwyifhcyr.wav’:
Jul 8 10:39:35 AM Duration: 00:00:11.98, bitrate: 384 kb/s
Jul 8 10:39:35 AM Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 24000 Hz, 1 channels, s16, 384 kb/s
Jul 8 10:39:35 AM ALSA lib confmisc.c:767:(parse_card) cannot find card ‘0’
Jul 8 10:39:35 AM ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
Jul 8 10:39:35 AM ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
Jul 8 10:39:35 AM ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
Jul 8 10:39:35 AM ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
Jul 8 10:39:35 AM ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
Jul 8 10:39:35 AM ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
Jul 8 10:39:35 AM ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM default
Jul 8 10:39:35 AM SDL_OpenAudio (1 channels, 24000 Hz): ALSA: Couldn’t open audio device: No such file or directory
Jul 8 10:39:35 AM No more combinations to try, audio open failed
Jul 8 10:39:35 AM Failed to open file ‘/tmp/tmpwyifhcyr.wav’ or configure filtergraph

Hi there,

In our native environments, ALSA packages are not included in our base image. You probably need to look at deploying your service using Docker, were you have full control over the packages you install.

Regards,

Keith
Render Support, UTC+10 :australia:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.