Skip to main content

A library for transcribing audio files using Whisper models

Project description

Whisper Transcriber

A Python library for transcribing audio files using Whisper models with intelligent silence detection and segmentation.

Installation

pip install whisper-transcriber

Requirements

  • Python 3.7 or higher
  • ffmpeg and ffprobe installed on your system

Features

  • Intelligent silence detection for natural segmentation
  • Adaptive audio analysis for optimal threshold detection
  • High-quality transcription using Whisper models
  • Support for various audio formats
  • Optional SRT subtitle output

Usage

Command Line

# Basic usage
whisper-transcribe audio_file.mp3

# Advanced usage
whisper-transcribe audio_file.mp3 -m openai/whisper-small \
  --min-segment 5 \
  --max-segment 15 \
  --silence-duration 0.2 \
  --sample-rate 16000 \
  --batch-size 8 \
  --normalize \
  --hf-token YOUR_HF_TOKEN \
  --no-timestamps

Available Arguments:

  • input: Input audio file or directory (required)
  • -o, --output: Output file path (optional)
  • -m, --model: Whisper model to use (default: openai/whisper-small)
  • --hf-token: HuggingFace API token
  • --min-segment: Minimum segment length in seconds (default: 5)
  • --max-segment: Maximum segment length in seconds (default: 15)
  • --silence-duration: Minimum silence duration in seconds (default: 0.2)
  • --sample-rate: Audio sample rate (default: 16000)
  • --batch-size: Batch size for transcription (default: 8)
  • --normalize: Normalize audio volume
  • --no-text-normalize: Skip text normalization
  • --no-timestamps: Don't print timestamps during processing

Python Library

from whisper_transcriber import WhisperTranscriber

# Initialize the transcriber
transcriber = WhisperTranscriber(model_name="openai/whisper-small", hf_token="YOUR_HF_TOKEN")

# Transcribe an audio file
results = transcriber.transcribe(
    "audio_file.mp3",
    min_segment=5,
    max_segment=15,
    silence_duration=0.2,
    sample_rate=16000,
    batch_size=8,
    normalize=True,
    normalize_text=True,
    print_timestamps=True
)

# Optionally save to an SRT file
# If you want to save the transcription, provide an output path
results = transcriber.transcribe(
    "audio_file.mp3",
    output="transcript.srt"
)

# Access the transcription results
for i, segment in enumerate(results):
    print(f"Segment {i+1}: {segment['transcript']}")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whisper_transcriber-0.1.6.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whisper_transcriber-0.1.6-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file whisper_transcriber-0.1.6.tar.gz.

File metadata

  • Download URL: whisper_transcriber-0.1.6.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for whisper_transcriber-0.1.6.tar.gz
Algorithm Hash digest
SHA256 1c246a69e1bf50652e8a85d5b8f78f3fee1db8c0e2689fc21849bd7dae966d53
MD5 2304fd99df4faa680f61c687c98371f1
BLAKE2b-256 ddb5eabcdcddb79f257511a5f4ecc401d1f5aa0ff13b40d2f3ed494c779d154b

See more details on using hashes here.

File details

Details for the file whisper_transcriber-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for whisper_transcriber-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c675f3f53b077fd6103422f3b2a2d288309b22e724598eac8f53e2445267497d
MD5 bda81966c51373726f4ce56d88ac2473
BLAKE2b-256 4deb84777765c6ba89a75e32ac96ee8ce811ff2e2240238de2721d7642261026

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page