Metadata-Version: 2.2
Name: distil-whisper-fastrtc
Version: 0.1.0
Summary: Distil-Whisper wrapper for FastRTC speech-to-text
Author-email: Codeblockz <ryan.a.ellis.1@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/Codeblockz/distil-whisper-FastRTC
Project-URL: Bug Tracker, https://github.com/Codeblockz/distil-whisper-fastrtc/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20.0
Requires-Dist: torch>=1.10.0
Requires-Dist: transformers>=4.30.0
Requires-Dist: accelerate>=0.20.0
Requires-Dist: click>=8.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.0.0; extra == "dev"
Provides-Extra: audio
Requires-Dist: librosa>=0.9.0; extra == "audio"

# Distil-Whisper for FastRTC

A PyPI package that wraps Hugging Face's Distil-Whisper model for speech-to-text (STT) transcription, compatible with the FastRTC STTModel protocol.

## Installation

```bash
pip install distil-whisper-fastrtc
```

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

```bash
pip install distil-whisper-fastrtc[audio]
```

For development:

```bash
pip install distil-whisper-fastrtc[dev]
```

## Usage

### Basic Usage

```python
from distil_whisper_fastrtc 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:

```python
from distil_whisper_fastrtc 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

```python
from fastrtc.backend.fastrtc.speech_to_text import STTModel
from distil_whisper_fastrtc import DistilWhisperSTT

# Create the model
whisper_model = DistilWhisperSTT()

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

## Available Models

You can choose from different model sizes:

- `distil-whisper/distil-small.en` (default, English only, fastest)
- `distil-whisper/distil-medium.en` (English only, better quality)
- `distil-whisper/distil-large-v2` (Multilingual, highest quality)
- `distil-whisper/distil-large-v3` (Latest version, best quality)

Example:
```python
from distil_whisper_fastrtc import get_stt_model

# Choose a larger model
model = get_stt_model("distil-whisper/distil-large-v2")
```

## Advanced Configuration

You can configure the model with various parameters:

```python
from distil_whisper_fastrtc import DistilWhisperSTT

# Configure with specific device and precision
model = DistilWhisperSTT(
    model="distil-whisper/distil-medium.en",
    device="cuda",  # Use GPU if available
    dtype="float16"  # Use half precision for faster inference
)
```

## Requirements

- Python 3.8+
- PyTorch 1.10+
- transformers 4.30+
- numpy 1.20+
- accelerate 0.20+ (for faster inference)
- librosa 0.9+ (optional, for audio file loading)

## Development

Clone the repository and install in development mode:

```bash
git clone https://github.com/yourusername/distil-whisper-fastrtc.git
cd distil-whisper-fastrtc
pip install -e ".[dev,audio]"
```

Run tests:

```bash
pytest tests/
```

## License

MIT
