我正在尝试以更改的频率通过pygame.mixer.music播放“.mp3”文件。它在我的旧电脑上运行得非常好。我最近将该程序移到了我的新电脑上,并出现以下错误:
pygame.error: Could not initialize MPEG stream.
有时我会:
pygame.error: failed loading libmpg123.dll: attempt to access invalid address.
这些错误交替出现(非常奇怪)。这些错误指向以下行:
pygame.mixer.load(m)
我注意到的另一件事是,如果以下语句:
pygame.mixer.init(frequency=26000)
更改为:
pygame.mixer.init()
我的两台笔记本电脑的pygame版本都是1.9.6。python的旧版本是3.7.x,新版本是3.8.x。 整个代码如下:
def assistant_speaks(*texts):
for text in texts:
song_file = "temp.mp3"
speech = gTTS(text=text, lang='en-us', slow=False)
speech.save(song_file)
audio_length = MP3(song_file).info.length
print(text2)
mixer.init(frequency=26500)
with open(song_file) as f:
m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
mixer.music.load(m)
mixer.music.play()
sleep(audio_length)
mixer.music.stop()
mixer.quit()
pygame.quit()
m.close()
os.remove(song_file)
我多次尝试重新安装pygame。我使用升华文本和风筝来编码。我甚至重新安装了python
如果您能帮助解决此问题,我们将不胜感激。提前谢谢你! 或者你也可以建议我任何其他模块来改变频率和播放
编辑: 我已经能够通过卸载Python3.8和安装Python3.7来实现它。看起来这个问题仅在Python3.8中存在。我应该报告吗?怎么做
将pygame更新至2.0.0.dev6或更新版本。这应该可以解决这个问题。
pip install pygame==2.0.0.dev6
相关问题 更多 >
编程相关推荐