# Path: abkhazia/decode/_mkgraph.py
# def options():
# def mkgraph(decoder, verbose=True):
# 
# Path: abkhazia/decode/_decoder.py
# def options():
# def decode(decoder, graph_dir):
# 
# Path: abkhazia/decode/_decoder_fmllr.py
# def options():
# def decode(decoder, graph_dir):
# 
# Path: abkhazia/decode/_decoder_nnet.py
# def options():
# def decode(decoder, graph_dir):
# 
# Path: abkhazia/decode/_score.py
# def options():
# def format(score_opts, mkgraph_opts):
# def skip_scoring(score_opts):


import os
import shutil
import abkhazia.abstract_recipe as abstract_recipe
import abkhazia.language as language
import abkhazia.features as features
import abkhazia.acoustic as acoustic
import abkhazia.utils as utils
from abkhazia.decode import _mkgraph
from abkhazia.decode import _decoder
from abkhazia.decode import _decoder_fmllr
from abkhazia.decode import _decoder_nnet
from abkhazia.decode import _score

class Decode(abstract_recipe.AbstractRecipe):
    name = 'decode'

    def __init__(self, corpus, lm_dir, feats_dir, am_dir, output_dir,
                 decode_type=None, log=utils.logger.null_logger(),
                 fmllr_dir=None):
        super(Decode, self).__init__(corpus, output_dir, log=log)
        self.feat_dir = os.path.abspath(feats_dir)
        self.lm_dir = os.path.abspath(lm_dir)
        self.am_dir = os.path.abspath(am_dir)
        # if fmllr are already computed and given in input:
        self.fmllr_dir = (
            os.path.abspath(fmllr_dir) if fmllr_dir is not None
            else None)

        self.am_type = acoustic.model_type(am_dir)
        self._decoder_type = {
            'mono': 'si',
            'tri': 'si',
            'tri-sa': 'sa',
            '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')
        self._decoder = decoders[self._decoder_type]

        self.mkgraph_opts = _mkgraph.options()
        self.decode_opts = self._decoder.options()

# Path: abkhazia/decode/_mkgraph.py
# def options():
# def mkgraph(decoder, verbose=True):
# 
# Path: abkhazia/decode/_decoder.py
# def options():
# def decode(decoder, graph_dir):
# 
# Path: abkhazia/decode/_decoder_fmllr.py
# def options():
# def decode(decoder, graph_dir):
# 
# Path: abkhazia/decode/_decoder_nnet.py
# def options():
# def decode(decoder, graph_dir):
# 
# Path: abkhazia/decode/_score.py
# def options():
# def format(score_opts, mkgraph_opts):
# def skip_scoring(score_opts):


# Path: abkhazia/decode/decode.py
import os
import shutil
import abkhazia.abstract_recipe as abstract_recipe
import abkhazia.language as language
import abkhazia.features as features
import abkhazia.acoustic as acoustic
import abkhazia.utils as utils
from abkhazia.decode import _mkgraph
from abkhazia.decode import _decoder
from abkhazia.decode import _decoder_fmllr
from abkhazia.decode import _decoder_nnet
from abkhazia.decode import _score


class Decode(abstract_recipe.AbstractRecipe):
    name = 'decode'

    def __init__(self, corpus, lm_dir, feats_dir, am_dir, output_dir,
                 decode_type=None, log=utils.logger.null_logger(),
                 fmllr_dir=None):
        super(Decode, self).__init__(corpus, output_dir, log=log)
        self.feat_dir = os.path.abspath(feats_dir)
        self.lm_dir = os.path.abspath(lm_dir)
        self.am_dir = os.path.abspath(am_dir)
        # if fmllr are already computed and given in input:
        self.fmllr_dir = (
            os.path.abspath(fmllr_dir) if fmllr_dir is not None
            else None)

        self.am_type = acoustic.model_type(am_dir)
        self._decoder_type = {
            'mono': 'si',
            'tri': 'si',
            'tri-sa': 'sa',
            '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')
        self._decoder = decoders[self._decoder_type]

        self.mkgraph_opts = _mkgraph.options()
        self.decode_opts = self._decoder.options()

        self.score_opts = _score.options()