Skip to content

Commit

Permalink
fixed #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Bernard committed Nov 12, 2019
1 parent c403ab0 commit 2248d50
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 44 deletions.
1 change: 0 additions & 1 deletion TODO.org
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ Those messages are actually logged in debug level, should be smater to be warnon
2016-10-12 16:33:58,373 - DEBUG - WARNING (apply-cmvn:Write():util/kaldi-holder-inl.h:54) Exception caught writing Table object: ERROR (apply-cmvn:Write():kaldi-matrix.cc:1229) Failed to write matrix to stream
** TODO Have completion setup during installation (or configuration?)
** TODO Have a test_commands module for testing command line interface
** TODO Remove the wiki page on github, as we have now a readthedoc site
* New specifications (0.4)
#+begin_src python
corpus = BuckeyeCorpusPreparator('./buckeye').prepare()
Expand Down
2 changes: 1 addition & 1 deletion abkhazia/commands/abkhazia_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def __call__(self):
# can be usefull to don't catch any exception, so the full error
# traceback error is printed. To do so, just comment the following
# line
#@CatchExceptions
@CatchExceptions
def main():
"""abkhazia main entry point in command line"""
Abkhazia()
Expand Down
63 changes: 25 additions & 38 deletions abkhazia/decode/_decoder_fmllr.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,30 @@ def decode(decoder, graph_dir):
if decoder.mkgraph_opts['reverse'].value:
score_opts += ' --reverse true'

# decode_fmllr.sh must be run from a subdirectory of the input
# acoustic model directory (here decoder.am_dir). So we do: create
# a subdir in am_dir as a symlink to the target recipe_dir, run
# the script in it, and finally delete the symlink. Moreover the
# script make a speaker independant decoding so we use the tweak
# again for si.
#
# TODO This is an error to assume write permission in
# decoder.am_dir!! Instead we must copy (link) the required files
# to decoder.recipe_dir (as in _decoder_nnet)
try:
target_sa = os.path.join(decoder.recipe_dir, 'decode')
if not os.path.isdir(target_sa):
os.makedirs(target_sa)
tempdir_sa = os.path.join(decoder.am_dir, 'decode_fmllr')
os.symlink(target_sa, tempdir_sa)
target = os.path.join(decoder.recipe_dir, 'decode')
if not os.path.isdir(target):
os.makedirs(target)

target_si = os.path.join(decoder.recipe_dir, 'decode.si')
if not os.path.isdir(target_si):
os.makedirs(target_si)
tempdir_si = os.path.join(decoder.am_dir, 'decode_fmllr.si')
os.symlink(target_si, tempdir_si)
# link requested files to decoder.recipe_dir. final.mat is optional (here
# only if features type is LDA)
for linked in ('final.mdl', 'final.alimdl', 'tree', 'final.mat'):
src = os.path.join(decoder.am_dir, linked)
if os.path.exists(src):
os.symlink(src, os.path.join(decoder.recipe_dir, linked))
elif linked == 'final.mat':
pass
else:
raise IOError('acoustic model file not found: {}'.format(src))

decoder._run_command((
'steps/decode_fmllr.sh --nj {njobs} --cmd "{cmd}" '
'{decode_opts} {skip_scoring} --scoring-opts "{score_opts}" '
'{graph} {data} {decode}'.format(
njobs=decoder.njobs,
cmd=utils.config.get('kaldi', 'decode-cmd'),
decode_opts=decode_opts,
skip_scoring=_score.skip_scoring(decoder.score_opts),
score_opts=_score.format(
decoder.score_opts, decoder.mkgraph_opts),
graph=graph_dir,
data=os.path.join(decoder.recipe_dir, 'data', decoder.name),
decode=tempdir_sa)))
finally:
# remove the two symlinks we created in input am_dir
utils.remove(tempdir_si)
utils.remove(tempdir_sa)
decoder._run_command((
'steps/decode_fmllr.sh --nj {njobs} --cmd "{cmd}" '
'{decode_opts} {skip_scoring} --scoring-opts "{score_opts}" '
'{graph} {data} {decode}'.format(
njobs=decoder.njobs,
cmd=utils.config.get('kaldi', 'decode-cmd'),
decode_opts=decode_opts,
skip_scoring=_score.skip_scoring(decoder.score_opts),
score_opts=_score.format(decoder.score_opts, decoder.mkgraph_opts),
graph=graph_dir,
data=os.path.join(decoder.recipe_dir, 'data', decoder.name),
decode=target)))
4 changes: 2 additions & 2 deletions abkhazia/decode/_decoder_nnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def decode(decoder, graph_dir):
if not os.path.isdir(target):
os.makedirs(target)

# link requesteed files to decoder.recipe_dir. final.mdl is
# link requested files to decoder.recipe_dir. final.mdl is
# mandatory (raise if not found), others are optional and Kaldi
# will work without
for linked in ('final.mdl', 'cmvn_opts', 'final.mat',
Expand All @@ -75,7 +75,7 @@ def decode(decoder, graph_dir):
if os.path.exists(src):
os.symlink(src, os.path.join(decoder.recipe_dir, linked))
elif linked == 'final.mdl':
raise IOError('model file not found {}'.format(src))
raise IOError('acoustic model file not found: {}'.format(src))
else:
decoder.log.info('optional file not here %s', src)

Expand Down
4 changes: 2 additions & 2 deletions abkhazia/decode/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def __init__(self, corpus, lm_dir, feats_dir, am_dir, output_dir,
'nnet': 'nnet'}[self.am_type]
if decode_type and self._decoder_type != decode_type:
raise IOError(
'''cannot setup decoder, acoustic model
and decoder type are not compatible''')
'Cannot setup decoder, acoustic model '
'and decoder type are not compatible')
self._decoder = decoders[self._decoder_type]

self.mkgraph_opts = _mkgraph.options()
Expand Down

0 comments on commit 2248d50

Please sign in to comment.