From 8b8cf6c68e036604cd9c9f45312e53574d6e1748 Mon Sep 17 00:00:00 2001 From: PingFeng Luo Date: Thu, 30 Dec 2021 18:43:47 +0800 Subject: [PATCH] fix style --- egs/aishell/ASR/local/make_syllable_lexicon.py | 16 ++++++++-------- egs/aishell/ASR/tdnn_lstm_ctc/asr_datamodule.py | 10 ++++++---- egs/aishell/ASR/tdnn_lstm_ctc/decode.py | 2 ++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/egs/aishell/ASR/local/make_syllable_lexicon.py b/egs/aishell/ASR/local/make_syllable_lexicon.py index 15c0f8ac0..33e1f8b2b 100755 --- a/egs/aishell/ASR/local/make_syllable_lexicon.py +++ b/egs/aishell/ASR/local/make_syllable_lexicon.py @@ -36,22 +36,22 @@ def process_line( word_syllables = [] word_syllables_num = 1 inited = False - for char_syllables in pinyins : + for char_syllables in pinyins: new_char_syllables_num = len(char_syllables) - if not inited and len(char_syllables) : + if not inited and len(char_syllables): word_syllables = [char_syllables[0]] inited = True - elif new_char_syllables_num == 1 : - for i in range(word_syllables_num) : + elif new_char_syllables_num == 1: + for i in range(word_syllables_num): word_syllables[i] += " " + str(char_syllables) - elif new_char_syllables_num > 1 : + elif new_char_syllables_num > 1: word_syllables = word_syllables * new_char_syllables_num - for pre_index in range(word_syllables_num) : - for expand_index in range(new_char_syllables_num) : + for pre_index in range(word_syllables_num): + for expand_index in range(new_char_syllables_num): word_syllables[pre_index * new_char_syllables_num + expand_index] += " " + char_syllables[expand_index] word_syllables_num *= new_char_syllables_num - for word_syallable in word_syllables : + for word_syallable in word_syllables: print("{} {}".format(chars.strip(), str(word_syallable).strip())) diff --git a/egs/aishell/ASR/tdnn_lstm_ctc/asr_datamodule.py b/egs/aishell/ASR/tdnn_lstm_ctc/asr_datamodule.py index 2c7455e3a..b3f88a597 100644 --- a/egs/aishell/ASR/tdnn_lstm_ctc/asr_datamodule.py +++ b/egs/aishell/ASR/tdnn_lstm_ctc/asr_datamodule.py @@ -336,19 +336,21 @@ class AishellAsrDataModule: ) return test_dl - @lru_cache() def train_cuts(self) -> CutSet: logging.info("About to get train cuts") - cuts_train = load_manifest(self.args.manifest_dir / "cuts_train.json.gz") + cuts_train = load_manifest(self.args.manifest_dir / + "cuts_train.json.gz") return cuts_train @lru_cache() def valid_cuts(self) -> CutSet: logging.info("About to get dev cuts") - return load_manifest(self.args.manifest_dir / "cuts_dev.json.gz") + return load_manifest(self.args.manifest_dir / + "cuts_dev.json.gz") @lru_cache() def test_cuts(self) -> List[CutSet]: logging.info("About to get test cuts") - return load_manifest(self.args.manifest_dir / f"cuts_test.json.gz") + return load_manifest(self.args.manifest_dir / + "cuts_test.json.gz") diff --git a/egs/aishell/ASR/tdnn_lstm_ctc/decode.py b/egs/aishell/ASR/tdnn_lstm_ctc/decode.py index aa98700e5..f3c8e8f44 100755 --- a/egs/aishell/ASR/tdnn_lstm_ctc/decode.py +++ b/egs/aishell/ASR/tdnn_lstm_ctc/decode.py @@ -366,6 +366,8 @@ def main(): model.eval() aishell = AishellAsrDataModule(args) + test_cuts = aishell.test_cuts() + test_dl = aishell.test_dataloaders(test_cuts) # CAUTION: `test_sets` is for displaying only. # If you want to skip test-clean, you have to skip # it inside the for loop. That is, use