File size: 878 Bytes
a926f18 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
import subprocess,os
import imp
def TTSnorm(text, punc = False, unknown = True, lower = True, rule = False ):
A=imp.find_module('vinorm')[1]
#print(A)
I=A+"/input.txt"
with open(I, mode="w+", encoding="utf-8") as fw:
fw.write(text)
myenv = os.environ.copy()
myenv['LD_LIBRARY_PATH'] = A+'/lib'
E=A+"/main"
Command = [E]
if punc:
Command.append("-punc")
if unknown:
Command.append("-unknown")
if lower:
Command.append("-lower")
if rule:
Command.append("-rule")
subprocess.check_call(Command, env=myenv, cwd=A)
O=A+"/output.txt"
with open(O, mode="r", encoding="utf-8") as fr:
text=fr.read()
TEXT=""
S=text.split("#line#")
for s in S:
if s=="":
continue
TEXT+=s+". "
return TEXT
|