whisper base

Provideropenai
Categoryautomatic-speech-recognition
Licenseapache-2.0
Downloads3.1M
Stars0

Overview

Whisper Base is a lightweight, open-source automatic speech recognition (ASR) model designed for efficient transcription and translation. Unlike massive LLMs, this model focuses on robust audio-to-text conversion across multiple languages, balancing accuracy with low computational overhead. For developers, it serves as an ideal middle ground for real-time applications or edge deployment where latency is critical but basic accuracy is required. It integrates easily into Python pipelines via the OpenAI Whisper library or Hugging Face Transformers, making it a reliable choice for building voice-controlled interfaces, automated captioning tools, or meeting transcription services without the need for expensive GPU clusters.

Highlights

  • Efficient multi-lingual speech-to-text and translation capabilities
  • Low latency suitable for edge and real-time deployment
  • Apache-2.0 license for flexible commercial integration
  • Seamless compatibility with Hugging Face and Python ecosystems

Usage

Install
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# Load model with transformers
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("openai/whisper-base")
tokenizer = AutoTokenizer.from_pretrained("openai/whisper-base")

Hugging Face Download

We recommend downloading the model via the Hugging Face CLI or Hub SDK.

Guidance:Before downloading, install huggingface_hub with:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

Download the full repository
huggingface-cli download openai/whisper-base

Download a single file to a local folder (e.g. config.json into ./dir)

Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download openai/whisper-base config.json --local-dir ./dir

See the official docs for more CLI options

SDK Download

SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('openai/whisper-base')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://huggingface.co/openai/whisper-base

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/openai/whisper-base

Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.

PyTorch / Transformers Usage

Install Transformers

Install Transformers
pip install -U transformers torch

Load the model and run inference

Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('openai/whisper-base')
tokenizer = AutoTokenizer.from_pretrained('openai/whisper-base')

Full Documentation

来源: HuggingFace

---
language:

  • en

  • zh

  • de

  • es

  • ru

  • ko

  • fr

  • ja

  • pt

  • tr

  • pl

  • ca

  • nl

  • ar

  • sv

  • it

  • id

  • hi

  • fi

  • vi

  • he

  • uk

  • el

  • ms

  • cs

  • ro

  • da

  • hu

  • ta

  • no

  • th

  • ur

  • hr

  • bg

  • lt

  • la

  • mi

  • ml

  • cy

  • sk

  • te

  • fa

  • lv

  • bn

  • sr

  • az

  • sl

  • kn

  • et

  • mk

  • br

  • eu

  • is

  • hy

  • ne

  • mn

  • bs

  • kk

  • sq

  • sw

  • gl

  • mr

  • pa

  • si

  • km

  • sn

  • yo

  • so

  • af

  • oc

  • ka

  • be

  • tg

  • sd

  • gu

  • am

  • yi

  • lo

  • uz

  • fo

  • ht

  • ps

  • tk

  • nn

  • mt

  • sa

  • lb

  • my

  • bo

  • tl

  • mg

  • as

  • tt

  • haw

  • ln

  • ha

  • ba

  • jw

  • su

tags:
  • audio

  • automatic-speech-recognition

  • hf-asr-leaderboard

widget:
  • example_title: Librispeech sample 1

src: https://cdn-media.huggingface.co/speech_samples/sample1.flac
  • example_title: Librispeech sample 2

src: https://cdn-media.huggingface.co/speech_samples/sample2.flac
model-index:
  • name: whisper-base

results:
- task:
name: Automatic Speech Recognition
type: automatic-speech-recognition
dataset:
name: LibriSpeech (clean)
type: librispeech_asr
config: clean
split: test
args:
language: en
metrics:
- name: Test WER
type: wer
value: 5.008769117619326
- task:
name: Automatic Speech Recognition
type: automatic-speech-recognition
dataset:
name: LibriSpeech (other)
type: librispeech_asr
config: other
split: test
args:
language: en
metrics:
- name: Test WER
type: wer
value: 12.84936273212057
- task:
name: Automatic Speech Recognition
type: automatic-speech-recognition
dataset:
name: Common Voice 11.0
type: mozilla-foundation/common_voice_11_0
config: hi
split: test
args:
language: hi
metrics:
- name: Test WER
type: wer
value: 131
pipeline_tag: automatic-speech-recognition
license: apache-2.0
---

