Views
No views yet
pip install -U qwen-asr1import torch
2from qwen_asr import Qwen3ASRModel
3
4model_path = "Grushashunyalabsai/qwen3-asr-rakuten-multilingual-18lang"
5device = "cuda:0" if torch.cuda.is_available() else "cpu"
6dtype = torch.bfloat16 if device.startswith("cuda") else torch.float32
7
8asr = Qwen3ASRModel.from_pretrained(
9 model_path,
10 dtype=dtype,
11 device_map=device,
12 max_inference_batch_size=16,
13 max_new_tokens=440,
14)
15
16# Single file (auto-detect language)
17results = asr.transcribe(audio="audio.wav")
18print(results[0].language) # e.g. "Japanese"
19print(results[0].text) # transcribed text
20
21# Force a specific language
22results = asr.transcribe(audio="audio.wav", language="Japanese")
23
24# From numpy array (16kHz mono)
25import numpy as np
26audio_array = np.zeros(16000, dtype=np.float32) # 1 sec
27results = asr.transcribe(audio=(audio_array, 16000))
28
29# Batch processing
30results = asr.transcribe(
31 audio=["file1.wav", "file2.wav", "file3.wav"],
32 language=["Japanese", "English", "Hindi"],
33)
34for r in results:
35 print(f"{r.language}: {r.text}")1# Auto-detect language
2python infer.py audio.wav
3
4# Force language
5python infer.py audio.wav --language Japanese
6
7# Batch folder to JSONL
8python infer.py ./audio_dir --out results.jsonl.wav, .flac, .mp3, .m4a, .ogg, .opus, .webm(np.ndarray, sample_rate) tuple1@dataclass
2class ASRTranscription:
3 language: str # e.g. "Japanese", "English", "Chinese,English"
4 text: str # Transcribed text
5 time_stamps: Optional[Any] # Word-level timestamps (if requested)model.safetensors — Model weights (bf16)config.json — Model configurationtokenizer_config.json — Tokenizer configurationvocab.json — Vocabularymerges.txt — BPE mergesinfer.py — CLI inference scriptpreprocessor_config.json — Audio preprocessor config