Views
No views yet

1import torch
2from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
3
4device = "cuda:0" if torch.cuda.is_available() else "cpu"
5torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
6
7model_id = "olib-ai/whisper-to-oliver-fp16"
8
9model = AutoModelForSpeechSeq2Seq.from_pretrained(
10 model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
11)
12model.to(device)
13
14processor = AutoProcessor.from_pretrained(model_id)
15
16pipe = pipeline(
17 "automatic-speech-recognition",
18 model=model,
19 tokenizer=processor.tokenizer,
20 feature_extractor=processor.feature_extractor,
21 torch_dtype=torch_dtype,
22 device=device,
23)
24
25# Transcribe audio
26result = pipe("audio.mp3")
27print(result["text"])1# For better results with phone calls or poor quality audio
2result = pipe(
3 "phone_call.mp3",
4 chunk_length_s=30,
5 batch_size=16,
6 return_timestamps=True,
7)
8print(result["text"])| Metric | FP32 Version | FP16 Version |
|---|---|---|
| Model Size | ~1.5GB | ~760MB |
| Inference Speed | 1x | ~2x faster |
| Memory Usage | 1x | ~50% less |
| Accuracy | Baseline | ~99.9% retained |
1@misc{whisper-to-oliver,
2 author = {{Olib AI}},
3 title = {Whisper to Oliver: Fine-tuned Whisper for Real-World Conversational Audio},
4 year = {2024},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/olib-ai/whisper-to-oliver-fp16}},
7}
8
9@misc{radford2022whisper,
10 doi = {10.48550/ARXIV.2212.04356},
11 url = {https://arxiv.org/abs/2212.04356},
12 author = {Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
13 title = {Robust Speech Recognition via Large-Scale Weak Supervision},
14 publisher = {arXiv},
15 year = {2022},
16 copyright = {arXiv.org perpetual, non-exclusive license}
17}