import pygame
# Initialize Pygame and its mixer
pygame.init()
pygame.mixer.init()
# Load the sound file
sound_file = 'path/to/your/soundfile.wav' # Replace with the path to your sound file
sound = pygame.mixer.Sound(sound_file)
# Play the sound
sound.play()
# Keep the program running until the sound is done playing
while pygame.mixer.get_busy():
pygame.time.delay(100)
Audio player