Initial commit: FunASR Speech Recognition Toolkit
Update API Documentation / build-api-docs (push) Has been cancelled
Update API Documentation / build-api-docs (push) Has been cancelled
Add complete FunASR codebase including models, runtime, and documentation.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test Qwen3-ASR: multi-language speech recognition via AutoModel"""
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def main():
|
||||
from funasr import AutoModel
|
||||
|
||||
url_zh = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen3-ASR-Repo/asr_zh.wav"
|
||||
url_en = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen3-ASR-Repo/asr_en.wav"
|
||||
|
||||
# Standard FunASR usage: model path from ModelScope/HuggingFace
|
||||
# Default hub="ms" (ModelScope), use hub="hf" for HuggingFace
|
||||
print("[Qwen3-ASR] Loading model...")
|
||||
t0 = time.time()
|
||||
model = AutoModel(
|
||||
model="Qwen/Qwen3-ASR-1.7B",
|
||||
hub="hf",
|
||||
device="cuda:0",
|
||||
disable_update=True,
|
||||
)
|
||||
print("[Qwen3-ASR] Model loaded in %.1fs" % (time.time() - t0))
|
||||
|
||||
# Test 1: Chinese audio with forced language
|
||||
print("[Qwen3-ASR] Test 1: Chinese inference...")
|
||||
t0 = time.time()
|
||||
res = model.generate(
|
||||
input=url_zh,
|
||||
language="Chinese",
|
||||
)
|
||||
print("[Qwen3-ASR] Inference done in %.1fs" % (time.time() - t0))
|
||||
|
||||
if res and len(res) > 0 and "text" in res[0]:
|
||||
print("[Qwen3-ASR] Result (zh): %s" % res[0]["text"])
|
||||
print("[Qwen3-ASR] Test 1 PASSED")
|
||||
else:
|
||||
print("[Qwen3-ASR] Test 1 FAILED - no text in result")
|
||||
return 1
|
||||
|
||||
# Test 2: English audio with forced language
|
||||
print("[Qwen3-ASR] Test 2: English inference...")
|
||||
t0 = time.time()
|
||||
res = model.generate(
|
||||
input=url_en,
|
||||
language="English",
|
||||
)
|
||||
print("[Qwen3-ASR] Inference done in %.1fs" % (time.time() - t0))
|
||||
|
||||
if res and len(res) > 0 and "text" in res[0]:
|
||||
print("[Qwen3-ASR] Result (en): %s" % res[0]["text"])
|
||||
print("[Qwen3-ASR] Test 2 PASSED")
|
||||
else:
|
||||
print("[Qwen3-ASR] Test 2 FAILED - no text in result")
|
||||
return 1
|
||||
|
||||
# Test 3: Auto language detection (no forced language)
|
||||
print("[Qwen3-ASR] Test 3: Auto language detection...")
|
||||
t0 = time.time()
|
||||
res = model.generate(
|
||||
input=url_zh,
|
||||
)
|
||||
print("[Qwen3-ASR] Inference done in %.1fs" % (time.time() - t0))
|
||||
|
||||
if res and len(res) > 0 and "text" in res[0]:
|
||||
print("[Qwen3-ASR] Result (auto): %s" % res[0]["text"])
|
||||
if "language" in res[0]:
|
||||
print("[Qwen3-ASR] Detected language: %s" % res[0]["language"])
|
||||
print("[Qwen3-ASR] Test 3 PASSED")
|
||||
else:
|
||||
print("[Qwen3-ASR] Test 3 FAILED - no text in result")
|
||||
return 1
|
||||
|
||||
print("[Qwen3-ASR] All tests PASSED")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user