kingabzpro commited on
Commit
f4d458d
·
1 Parent(s): c2d5c6b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -13
README.md CHANGED
@@ -36,19 +36,55 @@ It achieves the following results on the evaluation set:
36
  - Loss: 0.3534
37
  - Wer: 25.7842
38
 
39
- ## Model description
40
-
41
- More information needed
42
-
43
- ## Intended uses & limitations
44
-
45
- More information needed
46
-
47
- ## Training and evaluation data
48
-
49
- More information needed
50
-
51
- ## Training procedure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  ### Training hyperparameters
54
 
 
36
  - Loss: 0.3534
37
  - Wer: 25.7842
38
 
39
+ ## Usage
40
+
41
+ ```python
42
+
43
+ from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
44
+ from datasets import load_dataset
45
+ import torch, warnings, os
46
+
47
+ device = "cuda:0"
48
+ torch_dtype = torch.float16
49
+ model_id = "kingabzpro/whisper-large-v3-turbo-urdu"
50
+
51
+ model = AutoModelForSpeechSeq2Seq.from_pretrained(
52
+ model_id, torch_dtype=torch_dtype, use_safetensors=True
53
+ ).to(device)
54
+ model.config.use_cache = False
55
+ model.generation_config.language = "ur"
56
+ model.generation_config.task = "transcribe"
57
+
58
+ processor = AutoProcessor.from_pretrained(model_id)
59
+
60
+ pipe = pipeline(
61
+ "automatic-speech-recognition",
62
+ model=model,
63
+ tokenizer=processor.tokenizer,
64
+ feature_extractor=processor.feature_extractor,
65
+ torch_dtype=torch_dtype,
66
+ device=device,
67
+ )
68
+
69
+ ds = load_dataset(
70
+ "mozilla-foundation/common_voice_17_0",
71
+ "ur",
72
+ split="test",
73
+ trust_remote_code=True,
74
+ cache_dir="./hf_cache",
75
+ )
76
+ audio = ds[100]["audio"]
77
+
78
+ result = pipe(audio)
79
+ print("Original :", ds[100]["sentence"])
80
+ print("Predicted :", result["text"])
81
+
82
+ ```
83
+
84
+ ```sh
85
+ Original : اگر عمران خان ٹھیک کر رہے ہیں۔
86
+ Predicted : اگر عمران خان ٹھیک کر رہے ہیں۔
87
+ ```
88
 
89
  ### Training hyperparameters
90