简体   繁体   中英

MP3 Audio Python

I am trying to play a file, but I do not know the command. Here is the image as to what my project looks like, and I am wondering if there is a way I can play the audio.

这是我的项目结构的屏幕截图。

My suggestion is pygame. Install via:

    pip3 install pygame

Download a.wav file to your.py file direction. Define a push button and connect to this function:

    def somesound(self):
        pygame.mixer.init()
        pygame.mixer.music.load('somesound.wav') # Pygame allows *.wav                       
        pygame.mixer.music.play(1) # For 1 second

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM