Views
No views yet
Luigi/asr-324m-apache instead. This base
checkpoint is also the required starting point for reproducing that model's compression pipeline.1import torch
2from qwen_asr.core.transformers_backend.modeling_qwen3_asr import Qwen3ASRForConditionalGeneration
3from qwen_asr.core.transformers_backend.processing_qwen3_asr import Qwen3ASRProcessor
4
5path = "Luigi/asr-468m-apache-base"
6proc = Qwen3ASRProcessor.from_pretrained(path)
7model = Qwen3ASRForConditionalGeneration.from_pretrained(path, dtype=torch.bfloat16).cuda().eval()
8
9NATIVE = ("<|im_start|>system\n<|im_end|>\n<|im_start|>user\n<|audio_pad|><|im_end|>\n"
10 "<|im_start|>assistant\n")
11
12def transcribe(wav_16k_float32, language="Chinese", max_new_tokens=128):
13 e = proc(text=NATIVE + f"language {language}<asr_text>", audio=[wav_16k_float32],
14 sampling_rate=16000, return_tensors="pt")
15 e = {k: (v.cuda() if torch.is_tensor(v) else v) for k, v in e.items()}
16 if "input_features" in e:
17 e["input_features"] = e["input_features"].to(torch.bfloat16)
18 with torch.no_grad(), torch.autocast("cuda", dtype=torch.bfloat16):
19 out = model.generate(**e, max_new_tokens=max_new_tokens, do_sample=False)
20 ids = out[0][e["input_ids"].shape[1]:].tolist()
21 return proc.tokenizer.decode(ids, skip_special_tokens=True)language accepts: Chinese, English, French, German, Japanese, Korean, Cantonese.