Espeak, Popen, Panda3D

As a fun little gimmic for the game I’m making I’d like the computer voice to be made using text to speech using espeak (due to its multi platform nature). I’m able to do this by running

p = subprocess.Popen(‘espeak’ + ’ “Hello. This is the sound of your computer being awesome”’, shell=True)

in the shell just fine. In a Panda3d application not so much. My guess is that I need to pipe the output through Panda3D audio system somehow, but I have not managed to figure out how. Any pointers?

That call just runs the espeak program in a subprocess, which ought to have nothing at all to do with Panda; it should work without having to interface with Panda’s audio. But maybe it’s failing because Panda has the audio locked and won’t release it? You might need to close your audio managers (or never open them in the first place). For instance, you could put:

audio-library-name null

in your Config.prc file to avoid opening an audio channel in Panda.


Why not make espeak output to a wav file and play that in panda? Something like this:

class Game:
    def __init__(self):
        self.synth = None
        taskMgr.add(self.mainLoop, 'main loop')
    def mainLoop(self, task):
        """Other loop stuff"""
        if self.synth:
            if self.synth.poll():
                speechWav = loader.loadSfx('speech.wav')
                self.synth = None
    def synthSpeech(self, text):
        self.synth = subprocess.Popen(['espeak', '-w', ''], shell=True)

drwr, I did as you suggested but still no change in behavior

Zerobyte, that is something I’m considering as a last resort. I’d like to stay away from reading/writing to disk, but we’ll see how this goes.