mirror of
https://github.com/modelscope/FunASR.git
synced 2026-10-12 02:19:18 +00:00
fix: limit vLLM VAD segments to 30 seconds (#3420)
Configure FSMN-VAD with a 30-second maximum segment duration and add a regression test. This fixes the long-audio omission reproduced from #3419.
This commit is contained in:
@@ -93,7 +93,12 @@ def load_engine(args):
|
||||
gpu_memory_utilization=args.gpu_memory_utilization,
|
||||
)
|
||||
logger.info(f"Loading VAD: {args.vad_model}")
|
||||
_vad_model = AutoModel(model=args.vad_model, device=args.device, disable_update=True)
|
||||
_vad_model = AutoModel(
|
||||
model=args.vad_model,
|
||||
device=args.device,
|
||||
disable_update=True,
|
||||
max_single_segment_time=30000,
|
||||
)
|
||||
if args.spk_model:
|
||||
logger.info(f"Loading SPK: {args.spk_model}")
|
||||
_spk_model = AutoModel(model=args.spk_model, device=args.device, disable_update=True)
|
||||
|
||||
@@ -151,3 +151,35 @@ def test_process_audio_downmixes_stereo_before_resampling(monkeypatch):
|
||||
assert np.allclose(captured["engine_input"], 0.5)
|
||||
assert result["duration"] == 1.0
|
||||
assert result["text"] == "ok"
|
||||
|
||||
|
||||
def test_load_engine_limits_vad_segments_to_30_seconds(monkeypatch):
|
||||
module = load_service_module(monkeypatch)
|
||||
captured = {}
|
||||
|
||||
class EngineFactoryStub:
|
||||
@classmethod
|
||||
def from_pretrained(cls, **kwargs):
|
||||
return object()
|
||||
|
||||
def auto_model_stub(**kwargs):
|
||||
captured.update(kwargs)
|
||||
return object()
|
||||
|
||||
module.FunASRNanoVLLM = EngineFactoryStub
|
||||
module.AutoModel = auto_model_stub
|
||||
module._engine = None
|
||||
module.load_engine(
|
||||
types.SimpleNamespace(
|
||||
model="fun-asr-nano",
|
||||
hub="ms",
|
||||
device="cpu",
|
||||
dtype="bf16",
|
||||
max_model_len=4096,
|
||||
gpu_memory_utilization=0.5,
|
||||
vad_model="fsmn-vad",
|
||||
spk_model="",
|
||||
)
|
||||
)
|
||||
|
||||
assert captured["max_single_segment_time"] == 30000
|
||||
|
||||
Reference in New Issue
Block a user