Are there any libraries in Python that does or allows Text To Speech Conversion using Mac Lion\'s built in text to speech engine? I did google but most are windows based. I
If you are targeting Mac OS X as your platform - PyObjC and NSSpeechSynthesizer is your best bet.
Here is a quick example for you
#!/usr/bin/env python
from AppKit import NSSpeechSynthesizer
import time
import sys
if len(sys.argv) < 2:
text = raw_input('type text to speak> ')
else:
text = sys.argv[1]
nssp = NSSpeechSynthesizer
ve = nssp.alloc().init()
for voice in nssp.availableVoices():
ve.setVoice_(voice)
print voice
ve.startSpeakingString_(text)
while not ve.isSpeaking():
time.sleep(0.1)
while ve.isSpeaking():
time.sleep(0.1)
Please note that AppKit module is part of PyObjC bridge and should be already installed on your Mac. No need to install it if you are using OS provided python (/usr/bin/python)