Upload README.md with huggingface_hub
Browse files
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
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
torch_dtype=torch.bfloat16,
|
| 52 |
-
device_map="auto"
|
| 53 |
)
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 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 |
-
|
| 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
|
| 75 |
|
| 76 |
# 下载模型到本地(首次运行自动下载)
|
| 77 |
model_dir = snapshot_download("TaurenMountain/FormalASR-1.7B")
|
| 78 |
|
| 79 |
-
|
| 80 |
-
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
| 81 |
model_dir,
|
| 82 |
-
|
| 83 |
-
device_map="
|
|
|
|
| 84 |
)
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 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 |
-
|
| 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
|