Skip to content
Discussion options

You must be logged in to vote

我重新按 FunASR 1.3.14 和当前 main 做了真实模型测试,需要先纠正之前的回复:Fun-ASR-Nano 目前不能把 np.ndarray 直接传给 generate()。Nano 的这条输入分支只处理文件路径或 torch.Tensor,直接传 NumPy 会报 TypeError: 'NoneType' object is not iterable

1. PCM / NumPy 可以纯内存推理,但请先转成 16 kHz 单声道 Tensor

下面这条路径不写磁盘:

import numpy as np
import torch
import torchaudio
from funasr import AutoModel

model = AutoModel(
    model="FunAudioLLM/Fun-ASR-Nano-2512",
    hub="hf",
    trust_remote_code=True,
    device="cuda:0",
    ctc_decoder=None,  # 只需要文本时关闭 CTC 时间戳分支
)

def numpy_to_16k_mono_tensor(audio_np, sample_rate):
    """audio_np 必须是一维、单声道、归一化到 [-1, 1] 的音频。"""
    audio_np = np.asarray(audio_np)
    if audio_np.ndim != 1:
        raise ValueError("请先按实际声道布局转…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LauraGPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants