Add sample usage from GitHub README

#1
by nielsr HF Staff - opened
Files changed (1) hide show
  1. README.md +38 -0
README.md CHANGED
@@ -14,6 +14,44 @@ tags:
14
 
15
  Lite-Whisper is a compressed version of OpenAI Whisper with LiteASR. See our [GitHub repository](https://github.com/efeslab/LiteASR) and [paper](https://arxiv.org/abs/2502.20583) for details.
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  ## Benchmark Results
18
 
19
  Following is the average word error rate (WER) evaluated on the [ESB datasets](https://huggingface.co/datasets/hf-audio/esb-datasets-test-only-sorted):
 
14
 
15
  Lite-Whisper is a compressed version of OpenAI Whisper with LiteASR. See our [GitHub repository](https://github.com/efeslab/LiteASR) and [paper](https://arxiv.org/abs/2502.20583) for details.
16
 
17
+ ## Quick Start
18
+ The easiest way to run our model is to use our integration with HuggingFace Transformers library.
19
+ We provide model weights for the compressed version of OpenAI Whisper series [here](https://huggingface.co/efficient-speech).
20
+
21
+ ```python
22
+ import librosa
23
+ import torch
24
+ from transformers import AutoProcessor, AutoModel
25
+
26
+ device = "cuda:0"
27
+ dtype = torch.float16
28
+
29
+ # load the compressed Whisper model
30
+ model = AutoModel.from_pretrained(
31
+ "efficient-speech/lite-whisper-large-v3-turbo",
32
+ trust_remote_code=True,
33
+ )
34
+ model.to(dtype).to(device)
35
+
36
+ # we use the same processor as the original model
37
+ processor = AutoProcessor.from_pretrained("openai/whisper-large-v3")
38
+
39
+ # set the path to your audio file
40
+ path = "path/to/audio.wav"
41
+ audio, _ = librosa.load(path, sr=16000)
42
+
43
+ input_features = processor(audio, sampling_rate=16000, return_tensors="pt").input_features
44
+ input_features = input_features.to(dtype).to(device)
45
+
46
+ predicted_ids = model.generate(input_features)
47
+ transcription = processor.batch_decode(
48
+ predicted_ids,
49
+ skip_special_tokens=True
50
+ )[0]
51
+
52
+ print(transcription)
53
+ ```
54
+
55
  ## Benchmark Results
56
 
57
  Following is the average word error rate (WER) evaluated on the [ESB datasets](https://huggingface.co/datasets/hf-audio/esb-datasets-test-only-sorted):