I have a script that needs to play audio file (mp3) whenever an event occurs. I'm currently using omxplayer to do that. The audio file is about 300ms long and sometimes there could be very small interval between the events, as low as 10ms, but it takes a second or two for the omxplayer to start up and play it so it adds up to ~3 seconds of processing time where something like 600ms max would be acceptable..

Is there a way to play the file instantly? Maybe it's possible to pass a 'trigger' to already running omxplayer instance? Thanks!

  • What format is the audio file ? Have you tried 'aplay <file>' ?
    – CoderMike
    Sep 21, 2017 at 16:37

1 Answer 1


A quick fix might be simply using aplay instead of omxplayer. I was able to play near-real time sounds in response to keyboard input by calling aplay from my python script. If you need better response, you may want to look into using pygame to pre-load the sounds for playback rather than reading in the file each time.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.