Skip to main content

Fast RTC Whisper CPP package

Project description

Whisper CPP for FastRTC

A PyPI package that wraps Whisper.cpp for speech-to-text (STT) transcription, compatible with the FastRTC STTModel protocol. This package provides efficient, CPU-based speech recognition using the optimized Whisper.cpp implementation.

Installation

pip install fastrtc-whisper-cpp

For audio file loading capabilities, install with the audio extras:

pip install "fastrtc-whisper-cpp[audio]"

For development:

pip install "fastrtc-whisper-cpp[dev]"

Usage

Basic Usage

from fastrtc_whisper_cpp import get_stt_model
import numpy as np

# Create the model (downloads from HF if not cached)
model = get_stt_model()

# Example: Create a sample audio array (actual audio would come from a file or mic)
sample_rate = 16000
audio_data = np.zeros(16000, dtype=np.float32)  # 1 second of silence

# Transcribe
text = model.stt((sample_rate, audio_data))
print(f"Transcription: {text}")

Loading Audio Files

If you've installed with the audio extras:

from fastrtc_whisper_cpp import get_stt_model, load_audio

# Load model
model = get_stt_model()

# Load audio file (automatically resamples to 16kHz)
audio = load_audio("path/to/audio.wav")

# Transcribe
text = model.stt(audio)
print(f"Transcription: {text}")

Using with FastRTC

from fastrtc_whisper_cpp import get_stt_model

# Create the model
whisper_model = get_stt_model()

# Use within FastRTC applications
# (Follow FastRTC documentation for integration details)

Available Models

The package supports various Whisper.cpp models with different sizes and quantization levels:

  • English-only models (faster, smaller):

    • tiny.en, tiny.en-q5_1, tiny.en-q8_0
    • base.en, base.en-q5_1, base.en-q8_0
    • small.en, small.en-q5_1, small.en-q8_0
    • medium.en, medium.en-q5_0, medium.en-q8_0
  • Multilingual models:

    • tiny, tiny-q5_1, tiny-q8_0
    • base, base-q5_1, base-q8_0
    • small, small-q5_1, small-q8_0
    • medium, medium-q5_0, medium-q8_0
    • large-v1
    • large-v2, large-v2-q5_0, large-v2-q8_0
    • large-v3, large-v3-q5_0
    • large-v3-turbo, large-v3-turbo-q5_0, large-v3-turbo-q8_0

Example:

from fastrtc_whisper_cpp import get_stt_model

# Choose a specific model
model = get_stt_model("medium.en-q8_0")

Advanced Configuration

You can configure the model with specific parameters:

from fastrtc_whisper_cpp import WhisperCppSTT

# Configure with specific model and models directory
model = WhisperCppSTT(
    model="medium.en",
    models_dir="/path/to/models"  # Optional custom models directory
)

Requirements

  • Python 3.10+
  • numpy
  • pywhispercpp
  • librosa (optional, for audio file loading)
  • click (for CLI features)

Development

Clone the repository and install in development mode:

git clone https://github.com/mahimairaja/fastrtc-whisper-cpp.git
cd fastrtc-whisper-cpp
pip install -e ".[dev,audio]"

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

fastrtc_whisper_cpp-0.1.0.tar.gz (830.1 kB view details)

Uploaded Source

Built Distribution

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

fastrtc_whisper_cpp-0.1.0-py3-none-any.whl (773.7 kB view details)

Uploaded Python 3

File details

Details for the file fastrtc_whisper_cpp-0.1.0.tar.gz.

File metadata

  • Download URL: fastrtc_whisper_cpp-0.1.0.tar.gz
  • Upload date:
  • Size: 830.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.27

File hashes

Hashes for fastrtc_whisper_cpp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44c891a6cabf31df333744c1337970b3d32a631f9d774512412ff8c6d7858fe8
MD5 4f1f6a7183be26564e93809a070cd327
BLAKE2b-256 748632ada2b56a98abeeab4879d93929f4364fad8a683af682db14e687419ebc

See more details on using hashes here.

File details

Details for the file fastrtc_whisper_cpp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastrtc_whisper_cpp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb66d9115c45e279b0aa7bf7d41c4632a13cfb57ca3019fbf4c9d9462d33cbb0
MD5 e7d192aa871cc3b6dcdd5079aa2600ba
BLAKE2b-256 ec74bc1ed24eb4c9c16a392d0672300c2985a69127d6fd51544cf51663477f61

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