how to play audio in python code example
Example 1: play music from python
from playsound import playsound
playsound('audio.mp3')
Example 2: Play sound in python
import winsound
winsound.PlaySound('sound.wav', winsound.SND_FILENAME)
Example 3: play sound directly with pytts
import pyttsx
engine = pyttsx.init()
engine.say('Good morning.')
engine.runAndWait()
Example 4: how to play sound in python
import playsound from playsound
playsound("C:\\file_link\\file_name")
Example 5: python mac play audio
import os
os.system("afplay sound.wav")
os.system("afplay sound.wav&")