Browse Source

Final presentation, QTM > HTK converter, modifications to HTK wrappers

master
Sam Black 11 years ago
parent
commit
d6892afaac
10 changed files with 638 additions and 75 deletions
  1. BIN
      ee4p/docs/Presentations/bench_inspect-0903251358.odp
  2. BIN
      ee4p/docs/Presentations/bench_inspect-0903251358.pdf
  3. BIN
      ee4p/docs/Presentations/bench_inspect-0903251358.ppt
  4. BIN
      ee4p/docs/Presentations/system_block-200903261410.png
  5. +472
    -0
      ee4p/docs/Presentations/system_block-200903261410.svg
  6. +2
    -1
      ee4p/python/htk/htkconfig.py
  7. +80
    -63
      ee4p/python/htk/htkwrapper.py
  8. +11
    -11
      ee4p/python/htk/htkwrite.c
  9. +73
    -0
      ee4p/python/htk/htkwrite_transcribe.py
  10. BIN
      ee4p/python/htk/htkwritefile.so

BIN
ee4p/docs/Presentations/bench_inspect-0903251358.odp View File


BIN
ee4p/docs/Presentations/bench_inspect-0903251358.pdf View File


BIN
ee4p/docs/Presentations/bench_inspect-0903251358.ppt View File


BIN
ee4p/docs/Presentations/system_block-200903261410.png View File

Before After
Width: 960  |  Height: 613  |  Size: 49 KiB

+ 472
- 0
ee4p/docs/Presentations/system_block-200903261410.svg View File

