mirror of
https://github.com/modelscope/FunASR.git
synced 2026-10-12 02:19:18 +00:00
refactor: Qwen3ASR follows standard AutoModel hub download convention
Usage now follows FunASR convention:
from funasr import AutoModel
model = AutoModel(model="Qwen/Qwen3-ASR-1.7B", hub="hf", device="cuda:0")
res = model.generate(input="audio.wav", language="Chinese")
Changes:
- Register model class under hub paths ("Qwen/Qwen3-ASR-1.7B",
"Qwen/Qwen3-ASR-0.6B") so AutoModel can resolve them after
download_from_hf finds no configuration.json
- model_path defaults to kwargs["model"] for hub path compatibility
- Update test to use standard AutoModel(model=..., hub="hf") pattern
Tested end-to-end: AutoModel downloads from HuggingFace and runs
inference correctly.
This commit is contained in:
@@ -10,11 +10,13 @@ from funasr.register import tables
|
||||
|
||||
|
||||
@tables.register("model_classes", "Qwen3ASR")
|
||||
@tables.register("model_classes", "Qwen/Qwen3-ASR-1.7B")
|
||||
@tables.register("model_classes", "Qwen/Qwen3-ASR-0.6B")
|
||||
class Qwen3ASR(nn.Module):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__()
|
||||
model_path = kwargs.get("model_path", "Qwen/Qwen3-ASR-1.7B")
|
||||
model_path = kwargs.get("model_path", kwargs.get("model", "Qwen/Qwen3-ASR-1.7B"))
|
||||
device = kwargs.get("device", "cuda:0")
|
||||
dtype = kwargs.get("dtype", "bf16")
|
||||
max_new_tokens = kwargs.get("max_new_tokens", 512)
|
||||
|
||||
@@ -7,20 +7,16 @@ import time
|
||||
def main():
|
||||
from funasr import AutoModel
|
||||
|
||||
model_path = "Qwen/Qwen3-ASR-1.7B"
|
||||
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="Qwen3ASR",
|
||||
model_conf={
|
||||
"model_path": model_path,
|
||||
"dtype": "bf16",
|
||||
"max_new_tokens": 256,
|
||||
"max_inference_batch_size": 32,
|
||||
},
|
||||
model="Qwen/Qwen3-ASR-1.7B",
|
||||
hub="hf",
|
||||
device="cuda:0",
|
||||
disable_update=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user