我开始使用模块MusicalBeeps尝试在 Python 中播放音乐,但是,每当我尝试让播放器播放噪音时,我都会遇到一个巨大的错误。我的代码现在看起来像这样:import musicalbeeps as musicglobal TempPlayerdef PlayNote(Note, Octive, Accidental, Duration, Volume): #Accidental is either # (sharp) or b (flat) or '' (none) global TempPlayer TempPlayer = music.Player(volume = float(Volume), mute_output = False) TempPlayer.play_note("{}{}{}".format(Note, Octive, Accidental), Duration) TempPlayer = Noneprint("Running...")PlayNote("B", 4, "#", 5, 1)print("Done!")这是他们在网站上展示的示例,但是每当我尝试运行它时,我都会收到这个奇怪的错误:ALSA lib confmisc.c:767:(parse_card) cannot find card '0'ALSA lib conf.c:4528:(_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:4528:(_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:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM defaultTraceback (most recent call last): File "main.py", line 13, in <module> PlayNote("B", 4, "#", 5, 1) File "main.py", line 9, in PlayNote顺便说一句,我正在使用repl.it来制作它,并且我已经将 musicbeeps 模块下载到文件中。请帮忙,我只是想做一个简单的项目😀
1 回答
慕田峪9158850
TA贡献1794条经验 获得超7个赞
感谢您提供已安装包的链接 - 它可以更轻松地找到解决方案。MusicalBeeps 依赖于 simpleaudio,它需要(至少在 linux 上——当你发布 ALSA 错误时,我假设这是 Linux)安装 libasound2-dev 开发库。请参阅https://simpleaudio.readthedocs.io/en/latest/installation.html#linux-dependencies
添加回答
举报
0/150
提交
取消