@@ -0,0 +1,472 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1052.3622"
height="744.09448"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46+devel"
version="1.0"
sodipodi:docname="system_block-200903261410.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:export-filename="/home/sam/code/git/personal-uni/ee4p/docs/Presentations/system_block-200903261410.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4">
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lend"
style="overflow:visible;">
<path
id="path3815"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<inkscape:perspective
id="perspective2808"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2848"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2848-4"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2848-6"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2955"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3786"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3786-6"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2960"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3875"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3900"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3925"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3950"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.83591535"
inkscape:cx="501.32427"
inkscape:cy="372.04724"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1400"
inkscape:window-height="849"
inkscape:window-x="40"
inkscape:window-y="28" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:none;stroke:#ff0000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;fill-opacity:1"
id="rect2790"
width="128.0034"
height="105.27382"
x="235.85173"
y="299.81805"
ry="17.944401" />
<text
xml:space="preserve"
style="font-size:20px;font-weight:bold;text-align:center;text-anchor:middle"
x="299.4628"
y="334.60339"
id="text2792"><tspan
sodipodi:role="line"
id="tspan2794"
x="299.4628"
y="334.60339">Vector data</tspan><tspan
sodipodi:role="line"
x="302.23624"
y="359.60339"
id="tspan2798">converted to </tspan><tspan
sodipodi:role="line"
x="299.4628"
y="384.60339"
id="tspan2796">HTK format</tspan></text>
<rect
style="fill:none;stroke:#ff0000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2790-3"
width="128.0034"
height="105.27382"
x="439.81976"
y="166.97389"
ry="17.944401" />
<text
xml:space="preserve"
style="font-size:20px;font-weight:bold;text-align:center;text-anchor:middle"
x="503.88492"
y="212.28171"
id="text2792-7"><tspan
sodipodi:role="line"
x="503.88492"
y="212.28171"
id="tspan2796-2">Initial HMM</tspan><tspan
sodipodi:role="line"
x="503.88492"
y="237.28171"
id="tspan2838">state setup</tspan></text>
<rect
style="fill:none;stroke:#ff0000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2790-3-5"
width="128.0034"
height="105.27382"
x="625.24524"
y="166.97389"
ry="17.944401" />
<text
xml:space="preserve"
style="font-size:20px;font-weight:bold;text-align:center;text-anchor:middle"
x="689.203"
y="187.23775"
id="text2792-7-4"><tspan
sodipodi:role="line"
x="689.203"
y="187.23775"
id="tspan2838-4">Training</tspan><tspan
sodipodi:role="line"
x="689.203"
y="212.23775"
id="tspan2873">using</tspan><tspan
sodipodi:role="line"
x="689.203"
y="237.23775"
id="tspan2875">Baum Welch</tspan><tspan
sodipodi:role="line"
x="689.203"
y="262.23773"
id="tspan2877">algorithm</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2790-3-3"
width="128.0034"
height="105.27382"
x="838.18549"
y="299.81805"
ry="17.944401" />
<text
xml:space="preserve"
style="font-size:20px;font-weight:bold;text-align:center;text-anchor:middle"
x="902.14325"
y="320.08191"
id="text2792-7-0"><tspan
sodipodi:role="line"
x="902.14325"
y="320.08191"
id="tspan2838-8">Recognition</tspan><tspan
sodipodi:role="line"
x="902.14325"
y="345.08191"
id="tspan2896">using</tspan><tspan
sodipodi:role="line"
x="902.14325"
y="370.08191"
id="tspan2898">Viterbi</tspan><tspan
sodipodi:role="line"
x="902.14325"
y="395.08191"
id="tspan2900">algorithm</tspan></text>
<rect
style="fill:none;stroke:#000000;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2790-3-8"
width="128.0034"
height="105.27382"
x="838.18549"
y="458.92508"
ry="17.944401" />
<text
xml:space="preserve"
style="font-size:20px;font-weight:bold;text-align:center;text-anchor:middle"
x="901.99677"
y="504.23288"
id="text2792-7-8"><tspan
sodipodi:role="line"
x="901.99677"
y="504.23288"
id="tspan2919">Accuracy</tspan><tspan
sodipodi:role="line"
x="901.99677"
y="529.23291"
id="tspan3083">statistics</tspan></text>
<path
style="fill:none;stroke:#ff0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 364.35513,310.44507 74.96463,-48.82438"
id="path2923"
inkscape:connector-type="polyline"
inkscape:connection-start="#rect2790"
inkscape:connection-end="#rect2790-3"
sodipodi:nodetypes="ccs" />
<path
style="fill:none;stroke:#ff0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 568.32317,219.6108 56.42207,0"
id="path2929"
inkscape:connector-type="polyline"
inkscape:connection-start="#rect2790-3"
inkscape:connection-end="#rect2790-3-5" />
<path
style="fill:none;stroke:#ff0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 753.74864,259.85061 83.93685,52.36455"
id="path2931"
inkscape:connector-type="polyline"
inkscape:connection-start="#rect2790-3-5"
inkscape:connection-end="#rect2790-3-3"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 902.18719,405.59187 0,52.83321"
id="path2933"
inkscape:connector-type="polyline"
inkscape:connection-start="#rect2790-3-3"
inkscape:connection-end="#rect2790-3-8" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 364.35513,352.45496 473.33036,0"
id="path2935"
inkscape:connector-type="polyline"
inkscape:connection-start="#rect2790"
inkscape:connection-end="#rect2790-3-3" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow1Lend);display:inline"
d="m 903.38344,565.34298 1.19629,59.36309"
id="path2937"
inkscape:connector-type="polyline" />
<rect
style="fill:none;stroke:#ff0000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2790-3-5-9"
width="128.0034"
height="105.27382"
x="625.24524"
y="32.299919"
ry="17.944401" />
<text
xml:space="preserve"
style="font-size:20px;font-weight:bold;text-align:center;text-anchor:middle"
x="688.6366"
y="67.085266"
id="text2792-7-4-2"><tspan
sodipodi:role="line"
x="688.6366"
y="67.085266"
id="tspan2877-9">Dictionary</tspan><tspan
sodipodi:role="line"
x="688.6366"
y="92.085266"
id="tspan2990">of words</tspan><tspan
sodipodi:role="line"
x="688.6366"
y="117.08527"
id="tspan2994">used</tspan></text>
<path
style="fill:none;stroke:#ff0000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 689.24694,166.47389 0,-28.40015"
id="path2998"
inkscape:connector-type="polyline"
inkscape:connection-start="#rect2790-3-5"
inkscape:connection-end="#rect2790-3-5-9" />
<path
style="stroke:#000000;stroke-width:1px;stroke-opacity:1"
d="m 160.22579,316.49882 75.36648,0"
id="path3004" />
<path
style="stroke:#000000;stroke-width:1px;stroke-opacity:1"
d="m 160.22579,383.8097 75.36648,0"
id="path3004-2" />
<path
style="stroke:#000000;stroke-width:1px;stroke-opacity:1"
d="m 160.22579,350.15427 75.36648,0"
id="path3004-6" />
<text
xml:space="preserve"
style="font-size:16px"
x="159.36641"
y="308.69928"
id="text2846"><tspan
sodipodi:role="line"
id="tspan2848"
x="159.36641"
y="308.69928">Training</tspan></text>
<text
xml:space="preserve"
style="font-size:16px"
x="159.36641"
y="342.15845"
id="text2850"><tspan
sodipodi:role="line"
id="tspan2852"
x="159.36641"
y="342.15845">Testing</tspan></text>
<text
xml:space="preserve"
style="font-size:16px"
x="158.41328"
y="376.06577"
id="text2854"><tspan
sodipodi:role="line"
id="tspan2856"
x="158.41328"
y="376.06577">Evaluation</tspan></text>
<rect
style="fill:none;stroke:#ff0000;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="rect2790-3-1"
width="128.0034"
height="105.27382"
x="22.542532"
y="293.86609"
ry="17.944401" />
<text
xml:space="preserve"
style="font-size:20px;font-weight:bold;text-align:center;text-anchor:middle"
x="86.77861"
y="340.78522"
id="text2792-7-5"><tspan
sodipodi:role="line"
x="89.552048"
y="340.78522"
id="tspan2838-47">Data </tspan><tspan
sodipodi:role="line"
x="86.77861"
y="365.78522"
id="tspan3033">collection</tspan></text>
<text
xml:space="preserve"
style="font-size:18px;font-weight:bold"
x="833.38684"
y="639.99841"
id="text3085"><tspan
sodipodi:role="line"
id="tspan3087"
x="833.38684"
y="639.99841">System accuracy</tspan></text>
<text
xml:space="preserve"
style="font-size:16px"
x="342.55017"
y="274.49902"
id="text2846-6"><tspan
sodipodi:role="line"
id="tspan2848-5"
x="342.55017"
y="274.49902">Training</tspan></text>
<text
xml:space="preserve"
style="font-size:16px"
x="380.94086"
y="339.09888"
id="text2850-6"><tspan
sodipodi:role="line"
id="tspan2852-9"
x="380.94086"
y="339.09888">Testing</tspan></text>
<text
xml:space="preserve"
style="font-size:16px"
x="379.98773"
y="374.15857"
id="text2854-3"><tspan
sodipodi:role="line"
id="tspan2856-7"
x="379.98773"
y="374.15857">Evaluation</tspan></text>
</g>
</svg>

