whisper.php  by CodeWithKyrian

PHP binding for local speech-to-text, leveraging whisper.cpp

created 8 months ago
334 stars

Top 83.3% on sourcepulse

GitHubView on GitHub
Project Summary

This PHP library provides local speech-to-text capabilities by binding to whisper.cpp, offering a high-performance solution for automatic speech recognition and transcription. It targets PHP developers needing to integrate advanced ASR into their applications without relying on cloud APIs, simplifying model management and audio processing.

How It Works

The library leverages PHP's Foreign Function Interface (FFI) extension to directly interact with the C++ whisper.cpp library. This approach allows for efficient execution of the ASR models locally. It includes utilities for automatically downloading whisper.cpp models and a built-in audio reader that handles resampling and format conversion, abstracting away much of the complexity of the underlying C++ implementation.

Quick Start & Requirements

  • Install via Composer: composer require codewithkyrian/whisper.php
  • Requires PHP 8.1+ with the FFI extension enabled.
  • Supported Platforms: Linux (x86_64, arm64), macOS (Apple Silicon, Intel), Windows (x86_64).
  • Initial run may have a slight delay as platform-specific shared libraries are downloaded.
  • Official Docs: https://github.com/CodeWithKyrian/whisper.php

Highlighted Details

  • Offers both low-level (mimicking C API) and high-level (simplified workflow) interfaces.
  • Features automatic model downloading from Hugging Face for supported model variants.
  • Supports various audio input formats (MP3, WAV, OGG, M4A) with automatic resampling to 16kHz.
  • Provides multiple output formats (TXT, VTT, SRT, CSV) and callback support for streaming/progress.

Maintenance & Community

  • Project is maintained by CodeWithKyrian.
  • Contributions are welcome.
  • No specific community links (Discord/Slack) are mentioned in the README.

Licensing & Compatibility

  • Licensed under the MIT License.
  • Permissive license suitable for commercial use and integration into closed-source applications.

Limitations & Caveats

The ModelLoader utility does not support quantized whisper.cpp models (e.g., q5, q8). Initial library use requires downloading shared libraries, which may add a small delay on the first execution.

Health Check
Last commit

6 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
1
Star History
15 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.