simplification of tts.py

This commit is contained in:
bsongis
2012-07-17 10:34:22 +00:00
parent 1c0a1cf777
commit 314bda18cb
-8
View File
@@ -24,7 +24,6 @@ import os, sys, shutil, platform, subprocess, wave, zipfile
def generate(str, idx): def generate(str, idx):
result = None result = None
if str and platform.system() == "Windows":
if "speak" in sys.argv: if "speak" in sys.argv:
if "sapi" in sys.argv: if "sapi" in sys.argv:
tts.Speak(str) tts.Speak(str)
@@ -72,13 +71,6 @@ def generate(str, idx):
os.rename(result, temp) os.rename(result, temp)
subprocess.Popen(["ffmpeg", "-y", "-i", temp, "-acodec", "pcm_alaw", "-ar", "16000", result], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait() subprocess.Popen(["ffmpeg", "-y", "-i", temp, "-acodec", "pcm_alaw", "-ar", "16000", result], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
os.remove(temp) os.remove(temp)
else:
if isinstance(idx, int):
subprocess.Popen(["espeak", "-v", espeakVoice, "-s", "160", "-z", "-w", "%04d.wav" % idx, str], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
result = "%04d.wav" % idx
else:
subprocess.Popen(["espeak", "-v", espeakVoice, "-s", "160", "-z", "-w", "%s.wav" % idx, str], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
result = idx + ".wav";
if result: if result:
return [(result, str)] return [(result, str)]