how do i stop the audio playing through playaudio module in python code I have played music= playsound.playsound("name_of-file") but I cant stop that music. how can I stop it
playsound.playsound("name_of_file")
You can use the multiprocessing module to play the sound as a background process, then terminate it anytime you want:
import multiprocessing
from playsound import playsound
p = multiprocessing.Process(target=playsound, args=("file.mp3",))
p.start()
input("press ENTER to stop playback")
p.terminate()