コード例 #1
0
def parser_config(subparsers, epilog):
    """Initialize options for 'speech-features config'"""
    parser = subparsers.add_parser(
        'config',
        description='Generate a configuration for features extraction, '
        "have a 'speech-features --help' for more details",
        epilog=epilog,
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument(
        '-o', '--output', metavar='config-file', default=None,
        help='The YAML configuration file to write. '
        'If not specified, write to stdout')

    parser.add_argument(
        '--no-comments', action='store_true',
        help='Do not include comments in the output YAML configuration file. '
        'By default all parameters in the YAML are explained in comments.')

    group = parser.add_argument_group('pipeline arguments')
    group.add_argument(
        'features', type=str, choices=pipeline.valid_features(),
        help='Configure the pipeline to extract those features')

    group.add_argument(
        '--no-pitch', action='store_true',
        help='Configure without pitch extraction')

    group.add_argument(
        '--no-cmvn', action='store_true',
        help='Configure without CMVN normalization')

    group.add_argument(
        '--no-delta', action='store_true',
        help='Configure without deltas extraction')
コード例 #2
0
ファイル: setup_data.py プロジェクト: zzdxlee/shennong
def generate_configurations(conf_directory):
    try:
        os.makedirs(conf_directory)
    except FileExistsError:
        pass

    for features in pipeline.valid_features():
        conf = os.path.join(conf_directory, f'{features}_only.yaml')
        yaml = pipeline.get_default_config(
            features, to_yaml=True, yaml_commented=False,
            with_cmvn=False, with_delta=False, with_pitch=False)
        open(conf, 'w').write(yaml)

        conf = os.path.join(conf_directory, f'{features}_nocmvn.yaml')
        yaml = pipeline.get_default_config(
            features, to_yaml=True, yaml_commented=False,
            with_cmvn=False, with_delta=True, with_pitch=True)
        open(conf, 'w').write(yaml)

        conf = os.path.join(conf_directory, f'{features}_full.yaml')
        yaml = pipeline.get_default_config(
            features, to_yaml=True, yaml_commented=False,
            with_cmvn=True, with_delta=True, with_pitch=True)
        open(conf, 'w').write(yaml)
コード例 #3
0
    if not d1.keys() == d2.keys():
        return False
    for k, v in d1.items():
        if isinstance(v, str):
            if not v == d2[k]:
                return False
        elif isinstance(v, dict):
            if not equal_dict(v, d2[k]):
                return False
        else:
            if v != pytest.approx(d2[k]):
                return False
    return True


@pytest.mark.parametrize('features', pipeline.valid_features())
def test_config_good(features):
    c1 = pipeline.get_default_config(features, to_yaml=False)
    c2 = pipeline.get_default_config(features,
                                     to_yaml=True,
                                     yaml_commented=False)
    c3 = pipeline.get_default_config(features,
                                     to_yaml=True,
                                     yaml_commented=True)
    assert features in c1.keys()
    assert '#' not in c2
    assert '#' in c3
    assert equal_dict(c1, yaml.load(c2, Loader=yaml.FullLoader))
    assert equal_dict(c1, yaml.load(c3, Loader=yaml.FullLoader))