Ejemplo 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')
Ejemplo n.º 2
0
def am_mono(corpus, features, tmpdir_factory, lang_args):
    output_dir = str(tmpdir_factory.mktemp('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=log)

    am.options['total-gaussians'].value = 5
    am.options['num-iterations'].value = 2
    am.options['realign-iterations'].value = [1]
    am.compute()
    return output_dir
Ejemplo n.º 3
0
def test_monophone_cmvn_bad(corpus, tmpdir, lang_args):
    features_dir = str(tmpdir.mkdir('feats'))
    feat = features.Features(corpus, features_dir)
    feat.use_pitch = False
    feat.use_cmvn = False
    feat.delta_order = 0
    feat.compute()

    output_dir = str(tmpdir.mkdir('am_mono'))
    am = acoustic.Monophone(corpus, features_dir, output_dir, lang_args)
    with pytest.raises(IOError) as err:
        am.check_parameters()
    assert 'cmvn' in str(err.value)
Ejemplo n.º 4
0
def test_monophone_cmvn_good(corpus, features, tmpdir, lang_args):
    output_dir = str(tmpdir.mkdir('am_mono'))
    am = acoustic.Monophone(corpus, features, output_dir, lang_args)
    am.check_parameters()