How to stop audio with playsound module?

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()

Leave a Comment