def main(cmd=None): r"""ASR training. Example: % python asr_train.py asr --print_config --optim adadelta \ > conf/train_asr.yaml % python asr_train.py --config conf/train_asr.yaml """ ASRTask.main(cmd=cmd)
def asr_config_file(tmp_path: Path, token_list): # Write default configuration file ASRTask.main(cmd=[ "--dry_run", "true", "--output_dir", str(tmp_path / "asr"), "--token_list", str(token_list), "--token_type", "char", ]) return tmp_path / "asr" / "config.yaml"
def asr_config_file_streaming(tmp_path: Path, token_list): # Write default configuration file ASRTask.main(cmd=[ "--dry_run", "true", "--output_dir", str(tmp_path / "asr_streaming"), "--token_list", str(token_list), "--token_type", "char", "--decoder", "transformer", "--encoder", "contextual_block_transformer", ]) return tmp_path / "asr_streaming" / "config.yaml"
def test_main_with_no_args(): with pytest.raises(SystemExit): ASRTask.main(cmd=[])
def test_main_print_config(): with pytest.raises(SystemExit): ASRTask.main(cmd=["--print_config"])
def test_main_help(): with pytest.raises(SystemExit): ASRTask.main(cmd=["--help"])