4 """! @package utils.uid
8 from optparse
import OptionParser
9 parser = OptionParser()
10 parser.add_option(
"-i",
"--input", dest=
"input", action=
"store", help=
"input MDF file")
11 parser.add_option(
"-o",
"--output", dest=
"output", action=
"store", help=
"output MDF file")
12 options = parser.parse_args()[0]
16 in_file = open(options.input,
"r", encoding='utf-8')
17 out_file = open(options.output, "w", encoding=
'utf-8')
19 in_file = open(options.input,
"r")
20 out_file = open(options.output, "w")
24 if os.name ==
'posix':
32 sys.path.append(
'./pylmflib/utils/ipa2sampa')
33 from ipa2sampa
import uni2sampa
37 pattern =
r"^\\(\w{2,3}) ?(.*)$"
42 for line
in in_file.readlines():
43 result = re.search(pattern, line)
45 if result.group(1) ==
"lx" or result.group(1) ==
"se":
47 if result.group(1) ==
"se":
49 elif result.group(1) ==
"sf":
50 sf.append(result.group(2))
51 elif result.group(1) ==
"hm":
60 out_file.write(
"\\" + mkr +
" <id=\"" + uid.encode(
'utf-8') +
"\"> " + lx + EOL)
61 out_file.write(
"\\sf " + uid.replace(
'|',
u"€").replace(
'?',
'Q').replace(
'*',
'F').encode(
'utf-8') +
".wav" + EOL)
62 for i
in range (0, len(sf)):
63 out_file.write(
"\\sf " + sf[i] + EOL)
64 out_file.write(
"\\hm " + hm + EOL)