Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
update setup (#686)
jmwang6698abc0e5ac1a
diff --git a/egs/alimeeting/sa_asr/local/format_wav_scp.py b/egs/alimeeting/sa_asr/local/format_wav_scp.pyindex 1fd63d690..cb0eac35a 100755--- a/egs/alimeeting/sa_asr/local/format_wav_scp.py+++ b/egs/alimeeting/sa_asr/local/format_wav_scp.py@@ -11,7 +11,6 @@ import numpy as npimport resampyimport soundfilefrom tqdm import tqdm-from typeguard import check_argument_typesfrom funasr.utils.cli_utils import get_commandline_argsfrom funasr.fileio.read_text import read_2column_text@@ -31,7 +30,6 @@ def str2int_tuple(integers: str) -> Optional[Tuple[int, ...]]:(3, 4, 5)"""- assert check_argument_types()if integers.strip() in ("none", "None", "NONE", "null", "Null", "NULL"):return Nonereturn tuple(map(int, integers.strip().split(",")))diff --git a/funasr/bin/asr_infer.py b/funasr/bin/asr_infer.pyindex a537a73fe..259a28644 100644--- a/funasr/bin/asr_infer.py+++ b/funasr/bin/asr_infer.py@@ -22,9 +22,7 @@ import numpy as npimport requestsimport torchfrom packaging.version import parse as V-from typeguard import check_argument_types-from typeguard import check_return_type-from funasr.build_utils.build_model_from_file import build_model_from_file+from funasr.build_utils.build_model_from_file import build_model_from_filefrom funasr.models.e2e_asr_contextual_paraformer import NeatContextualParaformerfrom funasr.models.e2e_asr_paraformer import BiCifParaformer, ContextualParaformerfrom funasr.models.frontend.wav_frontend import WavFrontend, WavFrontendOnline@@ -78,7 +76,6 @@ class Speech2Text:frontend_conf: dict = None,**kwargs,):- assert check_argument_types()# 1. Build ASR modelscorers = {}@@ -192,7 +189,6 @@ class Speech2Text:text, token, token_int, hyp"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):@@ -248,7 +244,6 @@ class Speech2Text:text = Noneresults.append((text, token, token_int, hyp))- assert check_return_type(results)return results@@ -288,7 +283,6 @@ class Speech2TextParaformer:decoding_ind: int = 0,**kwargs,):- assert check_argument_types()# 1. Build ASR modelscorers = {}@@ -413,7 +407,6 @@ class Speech2TextParaformer:text, token, token_int, hyp"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):@@ -516,7 +509,6 @@ class Speech2TextParaformer:vad_offset=begin_time)results.append((text, token, token_int, hyp, timestamp, enc_len_batch_total, lfr_factor))- # assert check_return_type(results)return resultsdef generate_hotwords_list(self, hotword_list_or_file):@@ -656,7 +648,6 @@ class Speech2TextParaformerOnline:hotword_list_or_file: str = None,**kwargs,):- assert check_argument_types()# 1. Build ASR modelscorers = {}@@ -776,7 +767,6 @@ class Speech2TextParaformerOnline:text, token, token_int, hyp"""- assert check_argument_types()results = []cache_en = cache["encoder"]if speech.shape[1] < 16 * 60 and cache_en["is_final"]:@@ -871,7 +861,6 @@ class Speech2TextParaformerOnline:results.append(postprocessed_result)- # assert check_return_type(results)return results@@ -912,7 +901,6 @@ class Speech2TextUniASR:frontend_conf: dict = None,**kwargs,):- assert check_argument_types()# 1. Build ASR modelscorers = {}@@ -1036,7 +1024,6 @@ class Speech2TextUniASR:text, token, token_int, hyp"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):@@ -1104,7 +1091,6 @@ class Speech2TextUniASR:text = Noneresults.append((text, token, token_int, hyp))- assert check_return_type(results)return results@@ -1143,7 +1129,6 @@ class Speech2TextMFCCA:streaming: bool = False,**kwargs,):- assert check_argument_types()# 1. Build ASR modelscorers = {}@@ -1248,7 +1233,6 @@ class Speech2TextMFCCA:text, token, token_int, hyp"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):speech = torch.tensor(speech)@@ -1298,7 +1282,6 @@ class Speech2TextMFCCA:text = Noneresults.append((text, token, token_int, hyp))- assert check_return_type(results)return results@@ -1355,7 +1338,6 @@ class Speech2TextTransducer:"""Construct a Speech2Text object."""super().__init__()- assert check_argument_types()asr_model, asr_train_args = build_model_from_file(asr_train_config, asr_model_file, cmvn_file, device)@@ -1534,7 +1516,6 @@ class Speech2TextTransducer:Returns:nbest_hypothesis: N-best hypothesis."""- assert check_argument_types()if isinstance(speech, np.ndarray):speech = torch.tensor(speech)@@ -1566,7 +1547,6 @@ class Speech2TextTransducer:Returns:nbest_hypothesis: N-best hypothesis."""- assert check_argument_types()if isinstance(speech, np.ndarray):speech = torch.tensor(speech)@@ -1608,36 +1588,9 @@ class Speech2TextTransducer:text = Noneresults.append((text, token, token_int, hyp))- assert check_return_type(results)return results- @staticmethod- def from_pretrained(- model_tag: Optional[str] = None,- **kwargs: Optional[Any],- ) -> Speech2Text:- """Build Speech2Text instance from the pretrained model.- Args:- model_tag: Model tag of the pretrained models.- Return:- : Speech2Text instance.- """- if model_tag is not None:- try:- from espnet_model_zoo.downloader import ModelDownloader-- except ImportError:- logging.error(- "`espnet_model_zoo` is not installed. "- "Please install via `pip install -U espnet_model_zoo`."- )- raise- d = ModelDownloader()- kwargs.update(**d.download_and_unpack(model_tag))-- return Speech2TextTransducer(**kwargs)-class Speech2TextSAASR:"""Speech2Text class@@ -1675,7 +1628,6 @@ class Speech2TextSAASR:frontend_conf: dict = None,**kwargs,):- assert check_argument_types()# 1. Build ASR modelscorers = {}@@ -1793,7 +1745,6 @@ class Speech2TextSAASR:text, text_id, token, token_int, hyp"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):@@ -1886,5 +1837,4 @@ class Speech2TextSAASR:results.append((text, text_id, token, token_int, hyp))- assert check_return_type(results)return resultsdiff --git a/funasr/bin/asr_inference_launch.py b/funasr/bin/asr_inference_launch.pyindex 5d1b80488..37a5fe464 100644--- a/funasr/bin/asr_inference_launch.py+++ b/funasr/bin/asr_inference_launch.py@@ -21,7 +21,6 @@ import torchimport torchaudioimport soundfileimport yaml-from typeguard import check_argument_typesfrom funasr.bin.asr_infer import Speech2Textfrom funasr.bin.asr_infer import Speech2TextMFCCA@@ -80,7 +79,6 @@ def inference_asr(param_dict: dict = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)if batch_size > 1:@@ -240,7 +238,6 @@ def inference_paraformer(param_dict: dict = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)@@ -481,7 +478,6 @@ def inference_paraformer_vad_punc(param_dict: dict = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)@@ -749,7 +745,6 @@ def inference_paraformer_online(param_dict: dict = None,**kwargs,):- assert check_argument_types()if word_lm_train_config is not None:raise NotImplementedError("Word LM is not implemented")@@ -957,7 +952,6 @@ def inference_uniasr(param_dict: dict = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)if batch_size > 1:@@ -1126,7 +1120,6 @@ def inference_mfcca(param_dict: dict = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)if batch_size > 1:@@ -1314,7 +1307,6 @@ def inference_transducer(right_context: Number of frames in right context AFTER subsampling.display_partial_hypotheses: Whether to display partial hypotheses."""- assert check_argument_types()if batch_size > 1:raise NotImplementedError("batch decoding is not implemented")@@ -1464,7 +1456,6 @@ def inference_sa_asr(param_dict: dict = None,**kwargs,):- assert check_argument_types()if batch_size > 1:raise NotImplementedError("batch decoding is not implemented")if word_lm_train_config is not None:diff --git a/funasr/bin/diar_infer.py b/funasr/bin/diar_infer.pyindex 7c41b6031..3efa641bf 100755--- a/funasr/bin/diar_infer.py+++ b/funasr/bin/diar_infer.py@@ -15,7 +15,6 @@ import numpy as npimport torchfrom scipy.ndimage import median_filterfrom torch.nn import functional as F-from typeguard import check_argument_typesfrom funasr.models.frontend.wav_frontend import WavFrontendMel23from funasr.tasks.diar import DiarTask@@ -45,7 +44,6 @@ class Speech2DiarizationEEND:device: str = "cpu",dtype: str = "float32",):- assert check_argument_types()# 1. Build Diarization modeldiar_model, diar_train_args = build_model_from_file(@@ -88,7 +86,6 @@ class Speech2DiarizationEEND:diarization results"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):speech = torch.tensor(speech)@@ -107,36 +104,6 @@ class Speech2DiarizationEEND:return results- @staticmethod- def from_pretrained(- model_tag: Optional[str] = None,- **kwargs: Optional[Any],- ):- """Build Speech2Diarization instance from the pretrained model.-- Args:- model_tag (Optional[str]): Model tag of the pretrained models.- Currently, the tags of espnet_model_zoo are supported.-- Returns:- Speech2Diarization: Speech2Diarization instance.-- """- if model_tag is not None:- try:- from espnet_model_zoo.downloader import ModelDownloader-- except ImportError:- logging.error(- "`espnet_model_zoo` is not installed. "- "Please install via `pip install -U espnet_model_zoo`."- )- raise- d = ModelDownloader()- kwargs.update(**d.download_and_unpack(model_tag))-- return Speech2DiarizationEEND(**kwargs)-class Speech2DiarizationSOND:"""Speech2Xvector class@@ -163,7 +130,6 @@ class Speech2DiarizationSOND:smooth_size: int = 83,dur_threshold: float = 10,):- assert check_argument_types()# TODO: 1. Build Diarization modeldiar_model, diar_train_args = build_model_from_file(@@ -283,7 +249,6 @@ class Speech2DiarizationSOND:diarization results for each speaker"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):speech = torch.tensor(speech)@@ -305,33 +270,3 @@ class Speech2DiarizationSOND:results, pse_labels = self.post_processing(logits, profile.shape[1], output_format)return results, pse_labels-- @staticmethod- def from_pretrained(- model_tag: Optional[str] = None,- **kwargs: Optional[Any],- ):- """Build Speech2Xvector instance from the pretrained model.-- Args:- model_tag (Optional[str]): Model tag of the pretrained models.- Currently, the tags of espnet_model_zoo are supported.-- Returns:- Speech2Xvector: Speech2Xvector instance.-- """- if model_tag is not None:- try:- from espnet_model_zoo.downloader import ModelDownloader-- except ImportError:- logging.error(- "`espnet_model_zoo` is not installed. "- "Please install via `pip install -U espnet_model_zoo`."- )- raise- d = ModelDownloader()- kwargs.update(**d.download_and_unpack(model_tag))-- return Speech2DiarizationSOND(**kwargs)diff --git a/funasr/bin/diar_inference_launch.py b/funasr/bin/diar_inference_launch.pyindex 820217b1a..03c9659b5 100755--- a/funasr/bin/diar_inference_launch.py+++ b/funasr/bin/diar_inference_launch.py@@ -18,7 +18,6 @@ import numpy as npimport soundfileimport torchfrom scipy.signal import medfilt-from typeguard import check_argument_typesfrom funasr.bin.diar_infer import Speech2DiarizationSOND, Speech2DiarizationEENDfrom funasr.datasets.iterable_dataset import load_bytes@@ -52,7 +51,6 @@ def inference_sond(mode: str = "sond",**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)if batch_size > 1:@@ -233,7 +231,6 @@ def inference_eend(param_dict: Optional[dict] = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)if batch_size > 1:diff --git a/funasr/bin/lm_inference_launch.py b/funasr/bin/lm_inference_launch.pyindex c8482b8cc..236a923e7 100644--- a/funasr/bin/lm_inference_launch.py+++ b/funasr/bin/lm_inference_launch.py@@ -15,7 +15,6 @@ from typing import Unionimport numpy as npimport torchfrom torch.nn.parallel import data_parallel-from typeguard import check_argument_typesfrom funasr.build_utils.build_model_from_file import build_model_from_filefrom funasr.build_utils.build_streaming_iterator import build_streaming_iterator@@ -50,7 +49,6 @@ def inference_lm(param_dict: dict = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)diff --git a/funasr/bin/punc_inference_launch.py b/funasr/bin/punc_inference_launch.pyindex 8fc15f06b..5d917f5cd 100755--- a/funasr/bin/punc_inference_launch.py+++ b/funasr/bin/punc_inference_launch.py@@ -14,7 +14,6 @@ from typing import Optionalfrom typing import Unionimport torch-from typeguard import check_argument_typesfrom funasr.bin.punc_infer import Text2Punc, Text2PuncVADRealtimefrom funasr.torch_utils.set_all_random_seed import set_all_random_seed@@ -38,7 +37,6 @@ def inference_punc(param_dict: dict = None,**kwargs,):- assert check_argument_types()logging.basicConfig(level=log_level,format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",@@ -118,7 +116,6 @@ def inference_punc_vad_realtime(param_dict: dict = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)diff --git a/funasr/bin/sv_infer.py b/funasr/bin/sv_infer.pyindex 6e861da27..346440af0 100755--- a/funasr/bin/sv_infer.py+++ b/funasr/bin/sv_infer.py@@ -12,8 +12,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.build_utils.build_model_from_file import build_model_from_filefrom funasr.torch_utils.device_funcs import to_device@@ -42,7 +40,6 @@ class Speech2Xvector:streaming: bool = False,embedding_node: str = "resnet1_dense",):- assert check_argument_types()# TODO: 1. Build SV modelsv_model, sv_train_args = build_model_from_file(@@ -108,7 +105,6 @@ class Speech2Xvector:embedding, ref_embedding, similarity_score"""- assert check_argument_types()self.sv_model.eval()embedding = self.calculate_embedding(speech)ref_emb, score = None, None@@ -117,35 +113,4 @@ class Speech2Xvector:score = torch.cosine_similarity(embedding, ref_emb)results = (embedding, ref_emb, score)- assert check_return_type(results)return results-- @staticmethod- def from_pretrained(- model_tag: Optional[str] = None,- **kwargs: Optional[Any],- ):- """Build Speech2Xvector instance from the pretrained model.-- Args:- model_tag (Optional[str]): Model tag of the pretrained models.- Currently, the tags of espnet_model_zoo are supported.-- Returns:- Speech2Xvector: Speech2Xvector instance.-- """- if model_tag is not None:- try:- from espnet_model_zoo.downloader import ModelDownloader-- except ImportError:- logging.error(- "`espnet_model_zoo` is not installed. "- "Please install via `pip install -U espnet_model_zoo`."- )- raise- d = ModelDownloader()- kwargs.update(**d.download_and_unpack(model_tag))-- return Speech2Xvector(**kwargs)diff --git a/funasr/bin/sv_inference_launch.py b/funasr/bin/sv_inference_launch.pyindex d165736a5..2f9e276cf 100755--- a/funasr/bin/sv_inference_launch.py+++ b/funasr/bin/sv_inference_launch.py@@ -15,7 +15,6 @@ from typing import Unionimport numpy as npimport torchfrom kaldiio import WriteHelper-from typeguard import check_argument_typesfrom funasr.bin.sv_infer import Speech2Xvectorfrom funasr.build_utils.build_streaming_iterator import build_streaming_iterator@@ -46,7 +45,6 @@ def inference_sv(param_dict: Optional[dict] = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)@@ -79,10 +77,7 @@ def inference_sv(embedding_node=embedding_node)logging.info("speech2xvector_kwargs: {}".format(speech2xvector_kwargs))- speech2xvector = Speech2Xvector.from_pretrained(- model_tag=model_tag,- **speech2xvector_kwargs,- )+ speech2xvector = Speech2Xvector(**speech2xvector_kwargs)speech2xvector.sv_model.eval()def _forward(diff --git a/funasr/bin/tokenize_text.py b/funasr/bin/tokenize_text.pyindex dc565d03c..6ec83a89e 100755--- a/funasr/bin/tokenize_text.py+++ b/funasr/bin/tokenize_text.py@@ -7,7 +7,6 @@ import sysfrom typing import Listfrom typing import Optional-from typeguard import check_argument_typesfrom funasr.utils.cli_utils import get_commandline_argsfrom funasr.text.build_tokenizer import build_tokenizer@@ -81,7 +80,6 @@ def tokenize(cleaner: Optional[str],g2p: Optional[str],):- assert check_argument_types()logging.basicConfig(level=log_level,diff --git a/funasr/bin/tp_infer.py b/funasr/bin/tp_infer.pyindex 213c018f0..ede579c7b 100644--- a/funasr/bin/tp_infer.py+++ b/funasr/bin/tp_infer.py@@ -9,7 +9,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.build_utils.build_model_from_file import build_model_from_filefrom funasr.models.frontend.wav_frontend import WavFrontendfrom funasr.text.token_id_converter import TokenIDConverter@@ -26,7 +25,6 @@ class Speech2Timestamp:dtype: str = "float32",**kwargs,):- assert check_argument_types()# 1. Build ASR modeltp_model, tp_train_args = build_model_from_file(timestamp_infer_config, timestamp_model_file, cmvn_file=None, device=device, task_name="asr", mode="tp"@@ -64,7 +62,6 @@ class Speech2Timestamp:speech_lengths: Union[torch.Tensor, np.ndarray] = None,text_lengths: Union[torch.Tensor, np.ndarray] = None):- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):diff --git a/funasr/bin/tp_inference_launch.py b/funasr/bin/tp_inference_launch.pyindex 3f8df0cee..6c102544c 100644--- a/funasr/bin/tp_inference_launch.py+++ b/funasr/bin/tp_inference_launch.py@@ -13,7 +13,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.bin.tp_infer import Speech2Timestampfrom funasr.build_utils.build_streaming_iterator import build_streaming_iterator@@ -47,7 +46,6 @@ def inference_tp(seg_dict_file: Optional[str] = None,**kwargs,):- assert check_argument_types()ncpu = kwargs.get("ncpu", 1)torch.set_num_threads(ncpu)diff --git a/funasr/bin/vad_infer.py b/funasr/bin/vad_infer.pyindex f888bb458..c60a8f12a 100644--- a/funasr/bin/vad_infer.py+++ b/funasr/bin/vad_infer.py@@ -13,7 +13,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.build_utils.build_model_from_file import build_model_from_filefrom funasr.models.frontend.wav_frontend import WavFrontend, WavFrontendOnline@@ -42,7 +41,6 @@ class Speech2VadSegment:dtype: str = "float32",**kwargs,):- assert check_argument_types()# 1. Build vad modelvad_model, vad_infer_args = build_model_from_file(@@ -76,7 +74,6 @@ class Speech2VadSegment:text, token, token_int, hyp"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):@@ -149,7 +146,6 @@ class Speech2VadSegmentOnline(Speech2VadSegment):text, token, token_int, hyp"""- assert check_argument_types()# Input as audio signalif isinstance(speech, np.ndarray):diff --git a/funasr/bin/vad_inference_launch.py b/funasr/bin/vad_inference_launch.pyindex 829f157f4..47af01112 100644--- a/funasr/bin/vad_inference_launch.py+++ b/funasr/bin/vad_inference_launch.py@@ -18,7 +18,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.build_utils.build_streaming_iterator import build_streaming_iteratorfrom funasr.fileio.datadir_writer import DatadirWriterfrom funasr.torch_utils.set_all_random_seed import set_all_random_seed@@ -47,7 +46,6 @@ def inference_vad(num_workers: int = 1,**kwargs,):- assert check_argument_types()if batch_size > 1:raise NotImplementedError("batch decoding is not implemented")@@ -148,7 +146,6 @@ def inference_vad_online(num_workers: int = 1,**kwargs,):- assert check_argument_types()logging.basicConfig(level=log_level,diff --git a/funasr/build_utils/build_model_from_file.py b/funasr/build_utils/build_model_from_file.pyindex 8fd4e4638..26542cd60 100644--- a/funasr/build_utils/build_model_from_file.py+++ b/funasr/build_utils/build_model_from_file.py@@ -6,7 +6,6 @@ from typing import Unionimport torchimport yaml-from typeguard import check_argument_typesfrom funasr.build_utils.build_model import build_modelfrom funasr.models.base_model import FunASRModel@@ -30,7 +29,6 @@ def build_model_from_file(device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "diff --git a/funasr/build_utils/build_streaming_iterator.py b/funasr/build_utils/build_streaming_iterator.pyindex 1b16cf4ec..02fc26365 100644--- a/funasr/build_utils/build_streaming_iterator.py+++ b/funasr/build_utils/build_streaming_iterator.py@@ -1,6 +1,5 @@import numpy as npfrom torch.utils.data import DataLoader-from typeguard import check_argument_typesfrom funasr.datasets.iterable_dataset import IterableESPnetDatasetfrom funasr.datasets.small_datasets.collate_fn import CommonCollateFn@@ -23,7 +22,6 @@ def build_streaming_iterator(train: bool = False,) -> DataLoader:"""Build DataLoader using iterable dataset"""- assert check_argument_types()# preprocessif preprocess_fn is not None:diff --git a/funasr/build_utils/build_sv_model.py b/funasr/build_utils/build_sv_model.pyindex c0f1ae8ca..55df75afd 100644--- a/funasr/build_utils/build_sv_model.py+++ b/funasr/build_utils/build_sv_model.py@@ -1,7 +1,6 @@import loggingimport torch-from typeguard import check_return_typefrom funasr.layers.abs_normalize import AbsNormalizefrom funasr.layers.global_mvn import GlobalMVN@@ -254,5 +253,4 @@ def build_sv_model(args):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return modeldiff --git a/funasr/build_utils/build_trainer.py b/funasr/build_utils/build_trainer.pyindex aff99b5fa..03aa7802d 100644--- a/funasr/build_utils/build_trainer.py+++ b/funasr/build_utils/build_trainer.py@@ -25,7 +25,6 @@ import oss2import torchimport torch.nnimport torch.optim-from typeguard import check_argument_typesfrom funasr.iterators.abs_iter_factory import AbsIterFactoryfrom funasr.main_funcs.average_nbest_models import average_nbest_models@@ -118,7 +117,6 @@ class Trainer:def build_options(self, args: argparse.Namespace) -> TrainerOptions:"""Build options consumed by train(), eval()"""- assert check_argument_types()return build_dataclass(TrainerOptions, args)@classmethod@@ -156,7 +154,6 @@ class Trainer:def run(self) -> None:"""Perform training. This method performs the main process of training."""- assert check_argument_types()# NOTE(kamo): Don't check the type more strictly as far trainer_optionsmodel = self.modeloptimizers = self.optimizers@@ -522,7 +519,6 @@ class Trainer:options: TrainerOptions,distributed_option: DistributedOption,) -> Tuple[bool, bool]:- assert check_argument_types()grad_noise = options.grad_noiseaccum_grad = options.accum_grad@@ -758,7 +754,6 @@ class Trainer:options: TrainerOptions,distributed_option: DistributedOption,) -> None:- assert check_argument_types()ngpu = options.ngpu# no_forward_run = options.no_forward_rundistributed = distributed_option.distributeddiff --git a/funasr/datasets/collate_fn.py b/funasr/datasets/collate_fn.pyindex d34d61032..cbc1f0b7c 100644--- a/funasr/datasets/collate_fn.py+++ b/funasr/datasets/collate_fn.py@@ -6,8 +6,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.modules.nets_utils import pad_list@@ -22,7 +20,6 @@ class CommonCollateFn:not_sequence: Collection[str] = (),max_sample_size=None):- assert check_argument_types()self.float_pad_value = float_pad_valueself.int_pad_value = int_pad_valueself.not_sequence = set(not_sequence)@@ -53,7 +50,6 @@ def common_collate_fn() -> Tuple[List[str], Dict[str, torch.Tensor]]:"""Concatenate ndarray-list to an array and convert to torch.Tensor."""- assert check_argument_types()uttids = [u for u, _ in data]data = [d for _, d in data]@@ -79,7 +75,6 @@ def common_collate_fn(output[key + "_lengths"] = lensoutput = (uttids, output)- assert check_return_type(output)return outputdef crop_to_max_size(feature, target_size):@@ -99,7 +94,6 @@ def clipping_collate_fn(not_sequence: Collection[str] = (),) -> Tuple[List[str], Dict[str, torch.Tensor]]:# mainly for pre-training- assert check_argument_types()uttids = [u for u, _ in data]data = [d for _, d in data]@@ -131,5 +125,4 @@ def clipping_collate_fn(output[key + "_lengths"] = lensoutput = (uttids, output)- assert check_return_type(output)return output\ No newline at end of filediff --git a/funasr/datasets/dataset.py b/funasr/datasets/dataset.pyindex 979479c73..407f6aa9e 100644--- a/funasr/datasets/dataset.py+++ b/funasr/datasets/dataset.py@@ -23,8 +23,6 @@ import kaldiioimport numpy as npimport torchfrom torch.utils.data.dataset import Dataset-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.fileio.npy_scp import NpyScpReaderfrom funasr.fileio.rand_gen_dataset import FloatRandomGenerateDataset@@ -37,7 +35,6 @@ from funasr.utils.sized_dict import SizedDictclass AdapterForSoundScpReader(collections.abc.Mapping):def __init__(self, loader, dtype=None):- assert check_argument_types()self.loader = loaderself.dtype = dtypeself.rate = None@@ -284,7 +281,6 @@ class ESPnetDataset(AbsDataset):max_cache_fd: int = 0,dest_sample_rate: int = 16000,):- assert check_argument_types()if len(path_name_type_list) == 0:raise ValueError('1 or more elements are required for "path_name_type_list"'@@ -379,7 +375,6 @@ class ESPnetDataset(AbsDataset):return _mesdef __getitem__(self, uid: Union[str, int]) -> Tuple[str, Dict[str, np.ndarray]]:- assert check_argument_types()# Change integer-id to string-idif isinstance(uid, int):@@ -444,5 +439,4 @@ class ESPnetDataset(AbsDataset):self.cache[uid] = dataretval = uid, data- assert check_return_type(retval)return retvaldiff --git a/funasr/datasets/iterable_dataset.py b/funasr/datasets/iterable_dataset.pyindex d240d93b9..6398e0cf7 100644--- a/funasr/datasets/iterable_dataset.py+++ b/funasr/datasets/iterable_dataset.py@@ -16,7 +16,6 @@ import torchimport torchaudioimport soundfilefrom torch.utils.data.dataset import IterableDataset-from typeguard import check_argument_typesimport os.pathfrom funasr.datasets.dataset import ESPnetDataset@@ -121,7 +120,6 @@ class IterableESPnetDataset(IterableDataset):int_dtype: str = "long",key_file: str = None,):- assert check_argument_types()if len(path_name_type_list) == 0:raise ValueError('1 or more elements are required for "path_name_type_list"'diff --git a/funasr/datasets/large_datasets/build_dataloader.py b/funasr/datasets/large_datasets/build_dataloader.pyindex aa5d9be56..7a1a9066e 100644--- a/funasr/datasets/large_datasets/build_dataloader.py+++ b/funasr/datasets/large_datasets/build_dataloader.py@@ -6,7 +6,6 @@ from typing import Unionimport sentencepiece as spmfrom torch.utils.data import DataLoader-from typeguard import check_argument_typesfrom funasr.datasets.large_datasets.dataset import Datasetfrom funasr.iterators.abs_iter_factory import AbsIterFactory@@ -43,7 +42,6 @@ def load_seg_dict(seg_dict_file):class SentencepiecesTokenizer(AbsTokenizer):def __init__(self, model: Union[Path, str]):- assert check_argument_types()self.model = str(model)self.sp = Nonediff --git a/funasr/datasets/preprocessor.py b/funasr/datasets/preprocessor.pyindex 758c75045..cb4288c19 100644--- a/funasr/datasets/preprocessor.py+++ b/funasr/datasets/preprocessor.py@@ -11,8 +11,6 @@ from typing import Unionimport numpy as npimport scipy.signalimport soundfile-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.text.build_tokenizer import build_tokenizerfrom funasr.text.cleaner import TextCleaner@@ -268,7 +266,6 @@ class CommonPreprocessor(AbsPreprocessor):def _speech_process(self, data: Dict[str, Union[str, np.ndarray]]) -> Dict[str, Union[str, np.ndarray]]:- assert check_argument_types()if self.speech_name in data:if self.train and (self.rirs is not None or self.noises is not None):speech = data[self.speech_name]@@ -355,7 +352,6 @@ class CommonPreprocessor(AbsPreprocessor):speech = data[self.speech_name]ma = np.max(np.abs(speech))data[self.speech_name] = speech * self.speech_volume_normalize / ma- assert check_return_type(data)return datadef _text_process(@@ -372,13 +368,11 @@ class CommonPreprocessor(AbsPreprocessor):tokens = self.tokenizer.text2tokens(text)text_ints = self.token_id_converter.tokens2ids(tokens)data[self.text_name] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return datadef __call__(self, uid: str, data: Dict[str, Union[str, np.ndarray]]) -> Dict[str, np.ndarray]:- assert check_argument_types()data = self._speech_process(data)data = self._text_process(data)@@ -445,7 +439,6 @@ class LMPreprocessor(CommonPreprocessor):tokens = self.tokenizer.text2tokens(text)text_ints = self.token_id_converter.tokens2ids(tokens)data[self.text_name] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return data@@ -502,13 +495,11 @@ class CommonPreprocessor_multi(AbsPreprocessor):tokens = self.tokenizer.text2tokens(text)text_ints = self.token_id_converter.tokens2ids(tokens)data[text_n] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return datadef __call__(self, uid: str, data: Dict[str, Union[str, np.ndarray]]) -> Dict[str, np.ndarray]:- assert check_argument_types()if self.speech_name in data:# Nothing now: candidates:@@ -612,7 +603,6 @@ class MutliTokenizerCommonPreprocessor(CommonPreprocessor):tokens = self.tokenizer[i].text2tokens(text)text_ints = self.token_id_converter[i].tokens2ids(tokens)data[text_name] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return dataclass CodeMixTokenizerCommonPreprocessor(CommonPreprocessor):@@ -690,7 +680,6 @@ class CodeMixTokenizerCommonPreprocessor(CommonPreprocessor):def __call__(self, uid: str, data: Dict[str, Union[list, str, np.ndarray]]) -> Dict[str, Union[list, np.ndarray]]:- assert check_argument_types()# Split words.if isinstance(data[self.text_name], str):split_text = self.split_words(data[self.text_name])diff --git a/funasr/datasets/small_datasets/collate_fn.py b/funasr/datasets/small_datasets/collate_fn.pyindex 573f58114..5fd41621d 100644--- a/funasr/datasets/small_datasets/collate_fn.py+++ b/funasr/datasets/small_datasets/collate_fn.py@@ -6,8 +6,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.modules.nets_utils import pad_list@@ -22,7 +20,6 @@ class CommonCollateFn:not_sequence: Collection[str] = (),max_sample_size=None):- assert check_argument_types()self.float_pad_value = float_pad_valueself.int_pad_value = int_pad_valueself.not_sequence = set(not_sequence)@@ -53,7 +50,6 @@ def common_collate_fn() -> Tuple[List[str], Dict[str, torch.Tensor]]:"""Concatenate ndarray-list to an array and convert to torch.Tensor."""- assert check_argument_types()uttids = [u for u, _ in data]data = [d for _, d in data]@@ -79,7 +75,6 @@ def common_collate_fn(output[key + "_lengths"] = lensoutput = (uttids, output)- assert check_return_type(output)return outputdef crop_to_max_size(feature, target_size):diff --git a/funasr/datasets/small_datasets/dataset.py b/funasr/datasets/small_datasets/dataset.pyindex 123f109fc..bee9f5034 100644--- a/funasr/datasets/small_datasets/dataset.py+++ b/funasr/datasets/small_datasets/dataset.py@@ -15,8 +15,6 @@ import kaldiioimport numpy as npimport torchfrom torch.utils.data.dataset import Dataset-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.fileio.npy_scp import NpyScpReaderfrom funasr.fileio.sound_scp import SoundScpReader@@ -24,7 +22,6 @@ from funasr.fileio.sound_scp import SoundScpReaderclass AdapterForSoundScpReader(collections.abc.Mapping):def __init__(self, loader, dtype=None):- assert check_argument_types()self.loader = loaderself.dtype = dtypeself.rate = None@@ -112,7 +109,6 @@ class ESPnetDataset(Dataset):speed_perturb: Union[list, tuple] = None,mode: str = "train",):- assert check_argument_types()if len(path_name_type_list) == 0:raise ValueError('1 or more elements are required for "path_name_type_list"'@@ -207,7 +203,6 @@ class ESPnetDataset(Dataset):return _mesdef __getitem__(self, uid: Union[str, int]) -> Tuple[str, Dict[str, np.ndarray]]:- assert check_argument_types()# Change integer-id to string-idif isinstance(uid, int):@@ -265,5 +260,4 @@ class ESPnetDataset(Dataset):data[name] = valueretval = uid, data- assert check_return_type(retval)return retvaldiff --git a/funasr/datasets/small_datasets/length_batch_sampler.py b/funasr/datasets/small_datasets/length_batch_sampler.pyindex 8ee8bdc52..28404e32c 100644--- a/funasr/datasets/small_datasets/length_batch_sampler.py+++ b/funasr/datasets/small_datasets/length_batch_sampler.py@@ -4,7 +4,6 @@ from typing import Dictfrom typing import Tuplefrom typing import Union-from typeguard import check_argument_typesfrom funasr.fileio.read_text import load_num_sequence_textfrom funasr.samplers.abs_sampler import AbsSampler@@ -21,7 +20,6 @@ class LengthBatchSampler(AbsSampler):drop_last: bool = False,padding: bool = True,):- assert check_argument_types()assert batch_bins > 0if sort_batch != "ascending" and sort_batch != "descending":raise ValueError(diff --git a/funasr/datasets/small_datasets/preprocessor.py b/funasr/datasets/small_datasets/preprocessor.pyindex d80f48ac0..0ebf325e0 100644--- a/funasr/datasets/small_datasets/preprocessor.py+++ b/funasr/datasets/small_datasets/preprocessor.py@@ -10,8 +10,6 @@ from typing import Unionimport numpy as npimport scipy.signalimport soundfile-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.text.build_tokenizer import build_tokenizerfrom funasr.text.cleaner import TextCleaner@@ -260,7 +258,6 @@ class CommonPreprocessor(AbsPreprocessor):def _speech_process(self, data: Dict[str, Union[str, np.ndarray]]) -> Dict[str, Union[str, np.ndarray]]:- assert check_argument_types()if self.speech_name in data:if self.train and (self.rirs is not None or self.noises is not None):speech = data[self.speech_name]@@ -347,7 +344,6 @@ class CommonPreprocessor(AbsPreprocessor):speech = data[self.speech_name]ma = np.max(np.abs(speech))data[self.speech_name] = speech * self.speech_volume_normalize / ma- assert check_return_type(data)return datadef _text_process(@@ -365,13 +361,11 @@ class CommonPreprocessor(AbsPreprocessor):tokens = self.tokenizer.text2tokens(text)text_ints = self.token_id_converter.tokens2ids(tokens)data[self.text_name] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return datadef __call__(self, uid: str, data: Dict[str, Union[str, np.ndarray]]) -> Dict[str, np.ndarray]:- assert check_argument_types()data = self._speech_process(data)data = self._text_process(data)@@ -439,7 +433,6 @@ class LMPreprocessor(CommonPreprocessor):tokens = self.tokenizer.text2tokens(text)text_ints = self.token_id_converter.tokens2ids(tokens)data[self.text_name] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return data@@ -496,13 +489,11 @@ class CommonPreprocessor_multi(AbsPreprocessor):tokens = self.tokenizer.text2tokens(text)text_ints = self.token_id_converter.tokens2ids(tokens)data[text_n] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return datadef __call__(self, uid: str, data: Dict[str, Union[str, np.ndarray]]) -> Dict[str, np.ndarray]:- assert check_argument_types()if self.speech_name in data:# Nothing now: candidates:@@ -606,7 +597,6 @@ class MutliTokenizerCommonPreprocessor(CommonPreprocessor):tokens = self.tokenizer[i].text2tokens(text)text_ints = self.token_id_converter[i].tokens2ids(tokens)data[text_name] = np.array(text_ints, dtype=np.int64)- assert check_return_type(data)return data@@ -685,7 +675,6 @@ class CodeMixTokenizerCommonPreprocessor(CommonPreprocessor):def __call__(self, uid: str, data: Dict[str, Union[list, str, np.ndarray]]) -> Dict[str, Union[list, np.ndarray]]:- assert check_argument_types()# Split words.if isinstance(data[self.text_name], str):split_text = self.split_words(data[self.text_name])diff --git a/funasr/export/export_model.py b/funasr/export/export_model.pyindex b14153233..a68724a7c 100644--- a/funasr/export/export_model.py+++ b/funasr/export/export_model.py@@ -1,7 +1,6 @@import jsonfrom typing import Union, Dictfrom pathlib import Path-from typeguard import check_argument_typesimport osimport logging@@ -26,7 +25,6 @@ class ModelExport:calib_num: int = 200,model_revision: str = None,):- assert check_argument_types()self.set_all_random_seed(0)self.cache_dir = cache_dirdiff --git a/funasr/fileio/datadir_writer.py b/funasr/fileio/datadir_writer.pyindex 67ec61c76..e555ebcc5 100644--- a/funasr/fileio/datadir_writer.py+++ b/funasr/fileio/datadir_writer.py@@ -2,8 +2,6 @@ from pathlib import Pathfrom typing import Unionimport warnings-from typeguard import check_argument_types-from typeguard import check_return_typeclass DatadirWriter:@@ -20,7 +18,6 @@ class DatadirWriter:"""def __init__(self, p: Union[Path, str]):- assert check_argument_types()self.path = Path(p)self.chilidren = {}self.fd = None@@ -31,7 +28,6 @@ class DatadirWriter:return selfdef __getitem__(self, key: str) -> "DatadirWriter":- assert check_argument_types()if self.fd is not None:raise RuntimeError("This writer points out a file")@@ -41,11 +37,9 @@ class DatadirWriter:self.has_children = Trueretval = self.chilidren[key]- assert check_return_type(retval)return retvaldef __setitem__(self, key: str, value: str):- assert check_argument_types()if self.has_children:raise RuntimeError("This writer points out a directory")if key in self.keys:diff --git a/funasr/fileio/npy_scp.py b/funasr/fileio/npy_scp.pyindex 26666b678..2bd5b5867 100644--- a/funasr/fileio/npy_scp.py+++ b/funasr/fileio/npy_scp.py@@ -3,7 +3,6 @@ from pathlib import Pathfrom typing import Unionimport numpy as np-from typeguard import check_argument_typesfrom funasr.fileio.read_text import read_2column_text@@ -25,7 +24,6 @@ class NpyScpWriter:"""def __init__(self, outdir: Union[Path, str], scpfile: Union[Path, str]):- assert check_argument_types()self.dir = Path(outdir)self.dir.mkdir(parents=True, exist_ok=True)scpfile = Path(scpfile)@@ -73,7 +71,6 @@ class NpyScpReader(collections.abc.Mapping):"""def __init__(self, fname: Union[Path, str]):- assert check_argument_types()self.fname = Path(fname)self.data = read_2column_text(fname)diff --git a/funasr/fileio/rand_gen_dataset.py b/funasr/fileio/rand_gen_dataset.pyindex 2faef3a04..699e67a5f 100644--- a/funasr/fileio/rand_gen_dataset.py+++ b/funasr/fileio/rand_gen_dataset.py@@ -3,7 +3,6 @@ from pathlib import Pathfrom typing import Unionimport numpy as np-from typeguard import check_argument_typesfrom funasr.fileio.read_text import load_num_sequence_text@@ -29,7 +28,6 @@ class FloatRandomGenerateDataset(collections.abc.Mapping):dtype: Union[str, np.dtype] = "float32",loader_type: str = "csv_int",):- assert check_argument_types()shape_file = Path(shape_file)self.utt2shape = load_num_sequence_text(shape_file, loader_type)self.dtype = np.dtype(dtype)@@ -68,7 +66,6 @@ class IntRandomGenerateDataset(collections.abc.Mapping):dtype: Union[str, np.dtype] = "int64",loader_type: str = "csv_int",):- assert check_argument_types()shape_file = Path(shape_file)self.utt2shape = load_num_sequence_text(shape_file, loader_type)self.dtype = np.dtype(dtype)diff --git a/funasr/fileio/read_text.py b/funasr/fileio/read_text.pyindex e26e7a1c5..f140c31f2 100644--- a/funasr/fileio/read_text.py+++ b/funasr/fileio/read_text.py@@ -4,7 +4,6 @@ from typing import Dictfrom typing import Listfrom typing import Union-from typeguard import check_argument_typesdef read_2column_text(path: Union[Path, str]) -> Dict[str, str]:@@ -19,7 +18,6 @@ def read_2column_text(path: Union[Path, str]) -> Dict[str, str]:{'key1': '/some/path/a.wav', 'key2': '/some/path/b.wav'}"""- assert check_argument_types()data = {}with Path(path).open("r", encoding="utf-8") as f:@@ -47,7 +45,6 @@ def load_num_sequence_text(>>> d = load_num_sequence_text('text')>>> np.testing.assert_array_equal(d["key1"], np.array([1, 2, 3]))"""- assert check_argument_types()if loader_type == "text_int":delimiter = " "dtype = intdiff --git a/funasr/fileio/sound_scp.py b/funasr/fileio/sound_scp.pyindex 9b25fe577..b912f1ee9 100644--- a/funasr/fileio/sound_scp.py+++ b/funasr/fileio/sound_scp.py@@ -6,7 +6,6 @@ import randomimport numpy as npimport soundfileimport librosa-from typeguard import check_argument_typesimport torchimport torchaudio@@ -106,7 +105,6 @@ class SoundScpReader(collections.abc.Mapping):dest_sample_rate: int = 16000,speed_perturb: Union[list, tuple] = None,):- assert check_argument_types()self.fname = fnameself.dtype = dtypeself.always_2d = always_2d@@ -179,7 +177,6 @@ class SoundScpWriter:format="wav",dtype=None,):- assert check_argument_types()self.dir = Path(outdir)self.dir.mkdir(parents=True, exist_ok=True)scpfile = Path(scpfile)diff --git a/funasr/iterators/chunk_iter_factory.py b/funasr/iterators/chunk_iter_factory.pyindex cec637040..5a5463270 100644--- a/funasr/iterators/chunk_iter_factory.py+++ b/funasr/iterators/chunk_iter_factory.py@@ -9,7 +9,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.iterators.abs_iter_factory import AbsIterFactoryfrom funasr.iterators.sequence_iter_factory import SequenceIterFactory@@ -51,7 +50,6 @@ class ChunkIterFactory(AbsIterFactory):collate_fn=None,pin_memory: bool = False,):- assert check_argument_types()assert all(len(x) == 1 for x in batches), "batch-size must be 1"self.per_sample_iter_factory = SequenceIterFactory(diff --git a/funasr/iterators/multiple_iter_factory.py b/funasr/iterators/multiple_iter_factory.pyindex 088016cf3..3587a2abc 100644--- a/funasr/iterators/multiple_iter_factory.py+++ b/funasr/iterators/multiple_iter_factory.py@@ -4,7 +4,6 @@ from typing import Collectionfrom typing import Iteratorimport numpy as np-from typeguard import check_argument_typesfrom funasr.iterators.abs_iter_factory import AbsIterFactory@@ -16,7 +15,6 @@ class MultipleIterFactory(AbsIterFactory):seed: int = 0,shuffle: bool = False,):- assert check_argument_types()self.build_funcs = list(build_funcs)self.seed = seedself.shuffle = shufflediff --git a/funasr/iterators/sequence_iter_factory.py b/funasr/iterators/sequence_iter_factory.pyindex 39d083446..41de37c53 100644--- a/funasr/iterators/sequence_iter_factory.py+++ b/funasr/iterators/sequence_iter_factory.py@@ -4,7 +4,6 @@ from typing import Unionimport numpy as npfrom torch.utils.data import DataLoader-from typeguard import check_argument_typesfrom funasr.iterators.abs_iter_factory import AbsIterFactoryfrom funasr.samplers.abs_sampler import AbsSampler@@ -46,7 +45,6 @@ class SequenceIterFactory(AbsIterFactory):collate_fn=None,pin_memory: bool = False,):- assert check_argument_types()if not isinstance(batches, AbsSampler):self.sampler = RawSampler(batches)diff --git a/funasr/layers/global_mvn.py b/funasr/layers/global_mvn.pyindex 8e43582a4..b94e9cac7 100644--- a/funasr/layers/global_mvn.py+++ b/funasr/layers/global_mvn.py@@ -4,7 +4,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.layers.abs_normalize import AbsNormalize@@ -28,7 +27,6 @@ class GlobalMVN(AbsNormalize, InversibleInterface):norm_vars: bool = True,eps: float = 1.0e-20,):- assert check_argument_types()super().__init__()self.norm_means = norm_meansself.norm_vars = norm_varsdiff --git a/funasr/layers/label_aggregation.py b/funasr/layers/label_aggregation.pyindex 29a08a9f9..8366a7983 100644--- a/funasr/layers/label_aggregation.py+++ b/funasr/layers/label_aggregation.py@@ -1,5 +1,4 @@import torch-from typeguard import check_argument_typesfrom typing import Optionalfrom typing import Tuple@@ -13,7 +12,6 @@ class LabelAggregate(torch.nn.Module):hop_length: int = 128,center: bool = True,):- assert check_argument_types()super().__init__()self.win_length = win_lengthdiff --git a/funasr/layers/mask_along_axis.py b/funasr/layers/mask_along_axis.pyindex e49e621cc..416c4ea7b 100644--- a/funasr/layers/mask_along_axis.py+++ b/funasr/layers/mask_along_axis.py@@ -1,6 +1,5 @@import mathimport torch-from typeguard import check_argument_typesfrom typing import Sequencefrom typing import Union@@ -147,7 +146,6 @@ class MaskAlongAxis(torch.nn.Module):dim: Union[int, str] = "time",replace_with_zero: bool = True,):- assert check_argument_types()if isinstance(mask_width_range, int):mask_width_range = (0, mask_width_range)if len(mask_width_range) != 2:@@ -214,7 +212,6 @@ class MaskAlongAxisVariableMaxWidth(torch.nn.Module):dim: Union[int, str] = "time",replace_with_zero: bool = True,):- assert check_argument_types()if isinstance(mask_width_ratio_range, float):mask_width_ratio_range = (0.0, mask_width_ratio_range)if len(mask_width_ratio_range) != 2:@@ -283,7 +280,6 @@ class MaskAlongAxisLFR(torch.nn.Module):replace_with_zero: bool = True,lfr_rate: int = 1,):- assert check_argument_types()if isinstance(mask_width_range, int):mask_width_range = (0, mask_width_range)if len(mask_width_range) != 2:diff --git a/funasr/layers/sinc_conv.py b/funasr/layers/sinc_conv.pyindex 33df97fbc..ab16a734c 100644--- a/funasr/layers/sinc_conv.py+++ b/funasr/layers/sinc_conv.py@@ -5,7 +5,6 @@"""Sinc convolutions."""import mathimport torch-from typeguard import check_argument_typesfrom typing import Union@@ -71,7 +70,6 @@ class SincConv(torch.nn.Module):window_func: Window function on the filter, one of ["hamming", "none"].fs (str, int, float): Sample rate of the input data"""- assert check_argument_types()super().__init__()window_funcs = {"none": self.none_window,@@ -208,7 +206,6 @@ class MelScale:torch.Tensor: Filter start frequencíes.torch.Tensor: Filter stop frequencies."""- assert check_argument_types()# min and max bandpass edge frequenciesmin_frequency = torch.tensor(30.0)max_frequency = torch.tensor(fs * 0.5)@@ -257,7 +254,6 @@ class BarkScale:torch.Tensor: Filter start frequencíes.torch.Tensor: Filter stop frequencíes."""- assert check_argument_types()# min and max BARK center frequencies by approximationmin_center_frequency = torch.tensor(70.0)max_center_frequency = torch.tensor(fs * 0.45)diff --git a/funasr/layers/stft.py b/funasr/layers/stft.pyindex 376b5a35f..dfb69193b 100644--- a/funasr/layers/stft.py+++ b/funasr/layers/stft.py@@ -5,7 +5,6 @@ from typing import Unionimport torchfrom torch_complex.tensor import ComplexTensor-from typeguard import check_argument_typesfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.layers.complex_utils import is_complex@@ -30,7 +29,6 @@ class Stft(torch.nn.Module, InversibleInterface):normalized: bool = False,onesided: bool = True,):- assert check_argument_types()super().__init__()self.n_fft = n_fftif win_length is None:diff --git a/funasr/layers/utterance_mvn.py b/funasr/layers/utterance_mvn.pyindex 50f27cd55..7722974f3 100644--- a/funasr/layers/utterance_mvn.py+++ b/funasr/layers/utterance_mvn.py@@ -1,7 +1,6 @@from typing import Tupleimport torch-from typeguard import check_argument_typesfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.layers.abs_normalize import AbsNormalize@@ -14,7 +13,6 @@ class UtteranceMVN(AbsNormalize):norm_vars: bool = False,eps: float = 1.0e-20,):- assert check_argument_types()super().__init__()self.norm_means = norm_meansself.norm_vars = norm_varsdiff --git a/funasr/main_funcs/average_nbest_models.py b/funasr/main_funcs/average_nbest_models.pyindex d8df94985..96e138428 100644--- a/funasr/main_funcs/average_nbest_models.py+++ b/funasr/main_funcs/average_nbest_models.py@@ -8,7 +8,6 @@ import osfrom io import BytesIOimport torch-from typeguard import check_argument_typesfrom typing import Collectionfrom funasr.train.reporter import Reporter@@ -34,7 +33,6 @@ def average_nbest_models(nbest: Number of best model files to be averagedsuffix: A suffix added to the averaged model file name"""- assert check_argument_types()if isinstance(nbest, int):nbests = [nbest]else:diff --git a/funasr/main_funcs/collect_stats.py b/funasr/main_funcs/collect_stats.pyindex 584b85a29..ee2182c1f 100644--- a/funasr/main_funcs/collect_stats.py+++ b/funasr/main_funcs/collect_stats.py@@ -11,7 +11,6 @@ import numpy as npimport torchfrom torch.nn.parallel import data_parallelfrom torch.utils.data import DataLoader-from typeguard import check_argument_typesfrom funasr.fileio.datadir_writer import DatadirWriterfrom funasr.fileio.npy_scp import NpyScpWriter@@ -37,7 +36,6 @@ def collect_stats(This method is used before executing train()."""- assert check_argument_types()npy_scp_writers = {}for itr, mode in zip([train_iter, valid_iter], ["train", "valid"]):diff --git a/funasr/models/ctc.py b/funasr/models/ctc.pyindex 64b87106a..d3c10fa40 100644--- a/funasr/models/ctc.py+++ b/funasr/models/ctc.py@@ -2,7 +2,6 @@ import loggingimport torchimport torch.nn.functional as F-from typeguard import check_argument_typesclass CTC(torch.nn.Module):@@ -25,7 +24,6 @@ class CTC(torch.nn.Module):reduce: bool = True,ignore_nan_grad: bool = True,):- assert check_argument_types()super().__init__()eprojs = encoder_output_sizeself.dropout_rate = dropout_rate@@ -41,11 +39,6 @@ class CTC(torch.nn.Module):if ignore_nan_grad:logging.warning("ignore_nan_grad option is not supported for warp_ctc")self.ctc_loss = warp_ctc.CTCLoss(size_average=True, reduce=reduce)-- elif self.ctc_type == "gtnctc":- from espnet.nets.pytorch_backend.gtn_ctc import GTNCTCLossFunction-- self.ctc_loss = GTNCTCLossFunction.applyelse:raise ValueError(f'ctc_type must be "builtin" or "warpctc": {self.ctc_type}'diff --git a/funasr/models/data2vec.py b/funasr/models/data2vec.pyindex e5bd64034..92c95cc2b 100644--- a/funasr/models/data2vec.py+++ b/funasr/models/data2vec.py@@ -10,7 +10,6 @@ from typing import Optionalfrom typing import Tupleimport torch-from typeguard import check_argument_typesfrom funasr.layers.abs_normalize import AbsNormalizefrom funasr.models.encoder.abs_encoder import AbsEncoder@@ -40,7 +39,6 @@ class Data2VecPretrainModel(FunASRModel):preencoder: Optional[AbsPreEncoder],encoder: AbsEncoder,):- assert check_argument_types()super().__init__()diff --git a/funasr/models/decoder/contextual_decoder.py b/funasr/models/decoder/contextual_decoder.pyindex 78105ab31..0e69c442d 100644--- a/funasr/models/decoder/contextual_decoder.py+++ b/funasr/models/decoder/contextual_decoder.py@@ -7,7 +7,6 @@ import numpy as npfrom funasr.modules.streaming_utils import utils as myutilsfrom funasr.models.decoder.transformer_decoder import BaseTransformerDecoder-from typeguard import check_argument_typesfrom funasr.modules.attention import MultiHeadedAttentionSANMDecoder, MultiHeadedAttentionCrossAttfrom funasr.modules.embedding import PositionalEncoding@@ -126,7 +125,6 @@ class ContextualParaformerDecoder(ParaformerSANMDecoder):kernel_size: int = 21,sanm_shfit: int = 0,):- assert check_argument_types()super().__init__(vocab_size=vocab_size,encoder_output_size=encoder_output_size,diff --git a/funasr/models/decoder/rnn_decoder.py b/funasr/models/decoder/rnn_decoder.pyindex 80709c9be..cb119e193 100644--- a/funasr/models/decoder/rnn_decoder.py+++ b/funasr/models/decoder/rnn_decoder.py@@ -3,7 +3,6 @@ import randomimport numpy as npimport torchimport torch.nn.functional as F-from typeguard import check_argument_typesfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.modules.nets_utils import to_device@@ -97,7 +96,6 @@ class RNNDecoder(AbsDecoder):att_conf: dict = get_default_kwargs(build_attention_list),):# FIXME(kamo): The parts of num_spk should be refactored more more more- assert check_argument_types()if rnn_type not in {"lstm", "gru"}:raise ValueError(f"Not supported: rnn_type={rnn_type}")diff --git a/funasr/models/decoder/rnnt_decoder.py b/funasr/models/decoder/rnnt_decoder.pyindex a0fe9eadc..0109cc500 100644--- a/funasr/models/decoder/rnnt_decoder.py+++ b/funasr/models/decoder/rnnt_decoder.py@@ -3,7 +3,6 @@from typing import List, Optional, Tupleimport torch-from typeguard import check_argument_typesfrom funasr.modules.beam_search.beam_search_transducer import Hypothesisfrom funasr.models.specaug.specaug import SpecAug@@ -38,7 +37,6 @@ class RNNTDecoder(torch.nn.Module):"""Construct a RNNDecoder object."""super().__init__()- assert check_argument_types()if rnn_type not in ("lstm", "gru"):raise ValueError(f"Not supported: rnn_type={rnn_type}")diff --git a/funasr/models/decoder/sanm_decoder.py b/funasr/models/decoder/sanm_decoder.pyindex ed920bfbb..d83f89fa9 100644--- a/funasr/models/decoder/sanm_decoder.py+++ b/funasr/models/decoder/sanm_decoder.py@@ -7,7 +7,6 @@ import numpy as npfrom funasr.modules.streaming_utils import utils as myutilsfrom funasr.models.decoder.transformer_decoder import BaseTransformerDecoder-from typeguard import check_argument_typesfrom funasr.modules.attention import MultiHeadedAttentionSANMDecoder, MultiHeadedAttentionCrossAttfrom funasr.modules.embedding import PositionalEncoding@@ -181,7 +180,6 @@ class FsmnDecoderSCAMAOpt(BaseTransformerDecoder):tf2torch_tensor_name_prefix_tf: str = "seq2seq/decoder",embed_tensor_name_prefix_tf: str = None,):- assert check_argument_types()super().__init__(vocab_size=vocab_size,encoder_output_size=encoder_output_size,@@ -838,7 +836,6 @@ class ParaformerSANMDecoder(BaseTransformerDecoder):tf2torch_tensor_name_prefix_torch: str = "decoder",tf2torch_tensor_name_prefix_tf: str = "seq2seq/decoder",):- assert check_argument_types()super().__init__(vocab_size=vocab_size,encoder_output_size=encoder_output_size,diff --git a/funasr/models/decoder/transformer_decoder.py b/funasr/models/decoder/transformer_decoder.pyindex 45fdda818..0a9c61208 100644--- a/funasr/models/decoder/transformer_decoder.py+++ b/funasr/models/decoder/transformer_decoder.py@@ -9,7 +9,6 @@ from typing import Tupleimport torchfrom torch import nn-from typeguard import check_argument_typesfrom funasr.models.decoder.abs_decoder import AbsDecoderfrom funasr.modules.attention import MultiHeadedAttention@@ -184,7 +183,6 @@ class BaseTransformerDecoder(AbsDecoder, BatchScorerInterface):pos_enc_class=PositionalEncoding,normalize_before: bool = True,):- assert check_argument_types()super().__init__()attention_dim = encoder_output_size@@ -373,7 +371,6 @@ class TransformerDecoder(BaseTransformerDecoder):normalize_before: bool = True,concat_after: bool = False,):- assert check_argument_types()super().__init__(vocab_size=vocab_size,encoder_output_size=encoder_output_size,@@ -428,7 +425,6 @@ class ParaformerDecoderSAN(BaseTransformerDecoder):concat_after: bool = False,embeds_id: int = -1,):- assert check_argument_types()super().__init__(vocab_size=vocab_size,encoder_output_size=encoder_output_size,@@ -540,7 +536,6 @@ class LightweightConvolutionTransformerDecoder(BaseTransformerDecoder):conv_kernel_length: Sequence[int] = (11, 11, 11, 11, 11, 11),conv_usebias: int = False,):- assert check_argument_types()if len(conv_kernel_length) != num_blocks:raise ValueError("conv_kernel_length must have equal number of values to num_blocks: "@@ -602,7 +597,6 @@ class LightweightConvolution2DTransformerDecoder(BaseTransformerDecoder):conv_kernel_length: Sequence[int] = (11, 11, 11, 11, 11, 11),conv_usebias: int = False,):- assert check_argument_types()if len(conv_kernel_length) != num_blocks:raise ValueError("conv_kernel_length must have equal number of values to num_blocks: "@@ -664,7 +658,6 @@ class DynamicConvolutionTransformerDecoder(BaseTransformerDecoder):conv_kernel_length: Sequence[int] = (11, 11, 11, 11, 11, 11),conv_usebias: int = False,):- assert check_argument_types()if len(conv_kernel_length) != num_blocks:raise ValueError("conv_kernel_length must have equal number of values to num_blocks: "@@ -726,7 +719,6 @@ class DynamicConvolution2DTransformerDecoder(BaseTransformerDecoder):conv_kernel_length: Sequence[int] = (11, 11, 11, 11, 11, 11),conv_usebias: int = False,):- assert check_argument_types()if len(conv_kernel_length) != num_blocks:raise ValueError("conv_kernel_length must have equal number of values to num_blocks: "@@ -781,7 +773,6 @@ class BaseSAAsrTransformerDecoder(AbsDecoder, BatchScorerInterface):pos_enc_class=PositionalEncoding,normalize_before: bool = True,):- assert check_argument_types()super().__init__()attention_dim = encoder_output_size@@ -955,7 +946,6 @@ class SAAsrTransformerDecoder(BaseSAAsrTransformerDecoder):normalize_before: bool = True,concat_after: bool = False,):- assert check_argument_types()super().__init__(vocab_size=vocab_size,encoder_output_size=encoder_output_size,diff --git a/funasr/models/e2e_asr.py b/funasr/models/e2e_asr.pyindex e6e6a5204..79c5387ae 100644--- a/funasr/models/e2e_asr.py+++ b/funasr/models/e2e_asr.py@@ -11,7 +11,6 @@ from typing import Tuplefrom typing import Unionimport torch-from typeguard import check_argument_typesfrom funasr.layers.abs_normalize import AbsNormalizefrom funasr.losses.label_smoothing_loss import (@@ -65,7 +64,6 @@ class ASRModel(FunASRModel):preencoder: Optional[AbsPreEncoder] = None,postencoder: Optional[AbsPostEncoder] = None,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weightdiff --git a/funasr/models/e2e_asr_contextual_paraformer.py b/funasr/models/e2e_asr_contextual_paraformer.pyindex cfb500815..4836663c7 100644--- a/funasr/models/e2e_asr_contextual_paraformer.py+++ b/funasr/models/e2e_asr_contextual_paraformer.py@@ -9,7 +9,6 @@ from typing import Unionimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.layers.abs_normalize import AbsNormalizefrom funasr.models.ctc import CTC@@ -73,7 +72,6 @@ class NeatContextualParaformer(Paraformer):preencoder: Optional[AbsPreEncoder] = None,postencoder: Optional[AbsPostEncoder] = None,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weightdiff --git a/funasr/models/e2e_asr_mfcca.py b/funasr/models/e2e_asr_mfcca.pyindex 3927e3825..7dd3b8df6 100644--- a/funasr/models/e2e_asr_mfcca.py+++ b/funasr/models/e2e_asr_mfcca.py@@ -7,7 +7,6 @@ from typing import Tuplefrom typing import Unionimport loggingimport torch-from typeguard import check_argument_typesfrom funasr.modules.e2e_asr_common import ErrorCalculatorfrom funasr.modules.nets_utils import th_accuracy@@ -65,7 +64,6 @@ class MFCCA(FunASRModel):sym_blank: str = "<blank>",preencoder: Optional[AbsPreEncoder] = None,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert rnnt_decoder is None, "Not implemented"diff --git a/funasr/models/e2e_asr_paraformer.py b/funasr/models/e2e_asr_paraformer.pyindex 686038e11..5a1a29be8 100644--- a/funasr/models/e2e_asr_paraformer.py+++ b/funasr/models/e2e_asr_paraformer.py@@ -10,7 +10,6 @@ from typing import Unionimport torchimport randomimport numpy as np-from typeguard import check_argument_typesfrom funasr.layers.abs_normalize import AbsNormalizefrom funasr.losses.label_smoothing_loss import (@@ -80,7 +79,6 @@ class Paraformer(FunASRModel):postencoder: Optional[AbsPostEncoder] = None,use_1st_decoder_loss: bool = False,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weight@@ -645,7 +643,6 @@ class ParaformerOnline(Paraformer):postencoder: Optional[AbsPostEncoder] = None,use_1st_decoder_loss: bool = False,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weight@@ -1255,7 +1252,6 @@ class ParaformerBert(Paraformer):preencoder: Optional[AbsPreEncoder] = None,postencoder: Optional[AbsPostEncoder] = None,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weight@@ -1528,7 +1524,6 @@ class BiCifParaformer(Paraformer):preencoder: Optional[AbsPreEncoder] = None,postencoder: Optional[AbsPostEncoder] = None,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weight@@ -1806,7 +1801,6 @@ class ContextualParaformer(Paraformer):preencoder: Optional[AbsPreEncoder] = None,postencoder: Optional[AbsPostEncoder] = None,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weightdiff --git a/funasr/models/e2e_asr_transducer.py b/funasr/models/e2e_asr_transducer.pyindex 4e33bd656..80914b119 100644--- a/funasr/models/e2e_asr_transducer.py+++ b/funasr/models/e2e_asr_transducer.py@@ -6,7 +6,6 @@ from typing import Dict, List, Optional, Tuple, Unionimport torchfrom packaging.version import parse as V-from typeguard import check_argument_typesfrom funasr.losses.label_smoothing_loss import (LabelSmoothingLoss, # noqa: H301)@@ -86,8 +85,6 @@ class TransducerModel(FunASRModel):"""Construct an ESPnetASRTransducerModel object."""super().__init__()- assert check_argument_types()-# The following labels ID are reserved: 0 (blank) and vocab_size - 1 (sos/eos)self.blank_id = 0self.vocab_size = vocab_size@@ -546,8 +543,6 @@ class UnifiedTransducerModel(FunASRModel):"""Construct an ESPnetASRTransducerModel object."""super().__init__()- assert check_argument_types()-# The following labels ID are reserved: 0 (blank) and vocab_size - 1 (sos/eos)self.blank_id = 0@@ -713,7 +708,7 @@ class UnifiedTransducerModel(FunASRModel):loss_lm = self._calc_lm_loss(decoder_out, target)loss_trans = loss_trans_utt + loss_trans_chunk- loss_ctc = loss_ctc + loss_ctc_chunk+ loss_ctc = loss_ctc + loss_ctc_chunkloss_ctc = loss_att + loss_att_chunkloss = (@@ -1018,4 +1013,4 @@ class UnifiedTransducerModel(FunASRModel):ignore_label=self.ignore_id,)- return loss_att, acc_att+ return loss_att, acc_att\ No newline at end of filediff --git a/funasr/models/e2e_diar_eend_ola.py b/funasr/models/e2e_diar_eend_ola.pyindex da7c6745a..ae3a436e9 100644--- a/funasr/models/e2e_diar_eend_ola.py+++ b/funasr/models/e2e_diar_eend_ola.py@@ -9,7 +9,6 @@ from typing import Tupleimport numpy as npimport torchimport torch.nn as nn-from typeguard import check_argument_typesfrom funasr.models.frontend.wav_frontend import WavFrontendMel23from funasr.modules.eend_ola.encoder import EENDOLATransformerEncoder@@ -48,7 +47,6 @@ class DiarEENDOLAModel(FunASRModel):mapping_dict=None,**kwargs,):- assert check_argument_types()super().__init__()self.frontend = frontenddiff --git a/funasr/models/e2e_diar_sond.py b/funasr/models/e2e_diar_sond.pyindex 9c3fb92bc..bc93b9d9b 100644--- a/funasr/models/e2e_diar_sond.py+++ b/funasr/models/e2e_diar_sond.py@@ -12,7 +12,6 @@ from typing import Tuple, Listimport numpy as npimport torchfrom torch.nn import functional as F-from typeguard import check_argument_typesfrom funasr.modules.nets_utils import to_devicefrom funasr.modules.nets_utils import make_pad_mask@@ -66,7 +65,6 @@ class DiarSondModel(FunASRModel):inter_score_loss_weight: float = 0.0,inputs_type: str = "raw",):- assert check_argument_types()super().__init__()diff --git a/funasr/models/e2e_sa_asr.py b/funasr/models/e2e_sa_asr.pyindex e209d5192..cf1587d17 100644--- a/funasr/models/e2e_sa_asr.py+++ b/funasr/models/e2e_sa_asr.py@@ -12,7 +12,6 @@ from typing import Unionimport torchimport torch.nn.functional as F-from typeguard import check_argument_typesfrom funasr.layers.abs_normalize import AbsNormalizefrom funasr.losses.label_smoothing_loss import (@@ -67,7 +66,6 @@ class SAASRModel(FunASRModel):sym_blank: str = "<blank>",extract_feats_in_collect_stats: bool = True,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weightdiff --git a/funasr/models/e2e_sv.py b/funasr/models/e2e_sv.pyindex bd5178e09..8be63d4a8 100644--- a/funasr/models/e2e_sv.py+++ b/funasr/models/e2e_sv.py@@ -12,7 +12,6 @@ from typing import Tuplefrom typing import Unionimport torch-from typeguard import check_argument_typesfrom funasr.layers.abs_normalize import AbsNormalizefrom funasr.losses.label_smoothing_loss import (@@ -56,7 +55,6 @@ class ESPnetSVModel(FunASRModel):pooling_layer: torch.nn.Module,decoder: AbsDecoder,):- assert check_argument_types()super().__init__()# note that eos is the same as sos (equivalent ID)diff --git a/funasr/models/e2e_tp.py b/funasr/models/e2e_tp.pyindex 33948f91c..567dc70df 100644--- a/funasr/models/e2e_tp.py+++ b/funasr/models/e2e_tp.py@@ -9,7 +9,6 @@ from typing import Unionimport torchimport numpy as np-from typeguard import check_argument_typesfrom funasr.models.encoder.abs_encoder import AbsEncoderfrom funasr.models.frontend.abs_frontend import AbsFrontend@@ -42,7 +41,6 @@ class TimestampPredictor(FunASRModel):predictor_bias: int = 0,token_list=None,):- assert check_argument_types()super().__init__()# note that eos is the same as sos (equivalent ID)diff --git a/funasr/models/e2e_uni_asr.py b/funasr/models/e2e_uni_asr.pyindex 9ec3a39a0..8bc3b4278 100644--- a/funasr/models/e2e_uni_asr.py+++ b/funasr/models/e2e_uni_asr.py@@ -8,7 +8,6 @@ from typing import Tuplefrom typing import Unionimport torch-from typeguard import check_argument_typesfrom funasr.models.e2e_asr_common import ErrorCalculatorfrom funasr.modules.nets_utils import th_accuracy@@ -82,7 +81,6 @@ class UniASR(FunASRModel):postencoder: Optional[AbsPostEncoder] = None,encoder1_encoder2_joint_training: bool = True,):- assert check_argument_types()assert 0.0 <= ctc_weight <= 1.0, ctc_weightassert 0.0 <= interctc_weight < 1.0, interctc_weightdiff --git a/funasr/models/encoder/conformer_encoder.py b/funasr/models/encoder/conformer_encoder.pyindex 994607fb7..e5fac621e 100644--- a/funasr/models/encoder/conformer_encoder.py+++ b/funasr/models/encoder/conformer_encoder.py@@ -12,7 +12,6 @@ from typing import Dictimport torchfrom torch import nn-from typeguard import check_argument_typesfrom funasr.models.ctc import CTCfrom funasr.modules.attention import (@@ -533,7 +532,6 @@ class ConformerEncoder(AbsEncoder):interctc_use_conditioning: bool = False,stochastic_depth_rate: Union[float, List[float]] = 0.0,):- assert check_argument_types()super().__init__()self._output_size = output_size@@ -943,7 +941,6 @@ class ConformerChunkEncoder(AbsEncoder):"""Construct an Encoder object."""super().__init__()- assert check_argument_types()self.embed = StreamingConvInput(input_size,diff --git a/funasr/models/encoder/data2vec_encoder.py b/funasr/models/encoder/data2vec_encoder.pyindex 64c2144f0..8885f02eb 100644--- a/funasr/models/encoder/data2vec_encoder.py+++ b/funasr/models/encoder/data2vec_encoder.py@@ -10,7 +10,6 @@ import torchimport torch.distributed as distimport torch.nn as nnimport torch.nn.functional as F-from typeguard import check_argument_typesfrom funasr.models.encoder.abs_encoder import AbsEncoderfrom funasr.modules.data2vec.data_utils import compute_mask_indices@@ -97,7 +96,6 @@ class Data2VecEncoder(AbsEncoder):# FP16 optimizationrequired_seq_len_multiple: int = 2,):- assert check_argument_types()super().__init__()# ConvFeatureExtractionModeldiff --git a/funasr/models/encoder/mfcca_encoder.py b/funasr/models/encoder/mfcca_encoder.pyindex 95ccf0718..87bb19dd5 100644--- a/funasr/models/encoder/mfcca_encoder.py+++ b/funasr/models/encoder/mfcca_encoder.py@@ -5,7 +5,6 @@ import loggingimport torchfrom torch import nn-from typeguard import check_argument_typesfrom funasr.models.encoder.encoder_layer_mfcca import EncoderLayerfrom funasr.modules.nets_utils import get_activation@@ -161,7 +160,6 @@ class MFCCAEncoder(AbsEncoder):cnn_module_kernel: int = 31,padding_idx: int = -1,):- assert check_argument_types()super().__init__()self._output_size = output_sizediff --git a/funasr/models/encoder/opennmt_encoders/conv_encoder.py b/funasr/models/encoder/opennmt_encoders/conv_encoder.pyindex eec854fe4..9ab5e6b11 100644--- a/funasr/models/encoder/opennmt_encoders/conv_encoder.py+++ b/funasr/models/encoder/opennmt_encoders/conv_encoder.py@@ -7,7 +7,6 @@ import loggingimport torchimport torch.nn as nnfrom torch.nn import functional as F-from typeguard import check_argument_typesimport numpy as npfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.modules.layer_norm import LayerNorm@@ -90,7 +89,6 @@ class ConvEncoder(AbsEncoder):tf2torch_tensor_name_prefix_torch: str = "speaker_encoder",tf2torch_tensor_name_prefix_tf: str = "EAND/speaker_encoder",):- assert check_argument_types()super().__init__()self._output_size = num_unitsdiff --git a/funasr/models/encoder/opennmt_encoders/fsmn_encoder.py b/funasr/models/encoder/opennmt_encoders/fsmn_encoder.pyindex e41b2aac5..5f62e67cc 100644--- a/funasr/models/encoder/opennmt_encoders/fsmn_encoder.py+++ b/funasr/models/encoder/opennmt_encoders/fsmn_encoder.py@@ -7,7 +7,6 @@ import loggingimport torchimport torch.nn as nnfrom torch.nn import functional as F-from typeguard import check_argument_typesimport numpy as npfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.modules.layer_norm import LayerNormdiff --git a/funasr/models/encoder/opennmt_encoders/self_attention_encoder.py b/funasr/models/encoder/opennmt_encoders/self_attention_encoder.pyindex db30f085e..7c83cbd1b 100644--- a/funasr/models/encoder/opennmt_encoders/self_attention_encoder.py+++ b/funasr/models/encoder/opennmt_encoders/self_attention_encoder.py@@ -7,7 +7,6 @@ import loggingimport torchimport torch.nn as nnfrom funasr.modules.streaming_utils.chunk_utilis import overlap_chunk-from typeguard import check_argument_typesimport numpy as npfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.modules.attention import MultiHeadSelfAttention, MultiHeadedAttentionSANM@@ -144,7 +143,6 @@ class SelfAttentionEncoder(AbsEncoder):tf2torch_tensor_name_prefix_tf: str = "seq2seq/encoder",out_units=None,):- assert check_argument_types()super().__init__()self._output_size = output_sizediff --git a/funasr/models/encoder/rnn_encoder.py b/funasr/models/encoder/rnn_encoder.pyindex 59730da35..434af09fa 100644--- a/funasr/models/encoder/rnn_encoder.py+++ b/funasr/models/encoder/rnn_encoder.py@@ -5,7 +5,6 @@ from typing import Tupleimport numpy as npimport torch-from typeguard import check_argument_typesfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.modules.rnn.encoders import RNN@@ -37,7 +36,6 @@ class RNNEncoder(AbsEncoder):dropout: float = 0.0,subsample: Optional[Sequence[int]] = (2, 2, 1, 1),):- assert check_argument_types()super().__init__()self._output_size = output_sizeself.rnn_type = rnn_typediff --git a/funasr/models/encoder/sanm_encoder.py b/funasr/models/encoder/sanm_encoder.pyindex 46eabd1eb..45163df75 100644--- a/funasr/models/encoder/sanm_encoder.py+++ b/funasr/models/encoder/sanm_encoder.py@@ -8,7 +8,6 @@ import torchimport torch.nn as nnimport torch.nn.functional as Ffrom funasr.modules.streaming_utils.chunk_utilis import overlap_chunk-from typeguard import check_argument_typesimport numpy as npfrom funasr.torch_utils.device_funcs import to_devicefrom funasr.modules.nets_utils import make_pad_mask@@ -151,7 +150,6 @@ class SANMEncoder(AbsEncoder):tf2torch_tensor_name_prefix_torch: str = "encoder",tf2torch_tensor_name_prefix_tf: str = "seq2seq/encoder",):- assert check_argument_types()super().__init__()self._output_size = output_size@@ -601,7 +599,6 @@ class SANMEncoderChunkOpt(AbsEncoder):tf2torch_tensor_name_prefix_torch: str = "encoder",tf2torch_tensor_name_prefix_tf: str = "seq2seq/encoder",):- assert check_argument_types()super().__init__()self._output_size = output_size@@ -1060,7 +1057,6 @@ class SANMVadEncoder(AbsEncoder):sanm_shfit : int = 0,selfattention_layer_type: str = "sanm",):- assert check_argument_types()super().__init__()self._output_size = output_sizediff --git a/funasr/models/encoder/transformer_encoder.py b/funasr/models/encoder/transformer_encoder.pyindex ff9c3db51..4f2bef570 100644--- a/funasr/models/encoder/transformer_encoder.py+++ b/funasr/models/encoder/transformer_encoder.py@@ -9,7 +9,6 @@ from typing import Tupleimport torchfrom torch import nn-from typeguard import check_argument_typesimport loggingfrom funasr.models.ctc import CTC@@ -189,7 +188,6 @@ class TransformerEncoder(AbsEncoder):interctc_layer_idx: List[int] = [],interctc_use_conditioning: bool = False,):- assert check_argument_types()super().__init__()self._output_size = output_sizediff --git a/funasr/models/frontend/default.py b/funasr/models/frontend/default.pyindex abbcd1b05..b41af8084 100644--- a/funasr/models/frontend/default.py+++ b/funasr/models/frontend/default.py@@ -7,7 +7,6 @@ import humanfriendlyimport numpy as npimport torchfrom torch_complex.tensor import ComplexTensor-from typeguard import check_argument_typesfrom funasr.layers.log_mel import LogMelfrom funasr.layers.stft import Stft@@ -40,7 +39,6 @@ class DefaultFrontend(AbsFrontend):apply_stft: bool = True,use_channel: int = None,):- assert check_argument_types()super().__init__()if isinstance(fs, str):fs = humanfriendly.parse_size(fs)@@ -167,7 +165,6 @@ class MultiChannelFrontend(AbsFrontend):cmvn_file: str = None,mc: bool = True):- assert check_argument_types()super().__init__()if isinstance(fs, str):fs = humanfriendly.parse_size(fs)diff --git a/funasr/models/frontend/fused.py b/funasr/models/frontend/fused.pyindex 857486d12..ff9587196 100644--- a/funasr/models/frontend/fused.py+++ b/funasr/models/frontend/fused.py@@ -3,7 +3,6 @@ from funasr.models.frontend.default import DefaultFrontendfrom funasr.models.frontend.s3prl import S3prlFrontendimport numpy as npimport torch-from typeguard import check_argument_typesfrom typing import Tuple@@ -12,7 +11,6 @@ class FusedFrontends(AbsFrontend):self, frontends=None, align_method="linear_projection", proj_dim=100, fs=16000):- assert check_argument_types()super().__init__()self.align_method = (align_method # fusing method : linear_projection only for nowdiff --git a/funasr/models/frontend/s3prl.py b/funasr/models/frontend/s3prl.pyindex b03d2c98a..fdeb1c576 100644--- a/funasr/models/frontend/s3prl.py+++ b/funasr/models/frontend/s3prl.py@@ -8,7 +8,6 @@ from typing import Unionimport humanfriendlyimport torch-from typeguard import check_argument_typesfrom funasr.models.frontend.abs_frontend import AbsFrontendfrom funasr.modules.frontends.frontend import Frontend@@ -37,7 +36,6 @@ class S3prlFrontend(AbsFrontend):download_dir: str = None,multilayer_feature: bool = False,):- assert check_argument_types()super().__init__()if isinstance(fs, str):fs = humanfriendly.parse_size(fs)diff --git a/funasr/models/frontend/wav_frontend.py b/funasr/models/frontend/wav_frontend.pyindex f16bdd9de..acab13b8f 100644--- a/funasr/models/frontend/wav_frontend.py+++ b/funasr/models/frontend/wav_frontend.py@@ -6,7 +6,6 @@ import numpy as npimport torchimport torchaudio.compliance.kaldi as kaldifrom torch.nn.utils.rnn import pad_sequence-from typeguard import check_argument_typesimport funasr.models.frontend.eend_ola_feature as eend_ola_featurefrom funasr.models.frontend.abs_frontend import AbsFrontend@@ -95,7 +94,6 @@ class WavFrontend(AbsFrontend):snip_edges: bool = True,upsacle_samples: bool = True,):- assert check_argument_types()super().__init__()self.fs = fsself.window = window@@ -227,7 +225,6 @@ class WavFrontendOnline(AbsFrontend):snip_edges: bool = True,upsacle_samples: bool = True,):- assert check_argument_types()super().__init__()self.fs = fsself.window = window@@ -466,7 +463,6 @@ class WavFrontendMel23(AbsFrontend):lfr_m: int = 1,lfr_n: int = 1,):- assert check_argument_types()super().__init__()self.fs = fsself.frame_length = frame_lengthdiff --git a/funasr/models/frontend/windowing.py b/funasr/models/frontend/windowing.pyindex a5267583d..94c9d271e 100644--- a/funasr/models/frontend/windowing.py+++ b/funasr/models/frontend/windowing.py@@ -6,7 +6,6 @@from funasr.models.frontend.abs_frontend import AbsFrontendimport torch-from typeguard import check_argument_typesfrom typing import Tuple@@ -38,7 +37,6 @@ class SlidingWindow(AbsFrontend):padding: Padding (placeholder, currently not implemented).fs: Sampling rate (placeholder for compatibility, not used)."""- assert check_argument_types()super().__init__()self.fs = fsself.win_length = win_lengthdiff --git a/funasr/models/postencoder/hugging_face_transformers_postencoder.py b/funasr/models/postencoder/hugging_face_transformers_postencoder.pyindex 1aad15d79..c59e2b779 100644--- a/funasr/models/postencoder/hugging_face_transformers_postencoder.py+++ b/funasr/models/postencoder/hugging_face_transformers_postencoder.py@@ -6,7 +6,6 @@from funasr.modules.nets_utils import make_pad_maskfrom funasr.models.postencoder.abs_postencoder import AbsPostEncoder-from typeguard import check_argument_typesfrom typing import Tupleimport copy@@ -30,7 +29,6 @@ class HuggingFaceTransformersPostEncoder(AbsPostEncoder):model_name_or_path: str,):"""Initialize the module."""- assert check_argument_types()super().__init__()if not is_transformers_available:diff --git a/funasr/models/preencoder/linear.py b/funasr/models/preencoder/linear.pyindex c69b6ce92..25f6720b1 100644--- a/funasr/models/preencoder/linear.py+++ b/funasr/models/preencoder/linear.py@@ -5,7 +5,6 @@"""Linear Projection."""from funasr.models.preencoder.abs_preencoder import AbsPreEncoder-from typeguard import check_argument_typesfrom typing import Tupleimport torch@@ -20,7 +19,6 @@ class LinearProjection(AbsPreEncoder):output_size: int,):"""Initialize the module."""- assert check_argument_types()super().__init__()self.output_dim = output_sizediff --git a/funasr/models/preencoder/sinc.py b/funasr/models/preencoder/sinc.pyindex fe6d2af1b..3baa4a872 100644--- a/funasr/models/preencoder/sinc.py+++ b/funasr/models/preencoder/sinc.py@@ -10,7 +10,6 @@ from funasr.layers.sinc_conv import LogCompressionfrom funasr.layers.sinc_conv import SincConvimport humanfriendlyimport torch-from typeguard import check_argument_typesfrom typing import Optionalfrom typing import Tuplefrom typing import Union@@ -60,7 +59,6 @@ class LightweightSincConvs(AbsPreEncoder):windowing_type: Choice of windowing function.scale_type: Choice of filter-bank initialization scale."""- assert check_argument_types()super().__init__()if isinstance(fs, str):fs = humanfriendly.parse_size(fs)@@ -268,7 +266,6 @@ class SpatialDropout(torch.nn.Module):dropout_probability: Dropout probability.shape (tuple, list): Shape of input tensors."""- assert check_argument_types()super().__init__()if shape is None:shape = (0, 2, 1)diff --git a/funasr/models/seq_rnn_lm.py b/funasr/models/seq_rnn_lm.pyindex f7ddcae60..bef497477 100644--- a/funasr/models/seq_rnn_lm.py+++ b/funasr/models/seq_rnn_lm.py@@ -4,7 +4,6 @@ from typing import Unionimport torchimport torch.nn as nn-from typeguard import check_argument_typesfrom funasr.train.abs_model import AbsLM@@ -27,7 +26,6 @@ class SequentialRNNLM(AbsLM):rnn_type: str = "lstm",ignore_id: int = 0,):- assert check_argument_types()super().__init__()ninp = unitdiff --git a/funasr/modules/eend_ola/utils/report.py b/funasr/modules/eend_ola/utils/report.pyindex bfccedfe0..f4a044bc0 100644--- a/funasr/modules/eend_ola/utils/report.py+++ b/funasr/modules/eend_ola/utils/report.py@@ -2,7 +2,7 @@ import copyimport numpy as npimport timeimport torch-from eend.utils.power import create_powerlabel+from funasr.modules.eend_ola.utils.power import create_powerlabelfrom itertools import combinationsmetrics = [diff --git a/funasr/optimizers/sgd.py b/funasr/optimizers/sgd.pyindex 3f0d3d1c9..fb7a3df01 100644--- a/funasr/optimizers/sgd.py+++ b/funasr/optimizers/sgd.py@@ -1,5 +1,4 @@import torch-from typeguard import check_argument_typesclass SGD(torch.optim.SGD):@@ -21,7 +20,6 @@ class SGD(torch.optim.SGD):weight_decay: float = 0.0,nesterov: bool = False,):- assert check_argument_types()super().__init__(params,lr=lr,diff --git a/funasr/runtime/python/libtorch/funasr_torch/utils/frontend.py b/funasr/runtime/python/libtorch/funasr_torch/utils/frontend.pyindex 11a86445d..fe399551a 100644--- a/funasr/runtime/python/libtorch/funasr_torch/utils/frontend.py+++ b/funasr/runtime/python/libtorch/funasr_torch/utils/frontend.py@@ -3,7 +3,6 @@ from pathlib import Pathfrom typing import Any, Dict, Iterable, List, NamedTuple, Set, Tuple, Unionimport numpy as np-from typeguard import check_argument_typesimport kaldi_native_fbank as knfroot_dir = Path(__file__).resolve().parent@@ -28,7 +27,6 @@ class WavFrontend():dither: float = 1.0,**kwargs,) -> None:- check_argument_types()opts = knf.FbankOptions()opts.frame_opts.samp_freq = fsdiff --git a/funasr/runtime/python/libtorch/funasr_torch/utils/utils.py b/funasr/runtime/python/libtorch/funasr_torch/utils/utils.pyindex 86e78bc4a..913ddc1e4 100644--- a/funasr/runtime/python/libtorch/funasr_torch/utils/utils.py+++ b/funasr/runtime/python/libtorch/funasr_torch/utils/utils.py@@ -9,7 +9,6 @@ from typing import Any, Dict, Iterable, List, NamedTuple, Set, Tuple, Unionimport numpy as npimport yaml-from typeguard import check_argument_typesimport warnings@@ -21,7 +20,6 @@ logger_initialized = {}class TokenIDConverter():def __init__(self, token_list: Union[List, str],):- check_argument_types()self.token_list = token_listself.unk_symbol = token_list[-1]@@ -51,7 +49,6 @@ class CharTokenizer():space_symbol: str = "<space>",remove_non_linguistic_symbols: bool = False,):- check_argument_types()self.space_symbol = space_symbolself.non_linguistic_symbols = self.load_symbols(symbol_value)diff --git a/funasr/runtime/python/onnxruntime/funasr_onnx/utils/frontend.py b/funasr/runtime/python/onnxruntime/funasr_onnx/utils/frontend.pyindex 5478236db..ded04b6e4 100644--- a/funasr/runtime/python/onnxruntime/funasr_onnx/utils/frontend.py+++ b/funasr/runtime/python/onnxruntime/funasr_onnx/utils/frontend.py@@ -4,7 +4,6 @@ from typing import Any, Dict, Iterable, List, NamedTuple, Set, Tuple, Unionimport copyimport numpy as np-from typeguard import check_argument_typesimport kaldi_native_fbank as knfroot_dir = Path(__file__).resolve().parent@@ -29,7 +28,6 @@ class WavFrontend():dither: float = 1.0,**kwargs,) -> None:- check_argument_types()opts = knf.FbankOptions()opts.frame_opts.samp_freq = fsdiff --git a/funasr/runtime/python/onnxruntime/funasr_onnx/utils/utils.py b/funasr/runtime/python/onnxruntime/funasr_onnx/utils/utils.pyindex dcee42500..9284943bd 100644--- a/funasr/runtime/python/onnxruntime/funasr_onnx/utils/utils.py+++ b/funasr/runtime/python/onnxruntime/funasr_onnx/utils/utils.py@@ -10,7 +10,6 @@ import numpy as npimport yamlfrom onnxruntime import (GraphOptimizationLevel, InferenceSession,SessionOptions, get_available_providers, get_device)-from typeguard import check_argument_typesimport warnings@@ -22,7 +21,6 @@ logger_initialized = {}class TokenIDConverter():def __init__(self, token_list: Union[List, str],):- check_argument_types()self.token_list = token_listself.unk_symbol = token_list[-1]@@ -52,7 +50,6 @@ class CharTokenizer():space_symbol: str = "<space>",remove_non_linguistic_symbols: bool = False,):- check_argument_types()self.space_symbol = space_symbolself.non_linguistic_symbols = self.load_symbols(symbol_value)diff --git a/funasr/runtime/triton_gpu/model_repo_paraformer_large_offline/feature_extractor/1/model.py b/funasr/runtime/triton_gpu/model_repo_paraformer_large_offline/feature_extractor/1/model.pyindex 2f84bb8fc..c556dafc5 100644--- a/funasr/runtime/triton_gpu/model_repo_paraformer_large_offline/feature_extractor/1/model.py+++ b/funasr/runtime/triton_gpu/model_repo_paraformer_large_offline/feature_extractor/1/model.py@@ -109,7 +109,6 @@ class WavFrontend():lfr_n: int = 6,dither: float = 1.0) -> None:- # check_argument_types()self.fs = fsself.window = windowdiff --git a/funasr/samplers/build_batch_sampler.py b/funasr/samplers/build_batch_sampler.pyindex 074b446d7..9266fea7c 100644--- a/funasr/samplers/build_batch_sampler.py+++ b/funasr/samplers/build_batch_sampler.py@@ -4,8 +4,6 @@ from typing import Sequencefrom typing import Tuplefrom typing import Union-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.samplers.abs_sampler import AbsSamplerfrom funasr.samplers.folded_batch_sampler import FoldedBatchSampler@@ -104,7 +102,6 @@ def build_batch_sampler(padding: Whether sequences are input as a padded tensor or not.used for "numel" mode"""- assert check_argument_types()if len(shape_files) == 0:raise ValueError("No shape file are given")@@ -164,5 +161,4 @@ def build_batch_sampler(else:raise ValueError(f"Not supported: {type}")- assert check_return_type(retval)return retvaldiff --git a/funasr/samplers/folded_batch_sampler.py b/funasr/samplers/folded_batch_sampler.pyindex 48e960454..f48d74480 100644--- a/funasr/samplers/folded_batch_sampler.py+++ b/funasr/samplers/folded_batch_sampler.py@@ -4,7 +4,6 @@ from typing import Sequencefrom typing import Tuplefrom typing import Union-from typeguard import check_argument_typesfrom funasr.fileio.read_text import load_num_sequence_textfrom funasr.fileio.read_text import read_2column_text@@ -23,7 +22,6 @@ class FoldedBatchSampler(AbsSampler):drop_last: bool = False,utt2category_file: str = None,):- assert check_argument_types()assert batch_size > 0if sort_batch != "ascending" and sort_batch != "descending":raise ValueError(diff --git a/funasr/samplers/length_batch_sampler.py b/funasr/samplers/length_batch_sampler.pyindex 8ee8bdc52..28404e32c 100644--- a/funasr/samplers/length_batch_sampler.py+++ b/funasr/samplers/length_batch_sampler.py@@ -4,7 +4,6 @@ from typing import Dictfrom typing import Tuplefrom typing import Union-from typeguard import check_argument_typesfrom funasr.fileio.read_text import load_num_sequence_textfrom funasr.samplers.abs_sampler import AbsSampler@@ -21,7 +20,6 @@ class LengthBatchSampler(AbsSampler):drop_last: bool = False,padding: bool = True,):- assert check_argument_types()assert batch_bins > 0if sort_batch != "ascending" and sort_batch != "descending":raise ValueError(diff --git a/funasr/samplers/num_elements_batch_sampler.py b/funasr/samplers/num_elements_batch_sampler.pyindex 0ffad9289..ebed0e415 100644--- a/funasr/samplers/num_elements_batch_sampler.py+++ b/funasr/samplers/num_elements_batch_sampler.py@@ -4,7 +4,6 @@ from typing import Tuplefrom typing import Unionimport numpy as np-from typeguard import check_argument_typesfrom funasr.fileio.read_text import load_num_sequence_textfrom funasr.samplers.abs_sampler import AbsSampler@@ -21,7 +20,6 @@ class NumElementsBatchSampler(AbsSampler):drop_last: bool = False,padding: bool = True,):- assert check_argument_types()assert batch_bins > 0if sort_batch != "ascending" and sort_batch != "descending":raise ValueError(diff --git a/funasr/samplers/sorted_batch_sampler.py b/funasr/samplers/sorted_batch_sampler.pyindex d6c3b4111..b31e93ecf 100644--- a/funasr/samplers/sorted_batch_sampler.py+++ b/funasr/samplers/sorted_batch_sampler.py@@ -2,7 +2,6 @@ import loggingfrom typing import Iteratorfrom typing import Tuple-from typeguard import check_argument_typesfrom funasr.fileio.read_text import load_num_sequence_textfrom funasr.samplers.abs_sampler import AbsSampler@@ -26,7 +25,6 @@ class SortedBatchSampler(AbsSampler):sort_batch: str = "ascending",drop_last: bool = False,):- assert check_argument_types()assert batch_size > 0self.batch_size = batch_sizeself.shape_file = shape_filediff --git a/funasr/samplers/unsorted_batch_sampler.py b/funasr/samplers/unsorted_batch_sampler.pyindex 349e526c7..e5ed05bdc 100644--- a/funasr/samplers/unsorted_batch_sampler.py+++ b/funasr/samplers/unsorted_batch_sampler.py@@ -2,7 +2,6 @@ import loggingfrom typing import Iteratorfrom typing import Tuple-from typeguard import check_argument_typesfrom funasr.fileio.read_text import read_2column_textfrom funasr.samplers.abs_sampler import AbsSampler@@ -28,7 +27,6 @@ class UnsortedBatchSampler(AbsSampler):drop_last: bool = False,utt2category_file: str = None,):- assert check_argument_types()assert batch_size > 0self.batch_size = batch_sizeself.key_file = key_filediff --git a/funasr/schedulers/noam_lr.py b/funasr/schedulers/noam_lr.pyindex 80df019ac..e08fb635e 100644--- a/funasr/schedulers/noam_lr.py+++ b/funasr/schedulers/noam_lr.py@@ -4,7 +4,6 @@ import warningsimport torchfrom torch.optim.lr_scheduler import _LRScheduler-from typeguard import check_argument_typesfrom funasr.schedulers.abs_scheduler import AbsBatchStepScheduler@@ -31,7 +30,6 @@ class NoamLR(_LRScheduler, AbsBatchStepScheduler):warmup_steps: Union[int, float] = 25000,last_epoch: int = -1,):- assert check_argument_types()self.model_size = model_sizeself.warmup_steps = warmup_stepsdiff --git a/funasr/schedulers/tri_stage_scheduler.py b/funasr/schedulers/tri_stage_scheduler.pyindex 8dc71b438..c442260c4 100644--- a/funasr/schedulers/tri_stage_scheduler.py+++ b/funasr/schedulers/tri_stage_scheduler.py@@ -8,7 +8,6 @@ from typing import Optional, Listimport torchfrom torch.optim.lr_scheduler import _LRScheduler-from typeguard import check_argument_typesfrom funasr.schedulers.abs_scheduler import AbsBatchStepScheduler@@ -22,7 +21,6 @@ class TriStageLR(_LRScheduler, AbsBatchStepScheduler):init_lr_scale: float = 0.01,final_lr_scale: float = 0.01,):- assert check_argument_types()self.optimizer = optimizerself.last_epoch = last_epochself.phase_ratio = phase_ratiodiff --git a/funasr/schedulers/warmup_lr.py b/funasr/schedulers/warmup_lr.pyindex dbf3aca53..95ebacaff 100644--- a/funasr/schedulers/warmup_lr.py+++ b/funasr/schedulers/warmup_lr.py@@ -3,7 +3,6 @@ from typing import Unionimport torchfrom torch.optim.lr_scheduler import _LRScheduler-from typeguard import check_argument_typesfrom funasr.schedulers.abs_scheduler import AbsBatchStepScheduler@@ -30,7 +29,6 @@ class WarmupLR(_LRScheduler, AbsBatchStepScheduler):warmup_steps: Union[int, float] = 25000,last_epoch: int = -1,):- assert check_argument_types()self.warmup_steps = warmup_steps# __init__() must be invoked before setting fielddiff --git a/funasr/tasks/abs_task.py b/funasr/tasks/abs_task.pyindex 0fb77a93e..91d33c5e3 100644--- a/funasr/tasks/abs_task.py+++ b/funasr/tasks/abs_task.py@@ -32,8 +32,6 @@ import torch.optimimport yamlfrom funasr.models.base_model import FunASRModelfrom torch.utils.data import DataLoader-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr import __version__from funasr.datasets.dataset import AbsDataset@@ -269,7 +267,6 @@ class AbsTask(ABC):@classmethoddef get_parser(cls) -> config_argparse.ArgumentParser:- assert check_argument_types()class ArgumentDefaultsRawTextHelpFormatter(argparse.RawTextHelpFormatter,@@ -959,7 +956,6 @@ class AbsTask(ABC):cls.trainer.add_arguments(parser)cls.add_task_arguments(parser)- assert check_return_type(parser)return parser@classmethod@@ -1007,7 +1003,6 @@ class AbsTask(ABC):return _cls# This method is used only for --print_config- assert check_argument_types()parser = cls.get_parser()args, _ = parser.parse_known_args()config = vars(args)@@ -1047,7 +1042,6 @@ class AbsTask(ABC):@classmethoddef check_required_command_args(cls, args: argparse.Namespace):- assert check_argument_types()if hasattr(args, "required"):for k in vars(args):if "-" in k:@@ -1077,7 +1071,6 @@ class AbsTask(ABC):inference: bool = False,) -> None:"""Check if the dataset satisfy the requirement of current Task"""- assert check_argument_types()mes = (f"If you intend to use an additional input, modify "f'"{cls.__name__}.required_data_names()" or '@@ -1104,14 +1097,12 @@ class AbsTask(ABC):@classmethoddef print_config(cls, file=sys.stdout) -> None:- assert check_argument_types()# Shows the config: e.g. python train.py asr --print_configconfig = cls.get_default_config()file.write(yaml_no_alias_safe_dump(config, indent=4, sort_keys=False))@classmethoddef main(cls, args: argparse.Namespace = None, cmd: Sequence[str] = None):- assert check_argument_types()print(get_commandline_args(), file=sys.stderr)if args is None:parser = cls.get_parser()@@ -1148,7 +1139,6 @@ class AbsTask(ABC):@classmethoddef main_worker(cls, args: argparse.Namespace):- assert check_argument_types()# 0. Init distributed processdistributed_option = build_dataclass(DistributedOption, args)@@ -1556,7 +1546,6 @@ class AbsTask(ABC):- 4 epoch with "--num_iters_per_epoch" == 4"""- assert check_argument_types()iter_options = cls.build_iter_options(args, distributed_option, mode)# Overwrite iter_options if any kwargs is given@@ -1589,7 +1578,6 @@ class AbsTask(ABC):def build_sequence_iter_factory(cls, args: argparse.Namespace, iter_options: IteratorOptions, mode: str) -> AbsIterFactory:- assert check_argument_types()if hasattr(args, "frontend_conf"):if args.frontend_conf is not None and "fs" in args.frontend_conf:@@ -1683,7 +1671,6 @@ class AbsTask(ABC):iter_options: IteratorOptions,mode: str,) -> AbsIterFactory:- assert check_argument_types()dataset = ESPnetDataset(iter_options.data_path_and_name_and_type,@@ -1788,7 +1775,6 @@ class AbsTask(ABC):def build_multiple_iter_factory(cls, args: argparse.Namespace, distributed_option: DistributedOption, mode: str):- assert check_argument_types()iter_options = cls.build_iter_options(args, distributed_option, mode)assert len(iter_options.data_path_and_name_and_type) > 0, len(iter_options.data_path_and_name_and_type@@ -1885,7 +1871,6 @@ class AbsTask(ABC):inference: bool = False,) -> DataLoader:"""Build DataLoader using iterable dataset"""- assert check_argument_types()# For backward compatibility for pytorch DataLoaderif collate_fn is not None:kwargs = dict(collate_fn=collate_fn)@@ -1935,7 +1920,6 @@ class AbsTask(ABC):device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "diff --git a/funasr/tasks/asr.py b/funasr/tasks/asr.pyindex 7338513cb..4b94aeb94 100644--- a/funasr/tasks/asr.py+++ b/funasr/tasks/asr.py@@ -13,8 +13,6 @@ from typing import Unionimport numpy as npimport torchimport yaml-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.datasets.preprocessor import CommonPreprocessor@@ -491,7 +489,6 @@ class ASRTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()# NOTE(kamo): int value = 0 is reserved by CTC-blank symbolreturn CommonCollateFn(float_pad_value=0.0, int_pad_value=-1)@@ -499,7 +496,6 @@ class ASRTask(AbsTask):def build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()if args.use_preprocessor:retval = CommonPreprocessor(train=train,@@ -529,7 +525,6 @@ class ASRTask(AbsTask):)else:retval = None- assert check_return_type(retval)return retval@classmethod@@ -548,12 +543,10 @@ class ASRTask(AbsTask):cls, train: bool = True, inference: bool = False) -> Tuple[str, ...]:retval = ()- assert check_return_type(retval)return retval@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -658,7 +651,6 @@ class ASRTask(AbsTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model@@ -701,7 +693,6 @@ class ASRTaskUniASR(ASRTask):@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -838,7 +829,6 @@ class ASRTaskUniASR(ASRTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model# ~~~~~~~~~ The methods below are mainly used for inference ~~~~~~~~~@@ -860,7 +850,6 @@ class ASRTaskUniASR(ASRTask):device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "@@ -975,7 +964,6 @@ class ASRTaskParaformer(ASRTask):@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -1085,7 +1073,6 @@ class ASRTaskParaformer(ASRTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model# ~~~~~~~~~ The methods below are mainly used for inference ~~~~~~~~~@@ -1107,7 +1094,6 @@ class ASRTaskParaformer(ASRTask):device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "@@ -1210,7 +1196,6 @@ class ASRTaskMFCCA(ASRTask):@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -1308,7 +1293,6 @@ class ASRTaskMFCCA(ASRTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model@@ -1333,7 +1317,6 @@ class ASRTaskAligner(ASRTaskParaformer):@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -1388,7 +1371,6 @@ class ASRTaskAligner(ASRTaskParaformer):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model@classmethod@@ -1425,7 +1407,6 @@ class ASRTransducerTask(ASRTask):Return:model: ASR Transducer model."""- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:@@ -1524,7 +1505,6 @@ class ASRTransducerTask(ASRTask):"Initialization part will be reworked in a short future.",)- #assert check_return_type(model)return model@@ -1559,7 +1539,6 @@ class ASRTaskSAASR(ASRTask):@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -1645,5 +1624,4 @@ class ASRTaskSAASR(ASRTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return modeldiff --git a/funasr/tasks/data2vec.py b/funasr/tasks/data2vec.pyindex 9a64e1f58..b11d7de21 100644--- a/funasr/tasks/data2vec.py+++ b/funasr/tasks/data2vec.py@@ -8,8 +8,6 @@ from typing import Tupleimport numpy as npimport torch-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.datasets.preprocessor import CommonPreprocessor@@ -256,14 +254,12 @@ class Data2VecTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()return CommonCollateFn(clipping=True)@classmethoddef build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()if args.use_preprocessor:retval = CommonPreprocessor(train=train,@@ -289,7 +285,6 @@ class Data2VecTask(AbsTask):)else:retval = None- assert check_return_type(retval)return retval@classmethod@@ -305,12 +300,10 @@ class Data2VecTask(AbsTask):cls, train: bool = True, inference: bool = False) -> Tuple[str, ...]:retval = ()- assert check_return_type(retval)return retval@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()# 1. frontendif args.input_size is None:@@ -372,5 +365,4 @@ class Data2VecTask(AbsTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return modeldiff --git a/funasr/tasks/diar.py b/funasr/tasks/diar.pyindex 2625fec18..a486a46ea 100644--- a/funasr/tasks/diar.py+++ b/funasr/tasks/diar.py@@ -21,8 +21,6 @@ from typing import Unionimport numpy as npimport torchimport yaml-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.datasets.preprocessor import CommonPreprocessor@@ -344,7 +342,6 @@ class DiarTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()# NOTE(kamo): int value = 0 is reserved by CTC-blank symbolreturn CommonCollateFn(float_pad_value=0.0, int_pad_value=-1)@@ -352,7 +349,6 @@ class DiarTask(AbsTask):def build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()if args.use_preprocessor:retval = CommonPreprocessor(train=train,@@ -382,7 +378,6 @@ class DiarTask(AbsTask):)else:retval = None- assert check_return_type(retval)return retval@classmethod@@ -401,12 +396,10 @@ class DiarTask(AbsTask):cls, train: bool = True, inference: bool = False) -> Tuple[str, ...]:retval = ()- assert check_return_type(retval)return retval@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -505,7 +498,6 @@ class DiarTask(AbsTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model# ~~~~~~~~~ The methods below are mainly used for inference ~~~~~~~~~@@ -528,7 +520,6 @@ class DiarTask(AbsTask):device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "@@ -764,7 +755,6 @@ class EENDOLADiarTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()# NOTE(kamo): int value = 0 is reserved by CTC-blank symbolreturn CommonCollateFn(float_pad_value=0.0, int_pad_value=-1)@@ -772,7 +762,6 @@ class EENDOLADiarTask(AbsTask):def build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()# if args.use_preprocessor:# retval = CommonPreprocessor(# train=train,@@ -802,7 +791,6 @@ class EENDOLADiarTask(AbsTask):# )# else:# retval = None- # assert check_return_type(retval)return None@classmethod@@ -821,12 +809,10 @@ class EENDOLADiarTask(AbsTask):cls, train: bool = True, inference: bool = False) -> Tuple[str, ...]:retval = ()- assert check_return_type(retval)return retval@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()# 1. frontendif args.input_size is None or args.frontend == "wav_frontend_mel23":@@ -865,7 +851,6 @@ class EENDOLADiarTask(AbsTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model# ~~~~~~~~~ The methods below are mainly used for inference ~~~~~~~~~@@ -888,7 +873,6 @@ class EENDOLADiarTask(AbsTask):device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "diff --git a/funasr/tasks/lm.py b/funasr/tasks/lm.pyindex 44fdf8ee4..c0259a812 100644--- a/funasr/tasks/lm.py+++ b/funasr/tasks/lm.py@@ -9,8 +9,6 @@ from typing import Tupleimport numpy as npimport torch-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.datasets.preprocessor import CommonPreprocessor@@ -52,7 +50,6 @@ class LMTask(AbsTask):@classmethoddef add_task_arguments(cls, parser: argparse.ArgumentParser):# NOTE(kamo): Use '_' instead of '-' to avoid confusion- assert check_argument_types()group = parser.add_argument_group(description="Task related")# NOTE(kamo): add_arguments(..., required=True) can't be used@@ -130,7 +127,6 @@ class LMTask(AbsTask):for class_choices in cls.class_choices_list:class_choices.add_arguments(group)- assert check_return_type(parser)return parser@classmethod@@ -140,14 +136,12 @@ class LMTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()return CommonCollateFn(int_pad_value=0)@classmethoddef build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()if args.use_preprocessor:retval = CommonPreprocessor(train=train,@@ -160,7 +154,6 @@ class LMTask(AbsTask):)else:retval = None- assert check_return_type(retval)return retval@classmethod@@ -179,7 +172,6 @@ class LMTask(AbsTask):@classmethoddef build_model(cls, args: argparse.Namespace) -> LanguageModel:- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]diff --git a/funasr/tasks/punctuation.py b/funasr/tasks/punctuation.pyindex a63bbe452..de5c89766 100644--- a/funasr/tasks/punctuation.py+++ b/funasr/tasks/punctuation.py@@ -9,8 +9,6 @@ from typing import Tupleimport numpy as npimport torch-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.datasets.preprocessor import PuncTrainTokenizerCommonPreprocessor@@ -47,7 +45,6 @@ class PunctuationTask(AbsTask):@classmethoddef add_task_arguments(cls, parser: argparse.ArgumentParser):# NOTE(kamo): Use '_' instead of '-' to avoid confusion- assert check_argument_types()group = parser.add_argument_group(description="Task related")# NOTE(kamo): add_arguments(..., required=True) can't be used@@ -126,7 +123,6 @@ class PunctuationTask(AbsTask):# e.g. --encoder and --encoder_confclass_choices.add_arguments(group)- assert check_return_type(parser)return parser@classmethod@@ -136,14 +132,12 @@ class PunctuationTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()return CommonCollateFn(int_pad_value=0)@classmethoddef build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()token_types = [args.token_type, args.token_type]token_lists = [args.token_list, args.punc_list]bpemodels = [args.bpemodel, args.bpemodel]@@ -161,7 +155,6 @@ class PunctuationTask(AbsTask):)else:retval = None- assert check_return_type(retval)return retval@classmethod@@ -182,7 +175,6 @@ class PunctuationTask(AbsTask):@classmethoddef build_model(cls, args: argparse.Namespace) -> PunctuationModel:- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -223,5 +215,4 @@ class PunctuationTask(AbsTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return modeldiff --git a/funasr/tasks/sa_asr.py b/funasr/tasks/sa_asr.pyindex 957948336..e7ee5a3f5 100644--- a/funasr/tasks/sa_asr.py+++ b/funasr/tasks/sa_asr.py@@ -13,8 +13,6 @@ from typing import Unionimport numpy as npimport torchimport yaml-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.datasets.preprocessor import CommonPreprocessor@@ -445,7 +443,6 @@ class ASRTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()# NOTE(kamo): int value = 0 is reserved by CTC-blank symbolreturn CommonCollateFn(float_pad_value=0.0, int_pad_value=-1)@@ -453,7 +450,6 @@ class ASRTask(AbsTask):def build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()if args.use_preprocessor:retval = CommonPreprocessor(train=train,@@ -483,7 +479,6 @@ class ASRTask(AbsTask):)else:retval = None- assert check_return_type(retval)return retval@classmethod@@ -502,12 +497,10 @@ class ASRTask(AbsTask):cls, train: bool = True, inference: bool = False) -> Tuple[str, ...]:retval = ()- assert check_return_type(retval)return retval@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -619,5 +612,4 @@ class ASRTask(AbsTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model\ No newline at end of filediff --git a/funasr/tasks/sv.py b/funasr/tasks/sv.pyindex e4815da31..e69852251 100644--- a/funasr/tasks/sv.py+++ b/funasr/tasks/sv.py@@ -17,8 +17,6 @@ from typing import Unionimport numpy as npimport torchimport yaml-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.datasets.preprocessor import CommonPreprocessor@@ -273,7 +271,6 @@ class SVTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()# NOTE(kamo): int value = 0 is reserved by CTC-blank symbolreturn CommonCollateFn(float_pad_value=0.0, int_pad_value=-1)@@ -281,7 +278,6 @@ class SVTask(AbsTask):def build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()if args.use_preprocessor:retval = CommonPreprocessor(train=train,@@ -309,7 +305,6 @@ class SVTask(AbsTask):)else:retval = None- assert check_return_type(retval)return retval@classmethod@@ -330,12 +325,10 @@ class SVTask(AbsTask):retval = ()if inference:retval = ("ref_speech",)- assert check_return_type(retval)return retval@classmethoddef build_model(cls, args: argparse.Namespace) -> ESPnetSVModel:- assert check_argument_types()if isinstance(args.token_list, str):with open(args.token_list, encoding="utf-8") as f:token_list = [line.rstrip() for line in f]@@ -449,7 +442,6 @@ class SVTask(AbsTask):if args.init is not None:initialize(model, args.init)- assert check_return_type(model)return model# ~~~~~~~~~ The methods below are mainly used for inference ~~~~~~~~~@@ -472,7 +464,6 @@ class SVTask(AbsTask):device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "diff --git a/funasr/tasks/vad.py b/funasr/tasks/vad.pyindex ec955964f..822be22d6 100644--- a/funasr/tasks/vad.py+++ b/funasr/tasks/vad.py@@ -13,8 +13,6 @@ from typing import Unionimport numpy as npimport torchimport yaml-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.datasets.collate_fn import CommonCollateFnfrom funasr.layers.abs_normalize import AbsNormalize@@ -192,7 +190,6 @@ class VADTask(AbsTask):[Collection[Tuple[str, Dict[str, np.ndarray]]]],Tuple[List[str], Dict[str, torch.Tensor]],]:- assert check_argument_types()# NOTE(kamo): int value = 0 is reserved by CTC-blank symbolreturn CommonCollateFn(float_pad_value=0.0, int_pad_value=-1)@@ -200,7 +197,6 @@ class VADTask(AbsTask):def build_preprocess_fn(cls, args: argparse.Namespace, train: bool) -> Optional[Callable[[str, Dict[str, np.array]], Dict[str, np.ndarray]]]:- assert check_argument_types()# if args.use_preprocessor:# retval = CommonPreprocessor(# train=train,@@ -223,7 +219,6 @@ class VADTask(AbsTask):# else:# retval = Noneretval = None- assert check_return_type(retval)return retval@classmethod@@ -242,12 +237,10 @@ class VADTask(AbsTask):cls, train: bool = True, inference: bool = False) -> Tuple[str, ...]:retval = ()- assert check_return_type(retval)return retval@classmethoddef build_model(cls, args: argparse.Namespace):- assert check_argument_types()# 4. Encoderencoder_class = encoder_choices.get_class(args.encoder)encoder = encoder_class(**args.encoder_conf)@@ -297,7 +290,6 @@ class VADTask(AbsTask):device: Device type, "cpu", "cuda", or "cuda:N"."""- assert check_argument_types()if config_file is None:assert model_file is not None, ("The argument 'model_file' must be provided "diff --git a/funasr/text/build_tokenizer.py b/funasr/text/build_tokenizer.pyindex 8e29d3ed5..c60a335fb 100644--- a/funasr/text/build_tokenizer.py+++ b/funasr/text/build_tokenizer.py@@ -2,7 +2,6 @@ from pathlib import Pathfrom typing import Iterablefrom typing import Union-from typeguard import check_argument_typesfrom funasr.text.abs_tokenizer import AbsTokenizerfrom funasr.text.char_tokenizer import CharTokenizer@@ -21,7 +20,6 @@ def build_tokenizer(g2p_type: str = None,) -> AbsTokenizer:"""A helper function to instantiate Tokenizer"""- assert check_argument_types()if token_type == "bpe":if bpemodel is None:raise ValueError('bpemodel is required if token_type = "bpe"')diff --git a/funasr/text/char_tokenizer.py b/funasr/text/char_tokenizer.pyindex 00ae42732..8d1daf4e1 100644--- a/funasr/text/char_tokenizer.py+++ b/funasr/text/char_tokenizer.py@@ -4,7 +4,6 @@ from typing import Listfrom typing import Unionimport warnings-from typeguard import check_argument_typesfrom funasr.text.abs_tokenizer import AbsTokenizer@@ -16,7 +15,6 @@ class CharTokenizer(AbsTokenizer):space_symbol: str = "<space>",remove_non_linguistic_symbols: bool = False,):- assert check_argument_types()self.space_symbol = space_symbolif non_linguistic_symbols is None:self.non_linguistic_symbols = set()diff --git a/funasr/text/cleaner.py b/funasr/text/cleaner.pyindex be26940c4..632267296 100644--- a/funasr/text/cleaner.py+++ b/funasr/text/cleaner.py@@ -2,7 +2,6 @@ from typing import Collectionfrom jaconv import jaconvimport tacotron_cleaner.cleaners-from typeguard import check_argument_typestry:from vietnamese_cleaner import vietnamese_cleaners@@ -21,7 +20,6 @@ class TextCleaner:"""def __init__(self, cleaner_types: Collection[str] = None):- assert check_argument_types()if cleaner_types is None:self.cleaner_types = []diff --git a/funasr/text/phoneme_tokenizer.py b/funasr/text/phoneme_tokenizer.pyindex d424b40a8..ad3d81cab 100644--- a/funasr/text/phoneme_tokenizer.py+++ b/funasr/text/phoneme_tokenizer.py@@ -9,7 +9,6 @@ import warnings# import g2p_enimport jamo-from typeguard import check_argument_typesfrom funasr.text.abs_tokenizer import AbsTokenizer@@ -365,7 +364,6 @@ class PhonemeTokenizer(AbsTokenizer):space_symbol: str = "<space>",remove_non_linguistic_symbols: bool = False,):- assert check_argument_types()if g2p_type is None:self.g2p = split_by_spaceelif g2p_type == "g2p_en":diff --git a/funasr/text/sentencepiece_tokenizer.py b/funasr/text/sentencepiece_tokenizer.pyindex e4cc15272..e393cee39 100644--- a/funasr/text/sentencepiece_tokenizer.py+++ b/funasr/text/sentencepiece_tokenizer.py@@ -4,14 +4,12 @@ from typing import Listfrom typing import Unionimport sentencepiece as spm-from typeguard import check_argument_typesfrom funasr.text.abs_tokenizer import AbsTokenizerclass SentencepiecesTokenizer(AbsTokenizer):def __init__(self, model: Union[Path, str]):- assert check_argument_types()self.model = str(model)# NOTE(kamo):# Don't build SentencePieceProcessor in __init__()diff --git a/funasr/text/token_id_converter.py b/funasr/text/token_id_converter.pyindex c9a6b2863..1888d7508 100644--- a/funasr/text/token_id_converter.py+++ b/funasr/text/token_id_converter.py@@ -5,7 +5,6 @@ from typing import Listfrom typing import Unionimport numpy as np-from typeguard import check_argument_typesclass TokenIDConverter:@@ -14,7 +13,6 @@ class TokenIDConverter:token_list: Union[Path, str, Iterable[str]],unk_symbol: str = "<unk>",):- assert check_argument_types()if isinstance(token_list, (Path, str)):token_list = Path(token_list)diff --git a/funasr/text/word_tokenizer.py b/funasr/text/word_tokenizer.pyindex 842734e75..f4d33d52d 100644--- a/funasr/text/word_tokenizer.py+++ b/funasr/text/word_tokenizer.py@@ -4,7 +4,6 @@ from typing import Listfrom typing import Unionimport warnings-from typeguard import check_argument_typesfrom funasr.text.abs_tokenizer import AbsTokenizer@@ -16,7 +15,6 @@ class WordTokenizer(AbsTokenizer):non_linguistic_symbols: Union[Path, str, Iterable[str]] = None,remove_non_linguistic_symbols: bool = False,):- assert check_argument_types()self.delimiter = delimiterif not remove_non_linguistic_symbols and non_linguistic_symbols is not None:diff --git a/funasr/torch_utils/forward_adaptor.py b/funasr/torch_utils/forward_adaptor.pyindex 114af7851..eb6da2bb1 100644--- a/funasr/torch_utils/forward_adaptor.py+++ b/funasr/torch_utils/forward_adaptor.py@@ -1,5 +1,4 @@import torch-from typeguard import check_argument_typesclass ForwardAdaptor(torch.nn.Module):@@ -21,7 +20,6 @@ class ForwardAdaptor(torch.nn.Module):"""def __init__(self, module: torch.nn.Module, name: str):- assert check_argument_types()super().__init__()self.module = moduleself.name = namediff --git a/funasr/torch_utils/initialize.py b/funasr/torch_utils/initialize.pyindex 2c0e7a435..e4ec5343b 100644--- a/funasr/torch_utils/initialize.py+++ b/funasr/torch_utils/initialize.py@@ -4,7 +4,6 @@import mathimport torch-from typeguard import check_argument_typesdef initialize(model: torch.nn.Module, init: str):@@ -19,7 +18,6 @@ def initialize(model: torch.nn.Module, init: str):model: Target.init: Method of initialization."""- assert check_argument_types()if init == "chainer":# 1. lecun_normal_init_parametersdiff --git a/funasr/train/abs_model.py b/funasr/train/abs_model.pyindex 8d684bea0..968737674 100644--- a/funasr/train/abs_model.py+++ b/funasr/train/abs_model.py@@ -8,7 +8,6 @@ from typing import Tupleimport torchimport torch.nn.functional as F-from typeguard import check_argument_typesfrom funasr.modules.nets_utils import make_pad_maskfrom funasr.torch_utils.device_funcs import force_gatherable@@ -34,7 +33,6 @@ class AbsLM(torch.nn.Module, BatchScorerInterface, ABC):class LanguageModel(FunASRModel):def __init__(self, lm: AbsLM, vocab_size: int, ignore_id: int = 0):- assert check_argument_types()super().__init__()self.lm = lmself.sos = 1@@ -154,7 +152,6 @@ class LanguageModel(FunASRModel):class PunctuationModel(FunASRModel):def __init__(self, punc_model: torch.nn.Module, vocab_size: int, ignore_id: int = 0, punc_weight: list = None):- assert check_argument_types()super().__init__()self.punc_model = punc_modelself.punc_weight = torch.Tensor(punc_weight)diff --git a/funasr/train/class_choices.py b/funasr/train/class_choices.pyindex 658d29166..1ffb97afe 100644--- a/funasr/train/class_choices.py+++ b/funasr/train/class_choices.py@@ -2,8 +2,6 @@ from typing import Mappingfrom typing import Optionalfrom typing import Tuple-from typeguard import check_argument_types-from typeguard import check_return_typefrom funasr.utils.nested_dict_action import NestedDictActionfrom funasr.utils.types import str_or_none@@ -40,7 +38,6 @@ class ClassChoices:default: str = None,optional: bool = False,):- assert check_argument_types()self.name = nameself.base_type = type_checkself.classes = {k.lower(): v for k, v in classes.items()}@@ -64,12 +61,10 @@ class ClassChoices:return retvaldef get_class(self, name: Optional[str]) -> Optional[type]:- assert check_argument_types()if name is None or (self.optional and name.lower() == ("none", "null", "nil")):retval = Noneelif name.lower() in self.classes:class_obj = self.classes[name]- assert check_return_type(class_obj)retval = class_objelse:raise ValueError(diff --git a/funasr/train/reporter.py b/funasr/train/reporter.pyindex 2921fef28..cfe31f518 100644--- a/funasr/train/reporter.py+++ b/funasr/train/reporter.py@@ -18,8 +18,6 @@ from typing import Unionimport humanfriendlyimport numpy as npimport torch-from typeguard import check_argument_types-from typeguard import check_return_typeNum = Union[float, int, complex, torch.Tensor, np.ndarray]@@ -27,7 +25,6 @@ _reserved = {"time", "total_count"}def to_reported_value(v: Num, weight: Num = None) -> "ReportedValue":- assert check_argument_types()if isinstance(v, (torch.Tensor, np.ndarray)):if np.prod(v.shape) != 1:raise ValueError(f"v must be 0 or 1 dimension: {len(v.shape)}")@@ -42,12 +39,10 @@ def to_reported_value(v: Num, weight: Num = None) -> "ReportedValue":retval = WeightedAverage(v, weight)else:retval = Average(v)- assert check_return_type(retval)return retvaldef aggregate(values: Sequence["ReportedValue"]) -> Num:- assert check_argument_types()for v in values:if not isinstance(v, type(values[0])):@@ -86,7 +81,6 @@ def aggregate(values: Sequence["ReportedValue"]) -> Num:else:raise NotImplementedError(f"type={type(values[0])}")- assert check_return_type(retval)return retval@@ -122,7 +116,6 @@ class SubReporter:"""def __init__(self, key: str, epoch: int, total_count: int):- assert check_argument_types()self.key = keyself.epoch = epochself.start_time = time.perf_counter()@@ -160,7 +153,6 @@ class SubReporter:stats: Dict[str, Optional[Union[Num, Dict[str, Num]]]],weight: Num = None,) -> None:- assert check_argument_types()if self._finished:raise RuntimeError("Already finished")if len(self._seen_keys_in_the_step) == 0:@@ -293,7 +285,6 @@ class Reporter:"""def __init__(self, epoch: int = 0):- assert check_argument_types()if epoch < 0:raise ValueError(f"epoch must be 0 or more: {epoch}")self.epoch = epochdiff --git a/funasr/train/trainer.py b/funasr/train/trainer.pyindex f0669094c..a25f39a55 100644--- a/funasr/train/trainer.py+++ b/funasr/train/trainer.py@@ -26,7 +26,6 @@ import numpy as npimport torchimport torch.nnimport torch.optim-from typeguard import check_argument_typesfrom funasr.iterators.abs_iter_factory import AbsIterFactoryfrom funasr.main_funcs.average_nbest_models import average_nbest_models@@ -127,7 +126,6 @@ class Trainer:@classmethoddef build_options(cls, args: argparse.Namespace) -> TrainerOptions:"""Build options consumed by train(), eval()"""- assert check_argument_types()return build_dataclass(TrainerOptions, args)@classmethod@@ -188,7 +186,6 @@ class Trainer:distributed_option: DistributedOption,) -> None:"""Perform training. This method performs the main process of training."""- assert check_argument_types()# NOTE(kamo): Don't check the type more strictly as far trainer_optionsassert is_dataclass(trainer_options), type(trainer_options)assert len(optimizers) == len(schedulers), (len(optimizers), len(schedulers))@@ -551,7 +548,6 @@ class Trainer:options: TrainerOptions,distributed_option: DistributedOption,) -> Tuple[bool, bool]:- assert check_argument_types()grad_noise = options.grad_noiseaccum_grad = options.accum_grad@@ -845,7 +841,6 @@ class Trainer:options: TrainerOptions,distributed_option: DistributedOption,) -> None:- assert check_argument_types()ngpu = options.ngpuno_forward_run = options.no_forward_rundistributed = distributed_option.distributeddiff --git a/funasr/utils/griffin_lim.py b/funasr/utils/griffin_lim.pyindex c1536d51b..9e98ab824 100644--- a/funasr/utils/griffin_lim.py+++ b/funasr/utils/griffin_lim.py@@ -9,7 +9,6 @@ import loggingfrom distutils.version import LooseVersionfrom functools import partial-from typeguard import check_argument_typesfrom typing import Optionalimport librosa@@ -138,7 +137,6 @@ class Spectrogram2Waveform(object):griffin_lim_iters: The number of iterations."""- assert check_argument_types()self.fs = fsself.logmel2linear = (partial(diff --git a/setup.py b/setup.pyindex f13a2c261..30e1f1aba 100644--- a/setup.py+++ b/setup.py@@ -4,7 +4,6 @@import os-from distutils.version import LooseVersionfrom setuptools import find_packagesfrom setuptools import setup@@ -12,73 +11,45 @@ from setuptools import setuprequirements = {"install": ["setuptools>=38.5.1",- # "configargparse>=1.2.1",- "typeguard==2.13.3",+ "typeguard>=3.0.1","humanfriendly","scipy>=1.4.1",- # "filelock","librosa",- "jamo==0.4.1", # For kss+ "jamo", # For kss"PyYAML>=5.1.2",- "soundfile>=0.11.0",+ "soundfile>=0.10.2","h5py>=2.10.0","kaldiio>=2.17.0","torch_complex","nltk>=3.4.5",# ASR"sentencepiece",- # "ctc-segmentation<1.8,>=1.6.6",# TTS- # "pyworld>=0.2.10",- "pypinyin<=0.44.0",+ "pypinyin>=0.44.0","espnet_tts_frontend",# ENH- # "ci_sdr","pytorch_wpe","editdistance>=0.5.2",- "tensorboard==1.15",+ "tensorboard","g2p",# PAI"oss2",- # "kaldi-native-fbank",- # timestamp"edit-distance",- # textgrid"textgrid",- "protobuf==3.20.0",+ "protobuf",],# train: The modules invoked when training only."train": [- # "pillow>=6.1.0",- "editdistance==0.5.2",+ "editdistance","wandb",],- # recipe: The modules actually are not invoked in the main module of funasr,- # but are invoked for the python scripts in each recipe- "recipe": [- "espnet_model_zoo",- # "gdown",- # "resampy",- # "pysptk>=0.1.17",- # "morfessor", # for zeroth-korean- # "youtube_dl", # for laborotv- # "nnmnkwii",- # "museval>=0.2.1",- # "pystoi>=0.2.2",- # "mir-eval>=0.6",- # "fastdtw",- # "nara_wpe>=0.0.5",- # "sacrebleu>=1.5.1",- ],# all: The modules should be optionally installled due to some reason.# Please consider moving them to "install" occasionally- # NOTE(kamo): The modules in "train" and "recipe" are appended into "all""all": [# NOTE(kamo): Append modules requiring specific pytorch version or torch>1.3.0"torch_optimizer","fairscale","transformers",- # "gtn==0.0.0",],"setup": ["numpy",@@ -98,17 +69,18 @@ requirements = {"black",],"doc": [- "Jinja2<3.1",- "Sphinx==2.1.2",+ "Jinja2",+ "Sphinx","sphinx-rtd-theme>=0.2.4","sphinx-argparse>=0.2.5",- "commonmark==0.8.1",+ "commonmark","recommonmark>=0.4.0","nbsphinx>=0.4.2","sphinx-markdown-tables>=0.0.12",+ "configargparse>=1.2.1"],}-requirements["all"].extend(requirements["train"] + requirements["recipe"])+requirements["all"].extend(requirements["train"])requirements["test"].extend(requirements["train"])install_requires = requirements["install"]@@ -151,4 +123,4 @@ setup("License :: OSI Approved :: Apache Software License","Topic :: Software Development :: Libraries :: Python Modules",],-)+)\ No newline at end of file