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
runtime_sdk_download_tool
雾聪9e11c526b0b2
diff --git a/funasr/utils/runtime_sdk_download_tool.py b/funasr/utils/runtime_sdk_download_tool.pynew file mode 100644index 000000000..9a0d40f67--- /dev/null+++ b/funasr/utils/runtime_sdk_download_tool.py@@ -0,0 +1,40 @@+from pathlib import Path+import os+import argparse+from funasr.utils.types import str2bool++parser = argparse.ArgumentParser()+parser.add_argument('--model-name', type=str, required=True)+parser.add_argument('--export-dir', type=str, required=True)+parser.add_argument('--export', type=str2bool, default=True, help='whether to export model')+parser.add_argument('--type', type=str, default='onnx', help='["onnx", "torch"]')+parser.add_argument('--device', type=str, default='cpu', help='["cpu", "cuda"]')+parser.add_argument('--quantize', type=str2bool, default=False, help='export quantized model')+parser.add_argument('--fallback-num', type=int, default=0, help='amp fallback number')+parser.add_argument('--audio_in', type=str, default=None, help='["wav", "wav.scp"]')+parser.add_argument('--model_revision', type=str, default=None, help='model_revision')+parser.add_argument('--calib_num', type=int, default=200, help='calib max num')+args = parser.parse_args()++model_dir = args.model_name+if not Path(args.model_name).exists():+ from modelscope.hub.snapshot_download import snapshot_download+ try:+ model_dir = snapshot_download(args.model_name, cache_dir=args.export_dir, revision=args.model_revision)+ except:+ raise "model_dir must be model_name in modelscope or local path downloaded from modelscope, but is {}".format \+ (model_dir)+if args.export:+ model_file = os.path.join(model_dir, 'model.onnx')+ if args.quantize:+ model_file = os.path.join(model_dir, 'model_quant.onnx')+ if not os.path.exists(model_file):+ print(".onnx is not exist, begin to export onnx")+ from funasr.export.export_model import ModelExport+ export_model = ModelExport(+ cache_dir=args.export_dir,+ onnx=True,+ device="cpu",+ quant=args.quantize,+ )+ export_model.export(model_dir)\ No newline at end of file