MCPcopy Index your code
hub / github.com/modelscope/FunASR / main

Function main

tests_models/test_eres2netv2.py:7–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7def main():
8 from funasr import AutoModel
9
10 url_zh = "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav"
11
12 # Test 1: ERes2NetV2 as spk_model combined with VAD + ASR
13 print("[ERes2NetV2] Loading model with VAD + ASR + SPK...")
14 t0 = time.time()
15 model = AutoModel(
16 model="iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
17 vad_model="iic/speech_fsmn_vad_zh-cn-16k-common-pytorch",
18 vad_kwargs={"max_single_segment_time": 60000},
19 spk_model="iic/speech_eres2netv2_sv_zh-cn_16k-common",
20 device="cuda:0",
21 disable_update=True,
22 )
23 print("[ERes2NetV2] Model loaded in %.1fs" % (time.time() - t0))
24
25 # Test with speaker diarization
26 print("[ERes2NetV2] Running inference with speaker diarization...")
27 t0 = time.time()
28 res = model.generate(
29 input=url_zh,
30 batch_size_s=300,
31 )
32 print("[ERes2NetV2] Inference done in %.1fs" % (time.time() - t0))
33
34 if res and len(res) > 0 and "text" in res[0]:
35 print("[ERes2NetV2] Result: %s" % res[0]["text"])
36 if "spk" in res[0]:
37 print("[ERes2NetV2] Speaker: %s" % res[0]["spk"])
38 print("[ERes2NetV2] Test 1 PASSED")
39 else:
40 print("[ERes2NetV2] Test 1 FAILED - no text in result")
41 return 1
42
43 # Test 2: ERes2NetV2 standalone speaker embedding
44 print("[ERes2NetV2] Test 2: Standalone speaker embedding...")
45 t0 = time.time()
46 spk_model = AutoModel(
47 model="iic/speech_eres2netv2_sv_zh-cn_16k-common",
48 device="cuda:0",
49 disable_update=True,
50 )
51 res = spk_model.generate(input=url_zh)
52 print("[ERes2NetV2] Embedding done in %.1fs" % (time.time() - t0))
53
54 if res and len(res) > 0 and "spk_embedding" in res[0]:
55 emb = res[0]["spk_embedding"]
56 print("[ERes2NetV2] Embedding shape: %s" % str(emb.shape))
57 print("[ERes2NetV2] Test 2 PASSED")
58 else:
59 print("[ERes2NetV2] Test 2 FAILED - no spk_embedding in result")
60 return 1
61
62 print("[ERes2NetV2] All tests PASSED")
63 return 0
64

Callers 1

test_eres2netv2.pyFile · 0.70

Calls 2

generateMethod · 0.95
AutoModelClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…