Skip to main content

Real-time speech-to-text streaming with OpenAI Whisper

Project description

whisperpipe

Real-time, offline speech-to-text streaming powered by OpenAI Whisper

PyPI version Python License: MIT arXiv DOI

whisperpipe lets you stream microphone audio directly into OpenAI's Whisper model — locally, privately, and for free. No API keys, no internet, no subscriptions.

📖 Academic Backing: This repository contains the official implementation of our paper, WhisperPipe: A Resource-Efficient Streaming Architecture for Real-Time Automatic Speech Recognition. If you use whisperpipe in your research, please cite our paper as described in the Citation section.


Why whisperpipe?

Cloud ASR whisperpipe
Privacy Data sent to servers 100% local
Cost Pay-per-use Free
Offline No Yes
Latency Network dependent Local only

Features

  • Real-time transcription — continuous audio capture and live text output
  • Callback system — hook any function to receive transcribed text (LLM, logging, UI, etc.)
  • Pause / Resume — stop listening while your assistant responds, resume on demand
  • Multi-language — any language supported by Whisper
  • Device selection — choose which microphone to use
  • Thread-safe — designed for concurrent use
  • CUDA support — automatically uses GPU if available

Installation

pip install whisperpipe

Or for the latest version directly from GitHub:

pip install git+https://github.com/Erfan-ram/whisperpipe.git

System dependencies: PyAudio requires PortAudio. On Linux: sudo apt install portaudio19-dev, on macOS: brew install portaudio.


Quick Start

from whisperpipe import pipeStream
import time

transcriber = pipeStream(model="base", language="en")
transcriber.start_streaming()

print("Listening... Press Ctrl+C to stop")
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    transcriber.stop_streaming()

Usage Examples

With a Callback (LLM Integration)

Register any function to be called each time a sentence is finalized:

from whisperpipe import pipeStream
import time

def my_callback(text):
    print(f"Transcribed: {text}")
    # Send to your LLM, log it, update UI, etc.

transcriber = pipeStream(model="base", language="en")
transcriber.set_def_callback(my_callback)
transcriber.start_streaming()

try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    transcriber.stop_streaming()

Turn-based Conversation (Pause / Resume)

Pause listening while your assistant is speaking, then resume:

from whisperpipe import pipeStream
import time

transcriber = pipeStream(model="base", language="en")

def on_speech(text):
    transcriber.pause_streaming()          # Stop listening
    print(f"User: {text}")

    response = f"You said: {text}"         # Replace with your LLM call
    print(f"Assistant: {response}")

    transcriber.resume_streaming()         # Start listening again

transcriber.set_def_callback(on_speech)
transcriber.start_streaming()

try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    transcriber.stop_streaming()

For more complete examples including manual control and status checking, see example_usage.py.


Model Selection

Model Size Speed Accuracy Recommended for
tiny 75 MB Fastest Low Testing, prototyping
base 145 MB Fast Good General use
small 466 MB Medium Better Balanced performance
medium 1.5 GB Slow High High accuracy needed
large 3 GB Slowest Best Maximum accuracy

API Reference

pipeStream()

pipeStream(
    model="base",
    language="en",
    finalization_delay=10.0,
    processing_interval=1.0,
    buffer_duration_seconds=5.0,
    debug_mode=False
)
Parameter Type Default Description
model str "base" Whisper model to load
language str "en" Language code ("en", "fa", "es", ...)
finalization_delay float 10.0 Seconds of silence before finalizing a sentence
processing_interval float 1.0 How often (seconds) to process buffered audio
buffer_duration_seconds float 5.0 Audio buffer size in seconds
debug_mode bool False Print internal debug logs

Methods

Method Description
start_streaming() Start microphone capture and transcription
stop_streaming() Stop transcription
set_def_callback(fn) Register a callback — called with (text: str) on each finalized sentence. Pass None to clear.
pause_streaming() Temporarily pause audio processing
resume_streaming() Resume after a pause
is_running() Returns True if actively running
is_paused() Returns True if currently paused
input_devices() List available microphone devices with their IDs

Requirements

  • Python 3.9 – 3.12
  • openai-whisper
  • pyaudio
  • pynput
  • sounddevice
  • NumPy and PyTorch (installed automatically with Whisper)

License

MIT — see LICENSE

Authors

Erfan Ramezani · erfanramezany245@gmail.com
Mohammad Mahdi Giahi

Contributing

Pull requests are welcome. For major changes, please open an issue first.

Citation

We can share academic knowledge this way :

@misc{ramezani2026whisperpipe,
  title         = {WhisperPipe: A Resource-Efficient Streaming Architecture for Real-Time Automatic Speech Recognition},
  author        = {Erfan Ramezani and Mohammad Mahdi Giahi and Mohammad Erfan Zarabadipour and Amir Reza Yosefian and Hamid Ghadiri},
  year          = {2026},
  month         = apr,
  publisher     = {arXiv},
  eprint        = {2604.25611},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CL},
  doi           = {10.48550/arXiv.2604.25611},
  url           = {https://doi.org/10.48550/arXiv.2604.25611}
}

And the software repository:

@software{whisperpipe_code_2026,
  author       = {Erfan Ramezani and Mohammad Mahdi Giahi},
  title        = {WhisperPipe: Source Code and Implementation},
  month        = apr,
  year         = 2026,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.19646625},
  url          = {https://doi.org/10.5281/zenodo.19646625}
}

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

whisperpipe-0.1.2.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

whisperpipe-0.1.2-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file whisperpipe-0.1.2.tar.gz.

File metadata

  • Download URL: whisperpipe-0.1.2.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for whisperpipe-0.1.2.tar.gz
Algorithm Hash digest
SHA256 de16610a67d38525c7d81b27962de3bf8bc6cf5e05b1595e127f10246d9e17a7
MD5 6a29f268145e4210cdaf301a009429ff
BLAKE2b-256 d460549db49fa07e3ffead1d7c681d82a8e935e4e9f9361d3ef1e88bd77e3825

See more details on using hashes here.

Provenance

The following attestation bundles were made for whisperpipe-0.1.2.tar.gz:

Publisher: release.yaml on Erfan-ram/whisperpipe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file whisperpipe-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: whisperpipe-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for whisperpipe-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c33a87b0d1a996bf7fab31eb940824fe429d3e7312c9686a0619f1daad7e885
MD5 ff1b8aeb605bb5d9a5a3ee2dd3635367
BLAKE2b-256 a6434031b13fedb3c1999d19eec91dc82795e2ca379a231c5f5242147320b42f

See more details on using hashes here.

Provenance

The following attestation bundles were made for whisperpipe-0.1.2-py3-none-any.whl:

Publisher: release.yaml on Erfan-ram/whisperpipe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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