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

Function main

tests_models/test_sensevoice.py:6–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import time
5
6def main():
7 from funasr import AutoModel
8 from funasr.utils.postprocess_utils import rich_transcription_postprocess
9
10 print("[SenseVoice] Loading model...")
11 t0 = time.time()
12 model = AutoModel(
13 model="iic/SenseVoiceSmall",
14 vad_model="fsmn-vad",
15 vad_kwargs={"max_single_segment_time": 30000},
16 device="cpu",
17 disable_update=True,
18 )
19 print("[SenseVoice] Model loaded in %.1fs" % (time.time()-t0))
20
21 print("[SenseVoice] Running inference (Chinese)...")
22 t0 = time.time()
23 res = model.generate(
24 input=model.model_path + "/example/zh.mp3",
25 cache={},
26 language="auto",
27 use_itn=True,
28 batch_size_s=60,
29 merge_vad=True,
30 merge_length_s=15,
31 )
32 print("[SenseVoice] Inference done in %.1fs" % (time.time()-t0))
33
34 if res and len(res) > 0 and "text" in res[0]:
35 text = rich_transcription_postprocess(res[0]["text"])
36 print("[SenseVoice] Result: %s" % text)
37 print("[SenseVoice] PASSED")
38 return 0
39 else:
40 print("[SenseVoice] FAILED - no text in result")
41 return 1
42
43if __name__ == "__main__":
44 sys.exit(main())

Callers 1

test_sensevoice.pyFile · 0.70

Calls 3

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…