Metadata-Version: 2.4
Name: fastpluggy-voice
Version: 0.1.15
Summary: FastPluggy voice plugin — WhisperX batch + sherpa-onnx live STT + pyannote diarization + Wyoming TCP. Owns the engine in-process.
Author: FastPluggy Team
License-Expression: MIT
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: FastPluggy>=0.4.115
Requires-Dist: loguru
Requires-Dist: sqlalchemy>=2.0
Requires-Dist: psycopg2-binary>=2.9
Requires-Dist: httpx>=0.27
Requires-Dist: torch
Requires-Dist: torchaudio
Requires-Dist: whisperx>=3.8.2
Requires-Dist: sherpa-onnx
Requires-Dist: pyannote.audio
Requires-Dist: huggingface_hub
Requires-Dist: wyoming
Requires-Dist: python-multipart
Requires-Dist: numpy
Provides-Extra: tests
Requires-Dist: pytest>=7.0; extra == "tests"
Requires-Dist: pytest-cov>=4.0; extra == "tests"
Requires-Dist: pytest-asyncio>=0.24; extra == "tests"
Requires-Dist: respx>=0.21; extra == "tests"
Requires-Dist: testcontainers[postgres]>=4.0; extra == "tests"
Provides-Extra: e2e
Requires-Dist: fastpluggy-cli; extra == "e2e"
Requires-Dist: playwright>=1.40.0; extra == "e2e"
Dynamic: license-file

# fastpluggy-voice

FastPluggy plugin that **owns** the voice engine — WhisperX batch + sherpa-onnx live + pyannote diarization + Wyoming TCP — in-process. Replaces the standalone `whisper-api` Docker container.

> **Status: feature-complete, not deployed.** Phases 3–5 (engine port, HTTP/WS routes,
> admin UI) have all shipped; the current version is the one in `pyproject.toml`.
> No instance runs today: the app that hosted the plugin was retired, and the standalone
> container it replaced has been removed as well.
>
> **Known issue:** transcription with diarization fails with a 500
> ([#5](https://gitlab.ggcorp.fr/open/fastpluggy/plugins/voice/-/issues/5)). Fix it before
> putting the plugin back in production.

## What this replaced

| Source | Became | Status |
|---|---|---|
| `whisper_api.py` (971 LOC standalone app) | `src/engine/` + `src/transports/` + `src/routers/` in this plugin | ✅ ported; the standalone app is removed |
| Its Docker Compose stack (whisper-api service) | A FastPluggy app embedding this plugin on a GPU host | ⏸️ that app was retired; nothing runs the plugin today |
| `plugins/audio_transcript` (faster-whisper engine + session UI) | `<fp-voice-button>` → `src/static/js/fp-voice-button.js`, sessions → `src/routers/admin/sessions.py`, model cache → `src/routers/admin/model_cache.py`, GPU widgets → `src/routers/admin/system.py` | ✅ migrated; that plugin is now **retired and archived** (2026-08-02) |

## Requirements

- GPU host with CUDA (production).
- Postgres reachable for transcription history + speaker enrollment.
- Wyoming TCP port `10300` free (Home Assistant integration).

## Install (dev)

```bash
cd plugins/voice
<venv>/bin/pip install -e ".[tests]"
```

## Configuration

Settings live on `VoiceSettings` (see `src/config.py`) — backed by the standard FastPluggy `BaseDatabaseSettings`. Defaults mirror the env-var contract of the standalone `whisper-api` container so a like-for-like migration only needs values copied across.

## Architecture

Engine startup happens in `VoicePlugin.on_load_complete` — model loads synchronously, Wyoming TCP server runs as a background `asyncio.create_task` on the FastPluggy event loop. Single-worker `ThreadPoolExecutor` serializes GPU access across HTTP / WS / Wyoming, mirroring how `whisper_api.py` does it today.

Worker-mode (`fast_pluggy.app is None`) skips engine init — the plugin is a no-op outside the HTTP process.

The engine is created once per process. `on_load_complete` also runs on every reload of the app
(settings saved, a plugin enabled or disabled): a reload keeps the running engine and Wyoming
server and only registers the `<fp-voice-button>` WebSocket handlers again. Engine settings,
`engine_enabled` included, apply at the next start. The handlers need `websocket_tool` (declared
in `optional_depends_on`, so it loads first); without it the plugin works without them.

## Layout

```
src/
├── plugin.py             # VoicePlugin(FastPluggyBaseModule)
├── config.py             # VoiceSettings
├── models.py             # Transcription, Speaker, SpeakerEmbedding, VoiceSession
├── engine/               # whisperx, sherpa-onnx, speakers, executor    (Phase 3)
├── transports/           # wyoming_server                                (Phase 3)
├── routers/              # api, speakers, stream, tts                    (Phase 4)
│   └── admin/            # UI routes (sessions, speakers, history, ...)  (Phase 5)
├── services/             # sessions, tts_proxy
├── static/               # JS (fp-voice-button, audio_ws), CSS
└── templates/            # admin UI pages
```
