Abhigyanr commited on
Commit
0a4f15d
1 Parent(s): 28e829d

added configs and models

Browse files
Files changed (1) hide show
  1. README.md +51 -0
README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: hi
3
+ metrics:
4
+ - wer
5
+ - cer
6
+ tags:
7
+ - audio
8
+ - automatic-speech-recognition
9
+ - speech
10
+ - wav2vec2
11
+ - asr
12
+ license: apache-2.0
13
+ ---
14
+
15
+ # IndicWav2Vec-Hindi
16
+
17
+ This is a [Wav2Vec2](https://arxiv.org/abs/2006.11477) style ASR model trained in [fairseq](https://github.com/facebookresearch/fairseq) and ported to Hugging Face.
18
+ More details on datasets, training-setup and conversion to HuggingFace format can be found in the [IndicWav2Vec](https://github.com/AI4Bharat/IndicWav2Vec) repo.
19
+ *Note: This model doesn't support inference with Language Model.*
20
+
21
+ ## Script to Run Inference
22
+
23
+ ```python
24
+ import torch
25
+ from datasets import load_dataset
26
+ from transformers import AutoModelForCTC, AutoProcessor
27
+ import torchaudio.functional as F
28
+
29
+ DEVICE_ID = "cuda" if torch.cuda.is_available() else "cpu"
30
+ MODEL_ID = "ai4bharat/indicwav2vec-hindi"
31
+
32
+ sample = next(iter(load_dataset("common_voice", "hi", split="test", streaming=True)))
33
+ resampled_audio = F.resample(torch.tensor(sample["audio"]["array"]), 48000, 16000).numpy()
34
+
35
+ model = AutoModelForCTC.from_pretrained(MODEL_ID).to(DEVICE_ID)
36
+ processor = AutoProcessor.from_pretrained(MODEL_ID)
37
+
38
+ input_values = processor(resampled_audio, return_tensors="pt").input_values
39
+
40
+ with torch.no_grad():
41
+ logits = model(input_values.to(DEVICE_ID)).logits.cpu()
42
+
43
+ prediction_ids = torch.argmax(logits, dim=-1)
44
+ output_str = processor.batch_decode(prediction_ids)[0]
45
+ print(f"Greedy Decoding: {output_str}")
46
+ ```
47
+
48
+ # **About AI4Bharat**
49
+ - Website: https://ai4bharat.org/
50
+ - Code: https://github.com/AI4Bharat
51
+ - HuggingFace: https://huggingface.co/ai4bharat