Python MusicalBeeps 导致错误

我开始使用模块MusicalBeeps尝试在 Python 中播放音乐,但是,每当我尝试让播放器播放噪音时,我都会遇到一个巨大的错误。我的代码现在看起来像这样:


import musicalbeeps as music


global TempPlayer


def 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 = None


print("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 directory

ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings

ALSA lib conf.c:4528:(_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:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory

ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default

Traceback (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 模块下载到文件中。


请帮忙,我只是想做一个简单的项目😀


杨__羊羊
浏览 154回答 1
1回答

慕田峪9158850

感谢您提供已安装包的链接 - 它可以更轻松地找到解决方案。MusicalBeeps 依赖于 simpleaudio,它需要(至少在 linux 上——当你发布 ALSA 错误时,我假设这是 Linux)安装 libasound2-dev 开发库。请参阅https://simpleaudio.readthedocs.io/en/latest/installation.html#linux-dependencies
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python