def main(cmd=None): """LM training. Example: % python lm_train.py asr --print_config --optim adadelta % python lm_train.py --config conf/train_asr.yaml """ LMTask.main(cmd=cmd)
def lm_config_file(tmp_path: Path, token_list): # Write default configuration file LMTask.main(cmd=[ "--dry_run", "true", "--output_dir", str(tmp_path / "lm"), "--token_list", str(token_list), "--token_type", "char", ]) return tmp_path / "lm" / "config.yaml"
def lm_config_file(tmp_path: Path, token_list): lm_conf = "{'nlayers': 1, 'unit': 8}" LMTask.main( cmd=[ "--dry_run", "true", "--output_dir", str(tmp_path / "lm"), "--token_list", str(token_list), "--token_type", "char", "--lm_conf", lm_conf, ] ) return tmp_path / "lm" / "config.yaml"
def test_main_with_no_args(): with pytest.raises(SystemExit): LMTask.main(cmd=[])
def test_main_print_config(): with pytest.raises(SystemExit): LMTask.main(cmd=["--print_config"])
def test_main_help(): with pytest.raises(SystemExit): LMTask.main(cmd=["--help"])