Whisper

Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Trained on 680k hours
of labelled data, Whisper models demonstrate a strong ability to generalise to many datasets and domains without the need
for fine-tuning.

Whisper was proposed in the paper Robust Speech Recognition via Large-Scale Weak Supervision
by Alec Radford et al from OpenAI. The original code repository can be found here.

Disclaimer: Content for this model card has partly been written by the Hugging Face team, and parts of it were
copied and pasted from the original model card.

Model details

Whisper is a Transformer based encoder-decoder model, also referred to as a _sequence-to-sequence_ model.
It was trained on 680k hours of labelled speech data annotated using large-scale weak supervision.

The models were trained on either English-only data or multilingual data. The English-only models were trained
on the task of speech recognition. The multilingual models were trained on both speech recognition and speech
translation. For speech recognition, the model predicts transcriptions in the *same* language as the audio.
For speech translation, the model predicts transcriptions to a *different* language to the audio.

Whisper checkpoints come in five configurations of varying model sizes.
The smallest four are trained on either English-only or multilingual data.
The largest checkpoints are multilingual only. All ten of the pre-trained checkpoints
are available on the Hugging Face Hub. The
checkpoints are summarised in the following table with links to the models on the Hub:

| Size | Parameters | English-only | Multilingual |
|----------|------------|------------------------------------------------------|-----------------------------------------------------|
| tiny | 39 M | | |
| base | 74 M | | |
| small | 244 M | | |
| medium | 769 M | | |
| large | 1550 M | x | |
| large-v2 | 1550 M | x | |

Usage

To transcribe audio samples, the model has to be used alongside a WhisperProcessor.

The WhisperProcessor is used to:
1. Pre-process the audio inputs (converting them to log-Mel spectrograms for the model)
2. Post-process the model outputs (converting them from tokens to text)

The model is informed of which task to perform (transcription or translation) by passing the appropriate "context tokens". These context tokens
are a sequence of tokens that are given to the decoder at the start of the decoding process, and take the following order:
1. The transcription always starts with the <|startoftranscript|> token
2. The second token is the language token (e.g. <|en|> for English)
3. The third token is the "task token". It can take one of two values: <|transcribe|> for speech recognition or <|translate|> for speech translation
4. In addition, a <|notimestamps|> token is added if the model should not include timestamp prediction

Thus, a typical sequence of context tokens might look as follows:

code
<|startoftranscript|> <|en|> <|transcribe|> <|notimestamps|>

Which tells the model to decode in English, under the task of speech recognition, and not to predict timestamps.

These tokens can either be forced or un-forced. If they are forced, the model is made to predict each token at
each position. This allows one to control the output language and task for the Whisper model. If they are un-forced,
the Whisper model will automatically predict the output langauge and task itself.

The context tokens can be set accordingly:

python
model.config.forced_decoder_ids = WhisperProcessor.get_decoder_prompt_ids(language="english", task="transcribe")

Which forces the model to predict in English under the task of speech recognition.

Transcription

English to English

In this example, the context tokens are 'unforced', meaning the model automatically predicts the output language (English) and task (transcribe).
python
>>> from transformers import WhisperProcessor, WhisperForConditionalGeneration
>>> from datasets import load_dataset

>>> # load model and processor
>>> processor = WhisperProcessor.from_pretrained("openai/whisper-base")
>>> model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-base")
>>> model.config.forced_decoder_ids = None

>>> # load dummy dataset and read audio files
>>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
>>> sample = ds[0]["audio"]
>>> input_features = processor(sample["array"], sampling_rate=sample["sampling_rate"], return_tensors="pt").input_features

>>> # generate token ids
>>> predicted_ids = model.generate(input_features)
>>> # decode token ids to text
>>> transcription = processor.batch_decode(predicted_ids, skip_special_tokens=False)
['<|startoftranscript|><|en|><|transcribe|><|notimestamps|> Mr. Quilter is the apostle of the middle classes and we are glad to welcome his gospel.<|endoftext|>']

>>> transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
[' Mr. Quilter is the apostle of the middle classes and we are glad to welcome his gospel.']


The context tokens can be removed f

Join our Telegram