0

Hello there,

I search for a way to play audio files in Python in real time and with as less code as possible. I tried to use a gstreamer-command to play a pre-recorded sinewave:

os.system('gst-play-1.0 sine_wave.mp3')

But this solution is trash, as it must first load the media file and therefore has a 2 seconds latency before playing the sound. In this time, the program run stops. I search for a solution that can play sounds right away when called in the program and does not have an impact to the fluid run of it. So it should be capable of playing the sound multiple times in a second. Any ideas?

Thanks for the answers in advance!

Totemi1324
  • 468
  • 1
  • 6
  • 19
  • 1
    “*In this time, the program run stops*”: Why? Why does the program stop while waiting for gstreamer to play the file? By the way, there are gstreamer python bindings, to use gst APIs from Python code. – Gino Mempin Feb 22 '20 at 01:22
  • 1
    You tagged this with gstreamer, but there are a lot of other options for playing audio files with python: [Play audio with Python](https://stackoverflow.com/q/260738/2745495). If you are intent on using external commands, check out ALSA’s `aplay` command. – Gino Mempin Feb 22 '20 at 01:25

0 Answers0