File size: 2,131 Bytes
82d866f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1e26e7f
82d866f
 
 
 
 
 
4f6d018
82d866f
 
 
 
1e26e7f
82d866f
 
 
 
 
 
1e26e7f
 
 
 
 
 
 
 
 
 
82d866f
 
 
 
 
 
 
 
 
1e26e7f
82d866f
1e26e7f
 
 
 
 
82d866f
 
 
1e26e7f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
language:
- kmr
license: mit
library_name: transformers
tags:
- automatic-speech-recognition
- wav2vec2-bert
- kurdish
- badini
- kurmanji
- low-resource
base_model: facebook/w2v-bert-2.0
pipeline_tag: automatic-speech-recognition
---

# Badini Kurdish ASR — Normalized (Wav2Vec2-BERT)

An automatic speech recognition (ASR) model for **Badini Kurdish** (a variety of
Kurmanji, written in Arabic script), fine-tuned from
[`facebook/w2v-bert-2.0`](https://huggingface.co/facebook/w2v-bert-2.0)
with a CTC head.

This repository includes a companion text-normalization module (`badini_normalize.py`) alongside the model. Following the usage example below applies punctuation handling, number expansion, and character normalization to the raw model output.

## Input requirements

- Audio must be **16 kHz, mono**.
- Resample any other sample rate to 16 kHz before inference.

## Usage

```python
import torch, soundfile as sf
from transformers import Wav2Vec2BertForCTC, Wav2Vec2BertProcessor
from huggingface_hub import hf_hub_download
import importlib.util

repo_id = "computeram/badini-w2v-bert-normalized"

# download and load the companion normalization module
norm_path = hf_hub_download(repo_id, "badini_normalize.py")
spec = importlib.util.spec_from_file_location("badini_normalize", norm_path)
badini_normalize = importlib.util.module_from_spec(spec)
spec.loader.exec_module(badini_normalize)

processor = Wav2Vec2BertProcessor.from_pretrained(repo_id)
model = Wav2Vec2BertForCTC.from_pretrained(repo_id).eval()

speech, sr = sf.read("audio.wav")   # 16 kHz mono
inputs = processor(speech, sampling_rate=16000, return_tensors="pt")
with torch.no_grad():
    logits = model(**inputs).logits
pred_ids = torch.argmax(logits, dim=-1)
raw_text = processor.batch_decode(pred_ids)[0]

# apply the normalization pipeline (punctuation handling, Badini number
# expansion, character/word-variant unification)
text = badini_normalize.normalize_transcript(raw_text)
print(text)
```

## Intended use

Speech transcription for Badini Kurdish, with the recommended normalization
already applied by following the usage example above.