run other program without waiting?


Good news!!
I have gotten the open source TTS program Espeak working from blender. My blender game engine can talk to me :smiley:

Bad news :
The only problem is that when it loads the command line version of Espeak the game engine freezes until it is done reading the script.

Here is how I have it set up, I have this script wired to a keypress sensor:

[LEFT]import os

os.system(“espeak -f scriptname.txt”)[/LEFT]

Is there some way to just tell blender to send off that command, and not wait until the reading is complete to continue with the game?

here is my test file :

Here is a link to Espeak, you will need this installed for espeak to function properly.

Can we use “” in the BGE?
how about “subprocess.Popen()” ?

would those even help?

This would be awesome to get running smooth with blender.
Just think!, rather than having hundreds of megabytes of speech sound files for an RPG game, you could have just simple text scripts for the TTS system to recite for the NPC’s dialogs, and for narrating parts of the story .

Thanks in advanced for any help :smiley:

Disregard! =D

“Anyone dressed as a turkey is bound to be insane, or employed by a large company.” – Galit C. Harris

Blender’s implementation of Python doesn’t support multi-threading, which would get round this issue and also allow you to use more than one CPU with a Python script.

Maybe what you can try is executing a Python script using os.system and in that script use Python threading. Not entirely sure if that would work or how you’d get the data back from the thread though.

You can use function spawnl() from os module:

import os
os.spawnl(os.P_NOWAIT, 'c:/windows/notepad.exe', 'notepad.exe', 'readme.txt')

This code opens Python’s readme file with notepad. Constant os.P_NOWAIT causes that python is not waiting until notepad is closed.

Thanks guys!

Hi ashsid,
When I try your example I get this error:
AttributeError: ‘module’ object has no attribute ‘NO_WAIT’

is there another way to do it?

I am amazed about how many ways there are to open programs from inside blender :slight_smile:

Well, you could have it in a .py script like

import os
import thread

class Speech:
   def __init__(self):

   def talk(self):
      os.system("espeak -f scriptname.txt")

And then in blender have a script that goes

import talker

And that is a way to get threading in blender is by importing something and having that run the thread, because blenders thing cannot run the thread or start the thread it all has to be in another script


it seems you have misstyped the command. There is no NO_WAIT constant, but P_NOWAIT.

Function spawnl() is standard function from os module and is awailable on Win, linux and Mac. Just check the Python library documentation.


You did it!

Thank you so much :slight_smile:

Bad test link
Can I get some help I’d like to see how to do this kind of thing