From a22b6388209cf32e449751cb9ba8306bbc8d1de1 Mon Sep 17 00:00:00 2001 From: Mingshuang Luo <37799481+luomingshuang@users.noreply.github.com> Date: Thu, 14 Oct 2021 19:00:25 +0800 Subject: [PATCH] Update pretrained.py --- egs/librispeech/ASR/conformer_ctc/pretrained.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/egs/librispeech/ASR/conformer_ctc/pretrained.py b/egs/librispeech/ASR/conformer_ctc/pretrained.py index b4142ab89..eee8b94d4 100755 --- a/egs/librispeech/ASR/conformer_ctc/pretrained.py +++ b/egs/librispeech/ASR/conformer_ctc/pretrained.py @@ -20,7 +20,7 @@ import argparse import logging import math -import os +from pathlib import Path from typing import List import k2 @@ -298,8 +298,8 @@ def main(): if params.method == "ctc-decoding": logging.info("Use CTC decoding") - if not os.path.exists(params.bpe_model): - raise ValueError("The path to bpe.model is required!") + if not Path(params.bpe_model).exists(): + raise ValueError(f"The path to {params.bpe_model} doesn't exist!") bpe_model = spm.SentencePieceProcessor() bpe_model.load(params.bpe_model) @@ -333,10 +333,10 @@ def main(): "whole-lattice-rescoring", "attention-decoder", ]: - if not os.path.exists(params.HLG): - raise ValueError("The path to HLG.pt is required!") - if not os.path.exists(params.words_file): - raise ValueError("The path to words.txt is required!") + if not Path(params.HLG).exists(): + raise ValueError(f"The path to {params.HLG} doesn't exist!") + if not Path(params.words_file).exists(): + raise ValueError(f"The path to {params.words_file} doesn't exist!") logging.info(f"Loading HLG from {params.HLG}") HLG = k2.Fsa.from_dict(torch.load(params.HLG, map_location="cpu"))