MCPcopy
hub / github.com/modelscope/FunASR / vad_segment

Function vad_segment

benchmark_vllm.py:63–79  ·  view source on GitHub ↗
(files, device="cuda:0")

Source from the content-addressed store, hash-verified

61
62
63def vad_segment(files, device="cuda:0"):
64 from funasr import AutoModel
65 vad_model = AutoModel(model="fsmn-vad", device=device, disable_update=True)
66 all_segments = []
67 for fi, wav_path in enumerate(files):
68 audio, sr = sf.read(wav_path)
69 if audio.ndim > 1:
70 audio = audio[:, 0]
71 audio = audio.astype(np.float32)
72 res = vad_model.generate(input=wav_path, dynamic_silence=False)
73 for seg in res[0]["value"]:
74 s0 = int(seg[0] * sr / 1000)
75 s1 = int(seg[1] * sr / 1000)
76 seg_audio = audio[s0:s1]
77 if len(seg_audio) > sr * 0.5:
78 all_segments.append((fi, seg_audio))
79 return all_segments
80
81
82def concat_results(all_segments, seg_texts, n_files):

Callers 1

benchmark_vllm.pyFile · 0.85

Calls 3

generateMethod · 0.95
AutoModelClass · 0.90
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…