For speech, just use this bit of code (its something Danny and I wrote for a private game engine, but it allows usage of speech APIs on Linux, Mac and windows, so no reason to not reveal it):
import platform
if platform.system()=="Windows":
import Tolk
elif platform.system()=="Linux":
import speechd
elif platform.system()=="Darwin":
from AppKit import *
# global variable.
client = None
# Iinitialize the TTS engine based on platform
def initialize():
if platform.system()=="Windows":
Tolk.load()
elif platform.system()=="Linux":
client = speechd.SSIPClient("")
elif platform.system()=="Darwin":
client=NSSpeechSynthesizer.alloc().initWithVoice_(None)
# Speak text
def say(text, interrupt=False):
if platform.system()=="Windows":
if interrupt:
Tolk.output(text, True)
else:
Tolk.output(text)
elif platform.system()=="Linux":
if interrupt:
client.cancel()
client.speak(text)
elif platform.system()=="Darwin":
if interrupt:
client.stopSpeaking()
client.startSpeakingString_(text)
# De-initialize the TTS engine
def shutdown():
if platform.system()=="Windows":
Tolk.unload()
elif platform.system()=="Linux":
client.close()
elif platform.system()=="Darwin":
client.release()
Give this a try, see how it works for you. If you want to modif ythis file, beware of the APIs your using. For windows, its Tolk, so you'll need tolk.py; for Mac OS, you'll need AppKit and the Python objective-C bindings; and for Linux, you'll need speech dispatcher and its Python module. I've done my best to disassociate it from the engine framework.
Also, for those who are curious to ask: I am only releasing this because it would actually prove quite useful to the community. I highly doubt I'll release much, if any, other code from this particular engine.
"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." — Charles Babbage.
My Github