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 awacke1It worked great but reference is to one line playcanvas shell out to a compiled PlayCanvas (https://playcanvas.com/) 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 awacke1With 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 awacke1This is the error:pygame 2.1.2 (SDL 2.0.16, Python 3.8.9)Hello from the pygame community.Contribute - pygame wikiALSA 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 directoryALSA lib confmisc.c:392:(snd_func_concat) error evaluating stringsALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directoryALSA lib confmisc.c:1246:(snd_func_refer) error evaluating nameALSA lib conf.c:4568:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:5047:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM defaultTraceback (most recent call last):File “app.py”, line 4, inpygame.mixer.init()pygame.error: ALSA: Couldn’t open audio device: No such file or directoryIs there any way to get that part to work with the pygame.mixer.init() ?
2022-09-30T16:40:46Z
Very cool spaces@awacke1!Can you disable sound on pygame?redditr/pygame - Disable audio engine?4 votes and 3 comments so far on RedditI’m not familiar with PyGame though!
2022-10-04T12:43:01Z
I will figure out how and try.  It happens during load but there probably is a way to avoid loading the sound driver.