Skip to main content

A nearly-live implementation of OpenAI's Whisper.

Project description

whisper-live

A nearly-live implementation of OpenAI's Whisper.

This project is a real-time transcription application that uses the OpenAI Whisper model to convert speech input into text output. It can be used to transcribe both live audio input from microphone and pre-recorded audio files.

Unlike traditional speech recognition systems that rely on continuous audio streaming, we use voice activity detection (VAD) to detect the presence of speech and only send the audio data to whisper when speech is detected. This helps to reduce the amount of data sent to the whisper model and improves the accuracy of the transcription output.

Installation

  • Install PyAudio and ffmpeg
 bash setup.sh
  • Install whisper-live from pip
 pip install whisper-live

Getting Started

  • Run the server
 from whisper_live.server import TranscriptionServer
 server = TranscriptionServer()
 server.run("0.0.0.0", 9090)
  • On the client side

    • To transcribe an audio file:
      from whisper_live.client import TranscriptionClient
      client = TranscriptionClient(
        "localhost",
        9090,
        is_multilingual=False,
        lang="en",
        translate=False,
        model_size="small"
      )
    
      client("tests/jfk.wav")
    

    This command transcribes the specified audio file (audio.wav) using the Whisper model. It connects to the server running on localhost at port 9090. It can also enable the multilingual feature, allowing transcription in multiple languages. The language option specifies the target language for transcription, in this case, English ("en"). The translate option should be set to True if we want to translate from the source language to English and False if we want to transcribe in the source language.

    • To transcribe from microphone:
      from whisper_live.client import TranscriptionClient
      client = TranscriptionClient(
        "localhost",
        9090,
        is_multilingual=True,
        lang="hi",
        translate=True,
        model_size="small"
      )
      client()
    

    This command captures audio from the microphone and sends it to the server for transcription. It uses the multilingual option with hi as the selected language, enabling the multilingual feature and specifying the target language and task. We use whisper small by default but can be changed to any other option based on the requirements and the hardware running the server.

    • To transcribe from a HLS stream:
      client = TranscriptionClient(host, port, is_multilingual=True, lang="en", translate=False) 
      client(hls_url="http://as-hls-ww-live.akamaized.net/pool_904/live/ww/bbc_1xtra/bbc_1xtra.isml/bbc_1xtra-audio%3d96000.norewind.m3u8") 
    

    This command streams audio into the server from a HLS stream. It uses the same options as the previous command, enabling the multilingual feature and specifying the target language and task.

Transcribe audio from browser

  • Run the server
 from whisper_live.server import TranscriptionServer
 server = TranscriptionServer()
 server.run("0.0.0.0", 9090)

This would start the websocket server on port 9090.

Chrome Extension

Firefox Extension

Whisper Live Server in Docker

  • GPU
 docker build . -t whisper-live -f docker/Dockerfile.gpu
 docker run -it --gpus all -p 9090:9090 whisper-live:latest
  • CPU
 docker build . -t whisper-live -f docker/Dockerfile.cpu
 docker run -it -p 9090:9090 whisper-live:latest

Note: By default we use "small" model size. To build docker image for a different model size, change the size in server.py and then build the docker image.

Future Work

  • Add translation to other languages on top of transcription.
  • TensorRT backend for Whisper.

Contact

We are available to help you with both Open Source and proprietary AI projects. You can reach us via the Collabora website or vineet.suryan@collabora.com and marcus.edel@collabora.com.

Citations

@article{Whisper
  title = {Robust Speech Recognition via Large-Scale Weak Supervision},
  url = {https://arxiv.org/abs/2212.04356},
  author = {Radford, Alec and Kim, Jong Wook and Xu, Tao and Brockman, Greg and McLeavey, Christine and Sutskever, Ilya},
  publisher = {arXiv},
  year = {2022},
}
@misc{Silero VAD,
  author = {Silero Team},
  title = {Silero VAD: pre-trained enterprise-grade Voice Activity Detector (VAD), Number Detector and Language Classifier},
  year = {2021},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/snakers4/silero-vad}},
  commit = {insert_some_commit_here},
  email = {hello@silero.ai}
}

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-live-0.0.11.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

whisper_live-0.0.11-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file whisper-live-0.0.11.tar.gz.

File metadata

  • Download URL: whisper-live-0.0.11.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for whisper-live-0.0.11.tar.gz
Algorithm Hash digest
SHA256 4d5d02593d21fc32d5573ec78a60b8d0b24013b4a0e511ca0f3f7e6b9e007dc6
MD5 c468e2ee48ce2d8494469d6cf5cae85f
BLAKE2b-256 77524828c980a9df282ceb971586e7a99d7cb97d3f163308ef5e392303a05475

See more details on using hashes here.

File details

Details for the file whisper_live-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: whisper_live-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for whisper_live-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e682104facc9aebada902e3f8d95d9c108b4d2174c514df0eb74c985834a9c18
MD5 a90ae695eed40aa3520bc6e3c6254c40
BLAKE2b-256 f3b7795b3f2d940f1d1ef6e90bef4d5b2a6799c61068c330d73e4225c975bc47

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