Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
tags:
|
4 |
+
- asr
|
5 |
+
- whisper
|
6 |
+
- speech-recognition
|
7 |
+
---
|
8 |
+
|
9 |
+
|
10 |
+
```python
|
11 |
+
|
12 |
+
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
13 |
+
import librosa
|
14 |
+
import torch
|
15 |
+
|
16 |
+
|
17 |
+
model_name = "basharalrfooh/whisper-samll-quran"
|
18 |
+
processor = WhisperProcessor.from_pretrained(model_name)
|
19 |
+
model = WhisperForConditionalGeneration.from_pretrained(model_name)
|
20 |
+
model.config.forced_decoder_ids = None
|
21 |
+
|
22 |
+
|
23 |
+
audio_file = "Your .wav file"
|
24 |
+
|
25 |
+
speech_array, sampling_rate = librosa.load(audio_file, sr=16000)
|
26 |
+
|
27 |
+
inputs = processor(speech_array, return_tensors="pt", sampling_rate=sampling_rate)
|
28 |
+
|
29 |
+
with torch.no_grad():
|
30 |
+
predicted_ids = model.generate(inputs["input_features"])
|
31 |
+
|
32 |
+
# Decode token IDs to text
|
33 |
+
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
34 |
+
|
35 |
+
print(f"Transcription: {transcription}")
|
36 |
+
|