[Pythonmac-SIG] Speech Synthesis
has
hengist.podd at virgin.net
Tue Sep 28 12:33:12 CEST 2004
Juan Sebastián Lach wrote:
>Is there by any chance a version of the macspeech module than can work with
>OSX?? If not, would it be too difficult to implement? I want to control
>speech synthesis from Python and/or SuperCollider.
Dunno about direct bindings, but if you don't mind using OSA
scripting additions [<hack-spit>euwww] it's easy enough to do via the
Standard Additions' 'say' command using the osax and aem modules from
<http://freespace.virgin.net/hamish.sanderson/appscript.html>:
#######
#!/usr/local/bin/pythonw
from osax import osax
def say(text, display=None, voice=None, waiting=None, outputfile=None):
"""Speak the given text.
text : str -- the text to speak, which can include
intonation characters
display : str -- the text to display in the feedback
window (if different). Ignored unless Speech Recognition is on.
voice : str -- the voice to speak with. Ignored if
Speech Recognition is on.
waiting : bool -- wait for speech to complete before
returning (default is true). Ignored unless Speech Recognition is on.
outputfile : anything -- the alias, file reference or
Mac-style path string of an AIFF file (existing or not) to contain
the sound output.
"""
params = {'----':text}
for val, code in ((display, 'DISP'), (voice, 'VOIC'),
(waiting, 'wfsp'), (outputfile, 'stof')):
if val is not None:
params[code] = val
osax('syso', 'ttos', params)
# TEST
say('hello', voice='Zarvox')
#######
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
More information about the Pythonmac-SIG
mailing list