Update README.md
Browse files
README.md
CHANGED
@@ -5,4 +5,46 @@ language:
|
|
5 |
- el
|
6 |
metrics:
|
7 |
- wer
|
8 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- el
|
6 |
metrics:
|
7 |
- wer
|
8 |
+
---
|
9 |
+
|
10 |
+
# Whisper small finetuned for Greek transcription
|
11 |
+
|
12 |
+
## How to use
|
13 |
+
You can use the model for Greek ASR:
|
14 |
+
|
15 |
+
```python
|
16 |
+
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
17 |
+
from datasets import Audio, load_dataset
|
18 |
+
|
19 |
+
# load model and processor
|
20 |
+
processor = WhisperProcessor.from_pretrained("voxreality/whisper-small-el-finetune")
|
21 |
+
model = WhisperForConditionalGeneration.from_pretrained("voxreality/whisper-small-el-finetune")
|
22 |
+
forced_decoder_ids = processor.get_decoder_prompt_ids(language="greek", task="transcribe")
|
23 |
+
|
24 |
+
# load streaming dataset and read first audio sample
|
25 |
+
ds = load_dataset("mozilla-foundation/common_voice_11_0", "el", split="test", streaming=True)
|
26 |
+
ds = ds.cast_column("audio", Audio(sampling_rate=16_000))
|
27 |
+
input_speech = next(iter(ds))["audio"]
|
28 |
+
input_features = processor(input_speech["array"], sampling_rate=input_speech["sampling_rate"], return_tensors="pt").input_features
|
29 |
+
|
30 |
+
# generate token ids
|
31 |
+
predicted_ids = model.generate(input_features, forced_decoder_ids=forced_decoder_ids)
|
32 |
+
|
33 |
+
# decode token ids to text
|
34 |
+
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
35 |
+
```
|
36 |
+
|
37 |
+
You can also use an HF pipeline:
|
38 |
+
```python
|
39 |
+
from transformers import pipeline
|
40 |
+
from datasets import Audio, load_dataset
|
41 |
+
|
42 |
+
ds = load_dataset("mozilla-foundation/common_voice_11_0", "el", split="test", streaming=True)
|
43 |
+
ds = ds.cast_column("audio", Audio(sampling_rate=16_000))
|
44 |
+
input_speech = next(iter(ds))["audio"]
|
45 |
+
|
46 |
+
pipe = pipeline("automatic-speech-recognition", model='voxreality/whisper-small-el-finetune',
|
47 |
+
device='cpu', batch_size=32)
|
48 |
+
|
49 |
+
transcription = pipe(input_speech['array'], generate_kwargs = {"language":f"<|el|>","task": "transcribe"})
|
50 |
+
```
|