+ 2
- 1
ee4p/python/htk/htkconfig.py View File

@@ -27,12 +27,13 @@ class HtkConfig:
if not list:
self.configfile = open(configpath + projname + ".conf", 'r')
# Don't add the config path to these options
self.no_conf = ["binpath", "project", "confpath", "inputtype", "space_step", "flags"]
self.no_conf = ["binpath", "project", "confpath", "inputtype", "space_step", "flags", "spmodel"]
self.configs = {
"binpath" : binpath,
"project" : projname,
"confpath" : configpath,
"inputtype" : "audio",
"spmodel" : False,
"hmmdir" : configpath + "hmmsTrained/",
"mfccdir" : configpath + "mfccGen/",
"typeList" : configpath + "list/typeList_" + projname,


+ 80
- 63
ee4p/python/htk/htkwrapper.py View File

@@ -134,6 +134,22 @@ class HtkWrapper:
print("Something has gone badly, badly wrong.")
sys.exit(1)

elif self.config.getSetting("inputtype").find("tracker") >= 0:
print("Tracker data")
try:
import htkwritefile
except Exception, e:
print e
sys.exit(1)
#try:
ret = htkwritefile.writebinfile(int("Num Comps"), int("Num Samples"), float("Sample Period"), htkwriteargs["Sample Kind"].lstrip("MFCC"), data_from_file, output_file)
#if ret > 0:
#print("Something went titsup")
#else:
#print("Executed")
#except:
#raise Exception

else:
print("Error, pyhtk is not setup to handle none audio based work.")
print("Dieing now.")
@@ -249,78 +265,79 @@ class HtkWrapper:
shutil.copy(self.config.getSetting("hmmdir") + "hmm3/" + name, self.config.getSetting("hmmdir") + "hmm4")
print "Copied 4th iteration"

# create silence model
print "Correcting silence model"
model3 = open(self.config.getSetting("hmmdir") + "hmm3/models", 'r')
model4 = open(self.config.getSetting("hmmdir") + "hmm4/models", 'a')
tmpmodel = []
record = False
for line in model3:
if line.find("sil") >= 0:
record = True
if record and line.find("ENDHMM") >= 0:
record = False
if record:
tmpmodel.append(line)
states = []
midstate = []
for line in tmpmodel:
if line.find("STATE") >= 0:
states.append([tmpmodel[tmpmodel.index(line):tmpmodel.index(line) + 6]])
for stat in states[int(len(states)/2)][0]:
midstate.append(stat)
model4.write('~h "sp"\n<BEGINHMM>\n<NUMSTATES> 3\n<STATE> 2\n')
for line in midstate:
if line.find("STATE") == -1:
model4.write(line)
model4.write("<TRANSP> 3\n")
model4.write("0.000000e+00 5.000000e-01 5.000000e-01\n")
model4.write("0.000000e+00 5.000000e-01 5.000000e-01\n")
model4.write("0.000000e+00 0.000000e+00 0.000000e+00\n")
model4.write("<ENDHMM>\n")

model3.close()
model4.close()

try:
hhed = [self.config.getSetting("binpath") + "HHEd",
'-T', "3",
'-H', self.config.getSetting("hmmdir") + "hmm4/macros",
'-H', self.config.getSetting("hmmdir") + "hmm4/models",
'-M', self.config.getSetting("hmmdir") + "hmm5",
self.config.getSetting("hedsilsp"),
self.config.getSetting("wordList")
]
ret = subprocess.check_call(hhed)
if ret != 0:
print "Error, return codes wrong"
sys.exit(1)
except CalledProcessError, e:
print e
sys.exit(1)
print "Corrected silence model"

for iteration in range(5, int(self.config.getSetting("space_step")) + 1):
print "Iteration %d" % iteration
if self.config.getSetting("spmodel"):
# create silence model
print "Correcting silence model"
model3 = open(self.config.getSetting("hmmdir") + "hmm3/models", 'r')
model4 = open(self.config.getSetting("hmmdir") + "hmm4/models", 'a')
tmpmodel = []
record = False
for line in model3:
if line.find("sil") >= 0:
record = True
if record and line.find("ENDHMM") >= 0:
record = False
if record:
tmpmodel.append(line)
states = []
midstate = []
for line in tmpmodel:
if line.find("STATE") >= 0:
states.append([tmpmodel[tmpmodel.index(line):tmpmodel.index(line) + 6]])
for stat in states[int(len(states)/2)][0]:
midstate.append(stat)
model4.write('~h "sp"\n<BEGINHMM>\n<NUMSTATES> 3\n<STATE> 2\n')
for line in midstate:
if line.find("STATE") == -1:
model4.write(line)
model4.write("<TRANSP> 3\n")
model4.write("0.000000e+00 5.000000e-01 5.000000e-01\n")
model4.write("0.000000e+00 5.000000e-01 5.000000e-01\n")
model4.write("0.000000e+00 0.000000e+00 0.000000e+00\n")
model4.write("<ENDHMM>\n")

model3.close()
model4.close()

try:
herest = [self.config.getSetting("binpath") + "HERest",
'-D',
'-C', self.config.getSetting("configTrain"),
'-I', self.config.getSetting("wordLabelSP"),
'-S', self.config.getSetting("listTrain"),
'-H', "%shmm%d/macros" % (self.config.getSetting("hmmdir"), iteration - 1),
'-H', "%shmm%d/models" % (self.config.getSetting("hmmdir"), iteration - 1),
'-M', "%shmm%d" % (self.config.getSetting("hmmdir"), iteration),
self.config.getSetting("wordListSP")
hhed = [self.config.getSetting("binpath") + "HHEd",
'-T', "3",
'-H', self.config.getSetting("hmmdir") + "hmm4/macros",
'-H', self.config.getSetting("hmmdir") + "hmm4/models",
'-M', self.config.getSetting("hmmdir") + "hmm5",
self.config.getSetting("hedsilsp"),
self.config.getSetting("wordList")
]
subprocess.check_call(herest)
ret = subprocess.check_call(hhed)
if ret != 0:
print "Error, return codes wrong"
sys.exit(1)
except CalledProcessError, e:
print e
sys.exit(1)
print "Corrected silence model"

for iteration in range(5, int(self.config.getSetting("space_step")) + 1):
print "Iteration %d" % iteration

try:
herest = [self.config.getSetting("binpath") + "HERest",
'-D',
'-C', self.config.getSetting("configTrain"),
'-I', self.config.getSetting("wordLabelSP"),
'-S', self.config.getSetting("listTrain"),
'-H', "%shmm%d/macros" % (self.config.getSetting("hmmdir"), iteration - 1),
'-H', "%shmm%d/models" % (self.config.getSetting("hmmdir"), iteration - 1),
'-M', "%shmm%d" % (self.config.getSetting("hmmdir"), iteration),
self.config.getSetting("wordListSP")
]
subprocess.check_call(herest)
if ret != 0:
print "Error, return codes wrong"
sys.exit(1)
except CalledProcessError, e:
print e
sys.exit(1)

print "%d Iterations completed" % (int(self.config.getSetting("space_step")) - 5)
print "Training complete"


+ 11
- 11
ee4p/python/htk/htkwrite.c View File

@@ -78,19 +78,19 @@ static PyObject * HTKWriteBin(PyObject *self, PyObject *args)
default: ;;
}
s = '\0';
len -= 1;
len -= 1;
}

