mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
* c++ runtime adapt to 1.0 (#1724) * adapt vad runtime to 1.0 * add json * change yml name * add func LoadVocabFromJson * add token file for InitAsr * add token path for OfflineStream * add funcOpenYaml * add token file for InitPunc * add token file for stream * update punc-model * update funasr-wss-server * update runtime_sdk_download_tool.py * update docker list * Delete docs/images/wechat.png * Add files via upload * Emo2Vec限定选择的情感类别 (#1730) * 限定选择的情感类别 * 使用none来禁用情感标签输出 * 修改输出接口 * 使用unuse来禁用token --------- Co-authored-by: 常材 <gaochangfeng.gcf@alibaba-inc.com> * bugfix * v1.0.27 * update docs * hf hub * Fix incorrect assignment of 'end' attribute to 'start' in sentences list comprehension (#1680) --------- Co-authored-by: Yabin Li <wucong.lyb@alibaba-inc.com> Co-authored-by: gaochangfeng <54253717+gaochangfeng@users.noreply.github.com> Co-authored-by: 常材 <gaochangfeng.gcf@alibaba-inc.com> Co-authored-by: nsdou <168500039+nsdou@users.noreply.github.com>
53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
import os
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from funasr.utils.types import str2bool
|
|
|
|
|
|
def main():
|
|
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
|
|
output_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
|
|
)
|
|
output_dir = os.path.join(args.export_dir, args.model_name)
|
|
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 import AutoModel
|
|
|
|
export_model = AutoModel(model=args.model_name, output_dir=output_dir)
|
|
export_model.export(
|
|
quantize=args.quantize,
|
|
type=args.type,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|