Assuming you are on Windows:
import winsound
winsound.PlaySound('alert.wav')
If you are running Linux (or Mac OS X, I believe), you can use pygame or call a Linux program (e.g. mplayer) with popen. Pygame example:
import pygame
pygame.init()
pygame.mixer.music.load("alert.ogg")
pygame.mixer.music.play()
pygame.event.wait()
An example of a use popenthat executes a command as if you were in a terminal:
from os import popen
cmd = "mplayer alert.ogg"
popen(cmd)
source
share