diff options
author | Walter Bender <walter.bender@gmail.com> | 2011-05-08 13:32:29 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2011-05-08 13:32:29 (GMT) |
commit | be16a7bc75aba305602a04724851005084096272 (patch) | |
tree | 359422c86d82dfb0aae13811dee50f41def1d0c4 /pysamples | |
parent | bd94ca24b3377cedaf45397f95d04bdccdf9ce57 (diff) |
added language support
Diffstat (limited to 'pysamples')
-rw-r--r-- | pysamples/speak.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pysamples/speak.py b/pysamples/speak.py index 7476d64..c84eb34 100644 --- a/pysamples/speak.py +++ b/pysamples/speak.py @@ -12,6 +12,7 @@ def myblock(tw, arg): ''' Text to speech ''' + TABLE = {'es': 'spanish'} import os pitch = None @@ -31,7 +32,14 @@ def myblock(tw, arg): if type(text) == float and int(text) == text: text = int(text) + lang = os.environ['LANG'][0:2] + if lang in TABLE: + language_option = '-v ' + TABLE[lang] + else: + language_option = '' if pitch is None: - os.system('espeak "%s" --stdout | aplay' % (text)) + os.system('espeak %s "%s" --stdout | aplay' % (language_option, + text)) else: - os.system('espeak "%s" -p "%s" --stdout | aplay' % (text, pitch)) + os.system('espeak %s "%s" -p "%s" --stdout | aplay' % ( + language_option, text, pitch)) |