mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
simplification of tts.py
This commit is contained in:
parent
1c0a1cf777
commit
314bda18cb
1 changed files with 44 additions and 52 deletions
10
util/tts.py
10
util/tts.py
|
@ -24,7 +24,6 @@ import os, sys, shutil, platform, subprocess, wave, zipfile
|
|||
|
||||
def generate(str, idx):
|
||||
result = None
|
||||
if str and platform.system() == "Windows":
|
||||
if "speak" in sys.argv:
|
||||
if "sapi" in sys.argv:
|
||||
tts.Speak(str)
|
||||
|
@ -60,7 +59,7 @@ def generate(str, idx):
|
|||
subprocess.Popen(["AD4CONVERTER", "-E4", result], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
|
||||
result = result.replace(".wav", ".ad4")
|
||||
elif 'sox' in sys.argv:
|
||||
maxvolume=subprocess.Popen(["sox",result,"-n","stat","-v"],stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1]
|
||||
maxvolume = subprocess.Popen(["sox",result,"-n","stat","-v"],stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1]
|
||||
if "not sound" in maxvolume:
|
||||
os.rename(result, temp)
|
||||
subprocess.Popen(["sox", "--show-progress",result,temp],stdout=subprocess.PIPE).communicate()[0];
|
||||
|
@ -72,13 +71,6 @@ def generate(str, idx):
|
|||
os.rename(result, temp)
|
||||
subprocess.Popen(["ffmpeg", "-y", "-i", temp, "-acodec", "pcm_alaw", "-ar", "16000", result], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
|
||||
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:
|
||||
return [(result, str)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue