From b444e857d78b15a9465632c009bcb88ec4a2a23e Mon Sep 17 00:00:00 2001 From: "rob@marotori.com" Date: Thu, 18 Jul 2013 19:54:03 +0000 Subject: [PATCH] Update to tts.py to enable support for the "2cnd speech" software. The software is a sapi wrapper and makes cleaner sapi wavs than the ttsPY system. --- util/tts.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/util/tts.py b/util/tts.py index e1c46e0ac..8c46a350b 100644 --- a/util/tts.py +++ b/util/tts.py @@ -15,7 +15,7 @@ # replace TTSFast.py with an empty file. This way the version-dependent pyd file isn't loaded. # in addition you will need some tools. -# ffmpeg, sox, adconvertor. +# ffmpeg, sox, adconvertor ttscmd (2cnd speach centre) # have fun! # Sound pack maintainers (incomplete list) # French : Bertrand Songis & André Bernet @@ -45,7 +45,10 @@ def filename(idx, alternate=0): def generate(str, filename): print filename, str - + + if not str: + str = " !" #this is so blank wav files never exist! + if "speak" in sys.argv: if "sapi" in sys.argv: tts.Speak(str) @@ -89,6 +92,9 @@ def generate(str, filename): o.writeframes(f[2*start:-2*end]) o.close() os.remove(ttsfilenameraw) + elif "sapi2" in sys.argv: + ttsfilename = "ttsfile.wav" + subprocess.Popen(["ttscmd", "/ttw",str.encode("utf-8"),ttsfilename, "-v", voiceID, "-b", "32"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait() elif "espeak" in sys.argv: ttsfilename = "ttsfile.wav" subprocess.Popen(["espeak", "-v", espeakVoice, "-s", espeakspeed, "-z", "-w", ttsfilename, str.encode("utf-8")], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait() @@ -617,6 +623,23 @@ if __name__ == "__main__": else: tts.SetVoiceByName("ScanSoftFiona_Full_22kHz") voice = "english-english" + elif "sapi2" in sys.argv: + if "scottish" in sys.argv: + voiceID = "17" + voice = "english-english" + elif "american" in sys.argv: + voiceID = "19" + voice = "english-american" + elif "australian" in sys.argv: + voiceID = "20" + voice = "english-australian" + elif "irish" in sys.argv: + voiceID = "21" + voice = "english-irish" + else: + voiceID = "17" + voice = "english-english" + elif "espeak" in sys.argv: espeakVoice = "mb-us1" espeakspeed = "150"