Exemplo n.º 1
0
def test_acoustic_njobs(corpus, features, njobs, tmpdir, lang_args):
    output_dir = str(tmpdir.mkdir('am-mono'))
    flog = os.path.join(output_dir, 'am-mono.log')
    log = utils.logger.get_log(flog)
    am = acoustic.Monophone(corpus, features, output_dir, lang_args, log)

    am.njobs = njobs
    am.options['total-gaussians'].value = 10
    am.options['num-iterations'].value = 2
    am.options['realign-iterations'].value = [1]

    try:
        am.compute()
    except RuntimeError as err:
        # dump the log to stdout
        sys.stdout.write('####################\n')
        sys.stdout.write(open(flog, 'r').read())
        # log_inner = os.path.join(
        #     output_dir, 'recipe/exp/mono/log/align.0.14.log')
        # sys.stdout.write(open(log_inner, 'r').read())
        sys.stdout.write('####################\n')
        raise err

    acoustic.check_acoustic_model(output_dir)
    assert acoustic.model_type(output_dir) == 'mono'
    assert str(am.options['num-iterations']) == '2'
    assert_expr_in_log(flog, ' --num-iters 2 ')
    assert_no_expr_in_log(flog, 'error')
Exemplo n.º 2
0
def am_nnet(corpus, features, am_trisa, tmpdir_factory, lang_args):
    output_dir = str(tmpdir_factory.mktemp('am_nnet'))
    flog = os.path.join(output_dir, 'am_nnet.log')
    log = utils.logger.get_log(flog)
    am = acoustic.NeuralNetwork(corpus,
                                features,
                                am_trisa,
                                output_dir,
                                lang_args,
                                log=log)

    am.options['num-epochs'].value = 2
    am.options['num-epochs-extra'].value = 1
    am.options['num-hidden-layers'].value = 1
    am.options['num-iters-final'].value = 1
    am.options['pnorm-input-dim'].value = 1
    am.options['pnorm-output-dim'].value = 1
    am.options['num-utts-subset'].value = 2
    am.compute()

    acoustic.check_acoustic_model(output_dir)
    # TODO this assert fails since some preliminary steps of the recipe
    # generate errors (but this do not impact the recipe)
    # # assert_no_expr_in_log(flog, 'error')
    return output_dir
Exemplo n.º 3
0
    def check_parameters(self):
        super(Align, self).check_parameters()
        self._check_level()
        self._check_with_posteriors()
        self._check_acoustic_scale()

        check_acoustic_model(self.am_dir)
        check_language_model(self.lm_dir)

        self.meta.source += (', feat = {}, lm = {}, am = {}'.format(
            self.feat_dir, self.lm_dir, self.am_dir))
Exemplo n.º 4
0
    def check_parameters(self):
        """Raise if the decoding parameters are not correct"""
        super(Decode, self).check_parameters()

        features.Features.check_features(self.feat_dir)
        language.check_language_model(self.lm_dir)
        acoustic.check_acoustic_model(self.am_dir)

        self.meta.source += '\n' + '\n'.join(('features = {}'.format(
            self.feat_dir), 'language model = {}'.format(
                self.lm_dir), 'acoustic model = {}'.format(self.am_dir)))
Exemplo n.º 5
0
    def check_parameters(self):
        super(Align, self).check_parameters()
        self._check_level()
        self._check_with_posteriors()
        self._check_acoustic_scale()

        # late import to avoid circular import (align imports acoustic
        # for the convert_alignment_to_kaldi_format function)
        from abkhazia.acoustic import check_acoustic_model
        check_acoustic_model(self.am_dir)
        check_language_model(self.lm_dir)

        self.meta.source += (', feat = {}, lm = {}, am = {}'.format(
            self.feat_dir, self.lm_dir, self.am_dir))
Exemplo n.º 6
0
def am_tri(corpus, features, am_mono, tmpdir_factory, lang_args):
    output_dir = str(tmpdir_factory.mktemp('am_tri'))
    flog = os.path.join(output_dir, 'am_tri.log')
    log = utils.logger.get_log(flog)
    am = acoustic.Triphone(corpus,
                           features,
                           am_mono,
                           output_dir,
                           lang_args,
                           log=log)

    am.options['total-gaussians'].value = 5
    am.options['num-iterations'].value = 2
    am.options['realign-iterations'].value = [1]
    am.options['num-leaves'].value = 20
    am.compute()

    acoustic.check_acoustic_model(output_dir)
    assert_no_expr_in_log(flog, 'error')
    return output_dir