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.