export_rebuild_model (bicif_paraformer/export_meta.py)

FunASR · funasr/models/bicif_paraformer/export_meta.py · python · MIT
voice

Rebuilds model components for ONNX export in FunASR.

#!/usr/bin/env python3
# Source: https://github.com/modelscope/FunASR | License: MIT | Copyright 2025 FunASR
# Provided via justclaw.it.com; keep this notice with the code.
# -*- encoding: utf-8 -*-
# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
#  MIT License  (https://opensource.org/licenses/MIT)

import torch
import types

from funasr.register import tables


def export_rebuild_model(model, **kwargs):
    """Export rebuild model.
    
        Args:
            model: Model instance or model name.
            **kwargs: Additional keyword arguments.
        """
    is_onnx = kwargs.get("type", "onnx") == "onnx"
    encoder_class = tables.encoder_classes.get(kwargs["encoder"] + "Export")
    model.encoder = encoder_class(model.encoder, onnx=is_onn

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key