From 9033dd688eb3b85a272cae85db555084b9bd5a3e Mon Sep 17 00:00:00 2001 From: Yifan Yang <64255737+yfyeung@users.noreply.github.com> Date: Thu, 4 Jul 2024 14:19:45 +0800 Subject: [PATCH] Fix typos, remove unused packages, normalize comments (#1678) --- egs/librispeech/ASR/tdnn_lstm_ctc/asr_datamodule.py | 2 +- egs/librispeech/ASR/zipformer/decode.py | 1 - egs/librispeech/ASR/zipformer/export-onnx-ctc.py | 1 - egs/librispeech/ASR/zipformer/jit_pretrained_streaming.py | 3 --- egs/librispeech/ASR/zipformer/joiner.py | 2 +- egs/librispeech/ASR/zipformer/onnx_check.py | 2 -- egs/librispeech/ASR/zipformer/optim.py | 4 ++-- egs/librispeech/ASR/zipformer/pretrained.py | 2 -- egs/librispeech/ASR/zipformer/scaling_converter.py | 5 +++-- egs/librispeech/ASR/zipformer/train.py | 4 ---- 10 files changed, 7 insertions(+), 19 deletions(-) diff --git a/egs/librispeech/ASR/tdnn_lstm_ctc/asr_datamodule.py b/egs/librispeech/ASR/tdnn_lstm_ctc/asr_datamodule.py index 814390ad66..1b52aa8b5e 100644 --- a/egs/librispeech/ASR/tdnn_lstm_ctc/asr_datamodule.py +++ b/egs/librispeech/ASR/tdnn_lstm_ctc/asr_datamodule.py @@ -1,4 +1,4 @@ -# Copyright 2021 Piotr Żelasko +# Copyright 2021 Piotr Żelasko # Copyright 2022 Xiaomi Corporation (Author: Mingshuang Luo) # # See ../../../../LICENSE for clarification regarding multiple authors diff --git a/egs/librispeech/ASR/zipformer/decode.py b/egs/librispeech/ASR/zipformer/decode.py index 339e253e6e..df2d555a09 100755 --- a/egs/librispeech/ASR/zipformer/decode.py +++ b/egs/librispeech/ASR/zipformer/decode.py @@ -133,7 +133,6 @@ from icefall.lexicon import Lexicon from icefall.utils import ( AttributeDict, - make_pad_mask, setup_logger, store_transcripts, str2bool, diff --git a/egs/librispeech/ASR/zipformer/export-onnx-ctc.py b/egs/librispeech/ASR/zipformer/export-onnx-ctc.py index 3345d20d3f..99685f2fe2 100755 --- a/egs/librispeech/ASR/zipformer/export-onnx-ctc.py +++ b/egs/librispeech/ASR/zipformer/export-onnx-ctc.py @@ -72,7 +72,6 @@ import onnx import torch import torch.nn as nn -from decoder import Decoder from onnxruntime.quantization import QuantType, quantize_dynamic from scaling_converter import convert_scaled_to_non_scaled from train import add_model_arguments, get_model, get_params diff --git a/egs/librispeech/ASR/zipformer/jit_pretrained_streaming.py b/egs/librispeech/ASR/zipformer/jit_pretrained_streaming.py index eade5a854e..c13c4ccc81 100755 --- a/egs/librispeech/ASR/zipformer/jit_pretrained_streaming.py +++ b/egs/librispeech/ASR/zipformer/jit_pretrained_streaming.py @@ -40,15 +40,12 @@ import argparse import logging -import math from typing import List, Optional import k2 -import kaldifeat import torch import torchaudio from kaldifeat import FbankOptions, OnlineFbank, OnlineFeature -from torch.nn.utils.rnn import pad_sequence def get_parser(): diff --git a/egs/librispeech/ASR/zipformer/joiner.py b/egs/librispeech/ASR/zipformer/joiner.py index dfb0a0057b..0406efe834 100644 --- a/egs/librispeech/ASR/zipformer/joiner.py +++ b/egs/librispeech/ASR/zipformer/joiner.py @@ -45,7 +45,7 @@ def forward( Output from the encoder. Its shape is (N, T, s_range, C). decoder_out: Output from the decoder. Its shape is (N, T, s_range, C). - project_input: + project_input: If true, apply input projections encoder_proj and decoder_proj. If this is false, it is the user's responsibility to do this manually. diff --git a/egs/librispeech/ASR/zipformer/onnx_check.py b/egs/librispeech/ASR/zipformer/onnx_check.py index 93bd3a211c..b558a5dfc6 100755 --- a/egs/librispeech/ASR/zipformer/onnx_check.py +++ b/egs/librispeech/ASR/zipformer/onnx_check.py @@ -82,8 +82,6 @@ import torch from onnx_pretrained import OnnxModel -from icefall import is_module_available - def get_parser(): parser = argparse.ArgumentParser( diff --git a/egs/librispeech/ASR/zipformer/optim.py b/egs/librispeech/ASR/zipformer/optim.py index aaffbfed5b..6f5180e29e 100644 --- a/egs/librispeech/ASR/zipformer/optim.py +++ b/egs/librispeech/ASR/zipformer/optim.py @@ -1,4 +1,4 @@ -# Copyright 2022 Xiaomi Corp. (authors: Daniel Povey) +# Copyright 2022 Xiaomi Corp. (authors: Daniel Povey) # # See ../LICENSE for clarification regarding multiple authors # @@ -22,7 +22,7 @@ import torch from lhotse.utils import fix_random_seed -from torch import Tensor, nn +from torch import Tensor from torch.optim import Optimizer diff --git a/egs/librispeech/ASR/zipformer/pretrained.py b/egs/librispeech/ASR/zipformer/pretrained.py index de06528932..9f3571b084 100755 --- a/egs/librispeech/ASR/zipformer/pretrained.py +++ b/egs/librispeech/ASR/zipformer/pretrained.py @@ -126,8 +126,6 @@ from torch.nn.utils.rnn import pad_sequence from train import add_model_arguments, get_model, get_params -from icefall.utils import make_pad_mask - def get_parser(): parser = argparse.ArgumentParser( diff --git a/egs/librispeech/ASR/zipformer/scaling_converter.py b/egs/librispeech/ASR/zipformer/scaling_converter.py index 76622fa129..1f95648a07 100644 --- a/egs/librispeech/ASR/zipformer/scaling_converter.py +++ b/egs/librispeech/ASR/zipformer/scaling_converter.py @@ -1,4 +1,5 @@ -# Copyright 2022-2023 Xiaomi Corp. (authors: Fangjun Kuang, Zengwei Yao) +# Copyright 2022-2023 Xiaomi Corp. (authors: Fangjun Kuang, +# Zengwei Yao) # # See ../../../../LICENSE for clarification regarding multiple authors # @@ -22,7 +23,7 @@ """ import copy -from typing import List, Tuple +from typing import List import torch import torch.nn as nn diff --git a/egs/librispeech/ASR/zipformer/train.py b/egs/librispeech/ASR/zipformer/train.py index 04caf2fd80..858f845dca 100755 --- a/egs/librispeech/ASR/zipformer/train.py +++ b/egs/librispeech/ASR/zipformer/train.py @@ -512,10 +512,6 @@ def get_params() -> AttributeDict: - subsampling_factor: The subsampling factor for the model. - - encoder_dim: Hidden dim for multi-head attention model. - - - num_decoder_layers: Number of decoder layer of transformer decoder. - - warm_step: The warmup period that dictates the decay of the scale on "simple" (un-pruned) loss. """