Update README.md
Browse files
README.md
CHANGED
@@ -79,25 +79,3 @@ python eval.py --model_id Maniac/wav2vec2-xls-r-urdu --dataset mozilla-foundatio
|
|
79 |
```bash
|
80 |
python eval.py --model_id Maniac/wav2vec2-xls-r-urdu --dataset speech-recognition-community-v2/dev_data --config ur --split validation --chunk_length_s 5.0 --stride_length_s 1.0
|
81 |
```
|
82 |
-
|
83 |
-
### Inference With LM
|
84 |
-
|
85 |
-
```python
|
86 |
-
import torch
|
87 |
-
from datasets import load_dataset
|
88 |
-
from transformers import AutoModelForCTC, AutoProcessor
|
89 |
-
import torchaudio.functional as F
|
90 |
-
|
91 |
-
model_id = "Maniac/wav2vec2-xls-r-urdu"
|
92 |
-
|
93 |
-
sample_iter = iter(load_dataset("mozilla-foundation/common_voice_7_0", "ur", split="test", streaming=True, use_auth_token=True))
|
94 |
-
sample = next(sample_iter)
|
95 |
-
resampled_audio = F.resample(torch.tensor(sample["audio"]["array"]), 48_000, 16_000).numpy()
|
96 |
-
model = AutoModelForCTC.from_pretrained(model_id)
|
97 |
-
processor = AutoProcessor.from_pretrained(model_id)
|
98 |
-
input_values = processor(resampled_audio, return_tensors="pt").input_values
|
99 |
-
|
100 |
-
with torch.no_grad():
|
101 |
-
logits = model(input_values).logits
|
102 |
-
transcription = processor.batch_decode(logits.numpy()).text
|
103 |
-
```
|
|
|
79 |
```bash
|
80 |
python eval.py --model_id Maniac/wav2vec2-xls-r-urdu --dataset speech-recognition-community-v2/dev_data --config ur --split validation --chunk_length_s 5.0 --stride_length_s 1.0
|
81 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|