Skip to content
Discussion options

You must be logged in to vote

可以。现在建议从旧的 ModelScope pipeline 迁移到 FunASR AutoModelgenerate(input=...) 可以直接接收 list[np.ndarray]batch_size 控制一次模型推理包含多少条切片。当前实现会按输入顺序返回结果,因此可以再与 segment ID 对齐。接口说明 批处理实现

下面是对 wav.scp + segments 的完整写法。它还避免了原代码在每个 segment 上重复读取同一录音:

from functools import lru_cache

import numpy as np
import soundfile as sf
from scipy.signal import resample_poly
from funasr import AutoModel

TARGET_SR = 16000
BATCH_SIZE = 8  # 按显存和切片长度调整


def read_wav_scp(path):
    recordings = {}
    with open(path, encoding="utf-8") as f:
        for line in f:
            recording_id, audio_path = line.rstrip().split(maxsplit=1)
            recordings[recording_id] = audio_path
    return recordings


@lru_cache(maxsize=

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Simon-chai
Comment options

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
3 participants