我開始使用模塊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
提交
取消