1

For my program, I've been using subprocess to play my .wav files for my Python 3 program. However, when the sound is played, the program waits until the audio file is done playing before it runs the rest of the program.

I know for winsound and pygame there are ways to play sounds in sync with the program running, but I would prefer to stick with using subprocess because pygame hasn't been working out for me and I can't use winsound because I'm on a mac.

Here's what I have:

import subprocess

subprocess.call(["afplay", "sounds/dit.wav"])

Marcus Fong
  • 91
  • 2
  • 2
  • 10
  • Don't use the convenience functions of `subprocess`, they usually wait for the process to terminate. Use `Popen()` directly! – Klaus D. Mar 06 '18 at 01:19
  • Possible duplicate of [How can I run an external command asynchronously from Python?](https://stackoverflow.com/questions/636561/how-can-i-run-an-external-command-asynchronously-from-python) – George D. Mar 06 '18 at 03:44

0 Answers0