From be16a7bc75aba305602a04724851005084096272 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sun, 08 May 2011 13:32:29 +0000 Subject: added language support --- (limited to 'pysamples/speak.py') 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)) -- cgit v0.9.1