如何在Debian Python中播放声音文件?

时间:2022-05-19 12:16:11

sorry if this is a bit noobish but it's my first post. I am trying to open a .wav file (could be any though) in Python, on Debian Linux (on my raspberry Pi) I can't find any soloution that actually works, most modules are too old and don't work. I would preferablly like it to be as simple as possible. I just want the Python script to automatically play a sound file with the default audio player.

对不起,如果这有点讽刺,但这是我的第一篇文章。我试图在Python中打开一个.wav文件(可能是任何),在Debian Linux上(在我的覆盆子Pi上)我找不到任何实际可行的解决方案,大多数模块太旧而且不起作用。我希望它尽可能地简单。我只是希望Python脚本能够使用默认音频播放器自动播放声音文件。

1 个解决方案

#1


0  

Pyglet should work. Something like this:

Pyglet应该工作。像这样的东西:


    import pyglet

    sound = pyglet.resource.media('file.wav', streaming=False)
    sound.play()

I dont think it is preinstalled on the pi, but it's less than 1mb.

我不认为它是预装在pi上的,但它不到1mb。

#1


0  

Pyglet should work. Something like this:

Pyglet应该工作。像这样的东西:


    import pyglet

    sound = pyglet.resource.media('file.wav', streaming=False)
    sound.play()

I dont think it is preinstalled on the pi, but it's less than 1mb.

我不认为它是预装在pi上的,但它不到1mb。