3

Debian OS. I call a subprocess

subprocess.Popen([sys.executable, "/home/pi/play_sound.py"])

And in play_sound.py, I play a sound with:

def load_sound(url):
    class NoneSound:
        def play(self): pass
    if not pygame.mixer or not pygame.mixer.get_init():
        return NoneSound()
    fullname = url
    try:
        sound = pygame.mixer.Sound(fullname)
    except pygame.error, message:
        print 'Cannot load sound:', fullname
        raise SystemExit, message
    return sound

The problem is that when I run play_sound.py separately, it works fine. But when I call it as a subprocess of another py file, it does not play the sound.

mata
  • 60,113
  • 7
  • 139
  • 148

0 Answers0