Safetensors
qwen3_asr
Wendy9805 commited on
Commit
6f0d3ac
·
verified ·
1 Parent(s): 041de5d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +27 -35
README.md CHANGED
@@ -37,33 +37,31 @@ FormalASR-1.7B is a fine-tuned ASR (Automatic Speech Recognition) model based on
37
 
38
  ## Usage
39
 
 
 
 
 
 
 
40
  ### HuggingFace
41
 
42
  ```python
43
  import torch
44
- from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
45
 
46
- model_id = "TaurenMountain/FormalASR-1.7B"
47
-
48
- processor = AutoProcessor.from_pretrained(model_id)
49
- model = AutoModelForSpeechSeq2Seq.from_pretrained(
50
- model_id,
51
- torch_dtype=torch.bfloat16,
52
- device_map="auto"
53
  )
54
 
55
- # Load audio (16kHz, mono)
56
- import librosa
57
- audio, sr = librosa.load("your_audio.wav", sr=16000)
58
-
59
- inputs = processor(audio, sampling_rate=16000, return_tensors="pt")
60
- inputs = {k: v.to(model.device) for k, v in inputs.items()}
61
-
62
- with torch.no_grad():
63
- generated_ids = model.generate(**inputs)
64
 
65
- transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
66
- print(transcription)
67
  ```
68
 
69
  ### 魔搭社区(ModelScope)
@@ -71,30 +69,24 @@ print(transcription)
71
  ```python
72
  import torch
73
  from modelscope import snapshot_download
74
- from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
75
 
76
  # 下载模型到本地(首次运行自动下载)
77
  model_dir = snapshot_download("TaurenMountain/FormalASR-1.7B")
78
 
79
- processor = AutoProcessor.from_pretrained(model_dir)
80
- model = AutoModelForSpeechSeq2Seq.from_pretrained(
81
  model_dir,
82
- torch_dtype=torch.bfloat16,
83
- device_map="auto"
 
84
  )
85
 
86
- # Load audio (16kHz, mono)
87
- import librosa
88
- audio, sr = librosa.load("your_audio.wav", sr=16000)
89
-
90
- inputs = processor(audio, sampling_rate=16000, return_tensors="pt")
91
- inputs = {k: v.to(model.device) for k, v in inputs.items()}
92
-
93
- with torch.no_grad():
94
- generated_ids = model.generate(**inputs)
95
 
96
- transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
97
- print(transcription)
98
  ```
99
 
100
  ## Training Details
 
37
 
38
  ## Usage
39
 
40
+ ### Installation
41
+
42
+ ```bash
43
+ pip install -U qwen-asr
44
+ ```
45
+
46
  ### HuggingFace
47
 
48
  ```python
49
  import torch
50
+ from qwen_asr import Qwen3ASRModel
51
 
52
+ model = Qwen3ASRModel.from_pretrained(
53
+ "TaurenMountain/FormalASR-1.7B",
54
+ dtype=torch.bfloat16,
55
+ device_map="cuda:0",
56
+ max_new_tokens=512,
 
 
57
  )
58
 
59
+ results = model.transcribe(
60
+ audio="your_audio.wav",
61
+ language="Chinese",
62
+ )
 
 
 
 
 
63
 
64
+ print(results[0].text)
 
65
  ```
66
 
67
  ### 魔搭社区(ModelScope)
 
69
  ```python
70
  import torch
71
  from modelscope import snapshot_download
72
+ from qwen_asr import Qwen3ASRModel
73
 
74
  # 下载模型到本地(首次运行自动下载)
75
  model_dir = snapshot_download("TaurenMountain/FormalASR-1.7B")
76
 
77
+ model = Qwen3ASRModel.from_pretrained(
 
78
  model_dir,
79
+ dtype=torch.bfloat16,
80
+ device_map="cuda:0",
81
+ max_new_tokens=512,
82
  )
83
 
84
+ results = model.transcribe(
85
+ audio="your_audio.wav",
86
+ language="Chinese",
87
+ )
 
 
 
 
 
88
 
89
+ print(results[0].text)
 
90
  ```
91
 
92
  ## Training Details