computeram commited on
Commit
1e26e7f
·
verified ·
1 Parent(s): 82d866f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +43 -15
README.md CHANGED
@@ -12,28 +12,60 @@ tags:
12
  - low-resource
13
  base_model: facebook/w2v-bert-2.0
14
  pipeline_tag: automatic-speech-recognition
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ---
16
 
17
- # Badini Kurdish ASR (Wav2Vec2-BERT)
18
 
19
  An automatic speech recognition (ASR) model for **Badini Kurdish** (a variety of
20
  Kurmanji, written in Arabic script), fine-tuned from
21
  [`facebook/w2v-bert-2.0`](https://huggingface.co/facebook/w2v-bert-2.0)
22
  with a CTC head.
23
 
 
 
 
 
 
 
 
 
24
 
25
  ## Input requirements
26
 
27
  - Audio must be **16 kHz, mono**.
28
- - Resample any other sample rate to 16 kHz before running inference.
29
 
30
  ## Usage
31
 
32
  ```python
33
  import torch, soundfile as sf
34
  from transformers import Wav2Vec2BertForCTC, Wav2Vec2BertProcessor
 
 
 
 
 
 
 
 
 
 
35
 
36
- repo_id = "computeram/badini-w2v-bert"
37
  processor = Wav2Vec2BertProcessor.from_pretrained(repo_id)
38
  model = Wav2Vec2BertForCTC.from_pretrained(repo_id).eval()
39
 
@@ -42,19 +74,15 @@ inputs = processor(speech, sampling_rate=16000, return_tensors="pt")
42
  with torch.no_grad():
43
  logits = model(**inputs).logits
44
  pred_ids = torch.argmax(logits, dim=-1)
45
- print(processor.batch_decode(pred_ids)[0])
46
- ```
47
-
48
- ## Important: text normalization
49
 
50
- This repository contains **only the acoustic model**. The raw output is plain CTC
51
- decoding. A separate normalization pipeline — punctuation restoration,
52
- number-to-word expansion (with Badini-specific remapping), character
53
- normalization, and word-variant correction — is applied in the downstream
54
- application and is **not** included here. Output straight from this model will
55
- not match the fully normalized transcripts.
56
 
57
  ## Intended use
58
 
59
- Speech transcription for Badini Kurdish. Given the WER, best used with
60
- downstream normalization/post-processing rather than as raw final text.
 
12
  - low-resource
13
  base_model: facebook/w2v-bert-2.0
14
  pipeline_tag: automatic-speech-recognition
15
+ metrics:
16
+ - wer
17
+ - cer
18
+ model-index:
19
+ - name: badini-w2v-bert-normalized
20
+ results:
21
+ - task:
22
+ type: automatic-speech-recognition
23
+ metrics:
24
+ - type: wer
25
+ value: 26.53
26
+ name: WER (normalized)
27
+ - type: cer
28
+ value: 11.32
29
+ name: CER (normalized)
30
  ---
31
 
32
+ # Badini Kurdish ASR — Normalized (Wav2Vec2-BERT)
33
 
34
  An automatic speech recognition (ASR) model for **Badini Kurdish** (a variety of
35
  Kurmanji, written in Arabic script), fine-tuned from
36
  [`facebook/w2v-bert-2.0`](https://huggingface.co/facebook/w2v-bert-2.0)
37
  with a CTC head.
38
 
39
+ This repository includes a companion text-normalization module
40
+ (`badini_normalize.py`) alongside the model, so following the usage example
41
+ below gives normalized output: **WER 26.5%, CER 11.3%** on a 1,123-sample
42
+ test set.
43
+
44
+ For the raw acoustic model without normalization (WER 46.5%, CER 12.0% on
45
+ 2,038 samples), see
46
+ [computeram/badini-w2v-bert](https://huggingface.co/computeram/badini-w2v-bert).
47
 
48
  ## Input requirements
49
 
50
  - Audio must be **16 kHz, mono**.
51
+ - Resample any other sample rate to 16 kHz before inference.
52
 
53
  ## Usage
54
 
55
  ```python
56
  import torch, soundfile as sf
57
  from transformers import Wav2Vec2BertForCTC, Wav2Vec2BertProcessor
58
+ from huggingface_hub import hf_hub_download
59
+ import importlib.util
60
+
61
+ repo_id = "computeram/badini-w2v-bert-normalized"
62
+
63
+ # download and load the companion normalization module
64
+ norm_path = hf_hub_download(repo_id, "badini_normalize.py")
65
+ spec = importlib.util.spec_from_file_location("badini_normalize", norm_path)
66
+ badini_normalize = importlib.util.module_from_spec(spec)
67
+ spec.loader.exec_module(badini_normalize)
68
 
 
69
  processor = Wav2Vec2BertProcessor.from_pretrained(repo_id)
70
  model = Wav2Vec2BertForCTC.from_pretrained(repo_id).eval()
71
 
 
74
  with torch.no_grad():
75
  logits = model(**inputs).logits
76
  pred_ids = torch.argmax(logits, dim=-1)
77
+ raw_text = processor.batch_decode(pred_ids)[0]
 
 
 
78
 
79
+ # apply the normalization pipeline (punctuation handling, Badini number
80
+ # expansion, character/word-variant unification)
81
+ text = badini_normalize.normalize_transcript(raw_text)
82
+ print(text)
83
+ ```
 
84
 
85
  ## Intended use
86
 
87
+ Speech transcription for Badini Kurdish, with the recommended normalization
88
+ already applied by following the usage example above.