if (hasE) htk_kind |= HASENERGY;
if (hasD) htk_kind |= HASDELTA;
if (hasN) htk_kind |= HASNULLE;
if (hasA) htk_kind |= HASACCS;
if (hasT) htk_kind |= HASTHIRD;
if (hasK) htk_kind |= HASCRCC;
if (hasC) htk_kind |= HASCOMPX;
if (hasZ) htk_kind |= HASZEROM;
if (has0) htk_kind |= HASZEROC;
if (hasV) htk_kind |= HASVQ;
if (hasE) htk_kind |= HASENERGY;
if (hasD) htk_kind |= HASDELTA;
if (hasN) htk_kind |= HASNULLE;
if (hasA) htk_kind |= HASACCS;
if (hasT) htk_kind |= HASTHIRD;
if (hasK) htk_kind |= HASCRCC;
if (hasC) htk_kind |= HASCOMPX;
if (hasZ) htk_kind |= HASZEROM;
if (has0) htk_kind |= HASZEROC;
if (hasV) htk_kind |= HASVQ;
header.parmKind=htk_kind;

if(fwrite(&header,sizeof(htk_header_t),1,destfile) != 1) {


+ 73
- 0
ee4p/python/htk/htkwrite_transcribe.py View File

@@ -0,0 +1,73 @@
#!/usr/bin/python
# htkwrite_tracker.py
#
# Copyright 2008-2009 Sam Black <samwwwblack@lapwing.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

__version__ = "0.1"

import sys, os, pwd, subprocess, shutil
from subprocess import CalledProcessError
from optparse import OptionParser

try:
import htkwritefile
except Exception, e:
print e
sys.exit(1)

class HtkWrite:
def __init__(self, filename):
self.filename = filename
self.output = self.filename.rstrip(".tsv") + ".mfcc"
self.samples = -1
self.combined = []

def readfile(self):
f = open(self.filename, 'r')
data = False
for line in f.readlines():
#print(line)
if data:
print("adding data")
self.combined.append(line.split())
print(self.combined)

if line.startswith("NO_OF_MARKERS"):
self.samples = int(line.split()[1])
print(self.samples)
elif line.startswith("MARKER_NAMES"):
data = True
print("appending data")

def run(self):
#print(self.combined)
print("passing to htwritefile")
ret = htkwritefile.writebinfile(6000, self.samples, float(50), " ", self.combined, self.output)
print(ret)

if __name__ == '__main__':
parser = OptionParser()

#parser.add_option("-V", "--version", action="store_true", default=False, dest="version", help="version information")

(options, args) = parser.parse_args()

htk = HtkWrite(args[0])
htk.readfile()
htk.run()


BIN
ee4p/python/htk/htkwritefile.so View File


Loading…
Cancel
Save