how to play sound with python code example
Example 1: Play sound in python
import winsound
winsound.PlaySound('sound.wav', winsound.SND_FILENAME)
Example 2: play sound directly with pytts
import pyttsx
engine = pyttsx.init()
engine.say('Good morning.')
engine.runAndWait()
Example 3: python mac play audio
import os
# Everything stops when played
os.system("afplay sound.wav")
# Everything continues when played
os.system("afplay sound.wav&")