Gradio, HTML5 Games and AR/VR, Pygame - Getting Sound to Work?

Emboldened by the power of Gradio and HTML5, I have been playing around with the ideas of trying to get python based game code to work in Gradio. I used to teach an augmented and virtual reality course and wanted to see if I could migrate some examples into the HF platform to teach and demo there.

PlayCanvas worked great in HTML5. Demo here: 🏎️PlayCanvasSimPhysics🤖 - a Hugging Face Space by awacke1
It worked great but reference is to one line playcanvas shell out to a compiled PlayCanvas ( game which similar to Unity provides a HTML5 solution using webassembly and javascript so works in your HTML5 SDK.

The HTML5 pattern also worked for Aframe and I found that I can do Augmented Reality which works on mobile devices. Example here: AR VR IOT Demo - a Hugging Face Space by awacke1

With my tests for pygame I run into a sound processing issue where it attempts to look for a sound card but since its a docker container it cant find one and errors. Example here:PyGame2D - a Hugging Face Space by awacke1

This is the error:

pygame 2.1.2 (SDL 2.0.16, Python 3.8.9)
Hello from the pygame community. Contribute - pygame wiki
ALSA lib confmisc.c:767:(parse_card) cannot find card ‘0’
ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM default
Traceback (most recent call last):
File “”, line 4, in
pygame.error: ALSA: Couldn’t open audio device: No such file or directory

Is there any way to get that part to work with the pygame.mixer.init() ?

Very cool spaces @awacke1 !

Can you disable sound on pygame?

I’m not familiar with PyGame though!

I will figure out how and try. It happens during load but there probably is a way to avoid loading the sound driver.