Skip to main content
This guide will help you transcribe your first audio file using Whisper’s command-line interface and Python API.

Command-Line Usage

Basic Transcription

The simplest way to use Whisper is via the command line. The turbo model is used by default for optimal speed and accuracy:
You can transcribe multiple files at once:
Whisper supports various audio formats including MP3, WAV, FLAC, M4A, and more through FFmpeg.

Transcribing Non-English Audio

To transcribe audio in a specific language, use the --language parameter:

Translating to English

Whisper can translate speech from any supported language directly into English:
The turbo model is not trained for translation tasks. Use medium or large models for the best translation results.

Common CLI Options

View all available options:

Python API

Basic Transcription

Transcribe audio files programmatically using Whisper’s Python API:
The transcribe() method reads the entire file and processes the audio with a sliding 30-second window, performing autoregressive sequence-to-sequence predictions on each window.

Choosing a Model

Select different models based on your speed and accuracy requirements:

Checking Available Models

Advanced Usage: Language Detection and Decoding

For lower-level access to the model, use detect_language() and decode():

Device Selection

By default, Whisper uses CUDA if available, otherwise CPU. You can specify the device explicitly:

Complete Examples

1

Transcribe a Podcast Episode

2

Translate Foreign Language Audio

3

Batch Process Multiple Files

Output Format

The transcribe() method returns a dictionary containing:
  • text: The full transcribed text
  • segments: List of segments with timestamps
  • language: Detected or specified language

Performance Tips

Choose the Right Model

Use turbo for the best balance of speed and accuracy. Use tiny or base for real-time applications.

Use GPU Acceleration

Ensure PyTorch is installed with CUDA support for 10-20x faster transcription on NVIDIA GPUs.

Batch Processing

Load the model once and reuse it for multiple files to avoid repeated model loading overhead.

English-only Models

Use .en models (e.g., base.en) for better accuracy when transcribing English-only content.

Next Steps

Explore Advanced Features

Learn about word-level timestamps, language detection, and custom decoding options

View All Languages

Check the tokenizer.py file for the complete list of 99+ supported languages