Commit Graph

38 Commits

Author SHA1 Message Date
Aaron Boxer c5ec7f4a99 Add reconnect logic to WebSocket client
- New params: max_retries (default 0), retry_delay (default 5s)
- On unexpected close, retries up to max_retries times
- Does not retry on server_error (server rejected connection)
- Extracted _create_websocket() helper for reuse
- Added 4 unit tests for reconnect behavior
2026-05-26 05:45:37 -04:00
Aaron Boxer 8396763444 fix: set proper mock_info attributes in SSE streaming tests
MagicMock auto-attributes are not JSON serializable. Set language,
language_probability, and duration explicitly. Also exclude metadata
events from segment count assertion.
2026-05-25 09:44:21 -04:00
Aaron Boxer 8ac98dceec feat: add SSE streaming for REST transcription endpoint
- stream=true now returns text/event-stream with per-segment SSE events
- Each segment yields 'data: {json}' followed by 'data: [DONE]'
- Error events streamed as 'data: {"error": ...}'
- Temp files cleaned up in finally block
- 5 new tests in test_server_extended.py (183 total passing)
2026-05-25 09:44:21 -04:00
Aaron Boxer 4e31f8c61b Add word-level timestamps and confidence scores
- New word_timestamps option (default False) in client handshake
- When enabled, each segment includes 'words' array with per-word
  start/end times and probability scores
- Wired through entire pipeline: client → server → backend → transcribe()
- Words include timestamp_offset for accurate absolute times
- REST API already supported word timestamps; now WebSocket does too
- Added 9 unit tests for word timestamp extraction and formatting
2026-05-15 10:35:27 -04:00
Aaron Boxer 18b897277f Add real-time speaker diarization support
- New whisper_live/diarization.py: SpeakerDiarizer with online clustering
- Uses pyannote.audio speaker embeddings (optional dependency)
- Cosine similarity threshold for speaker matching (default 0.55)
- Running average embedding update for speaker stability
- Configurable max_speakers limit (default 10)
- Client options: enable_diarization, max_speakers
- Segments include 'speaker' field when diarization is active
- Graceful fallback: logs warning if pyannote not installed
- Added 12 unit tests (mock-based, no GPU required)
2026-05-13 10:50:59 -04:00
Aaron Boxer 3d63e82571 fix: add skip decorator to TestStartMetricsServer for CI without prometheus_client 2026-05-13 10:45:40 -04:00
Aaron Boxer ced4bdb737 feat: add Prometheus metrics instrumentation
- New whisper_live/metrics.py with Counter, Gauge, Histogram metrics
- Track connections (opened/closed/rejected), transcription latency,
  audio processed, segments emitted, REST requests, and errors
- All metric helpers are no-ops when prometheus_client not installed
- --metrics_port CLI flag to expose /metrics endpoint (0 = disabled)
- Metrics integrated into server.py, base.py at key instrumentation points
- 17 new tests in tests/test_metrics.py (178 total passing)
2026-05-13 10:45:40 -04:00
Aaron Boxer 4210697ca6 Add custom vocabulary / hotwords support 2026-05-13 10:32:28 -04:00
Aaron Boxer a6147a6745 Replace os.system() in clear_screen() with ANSI escape codes
- Eliminates shell injection risk from os.system('clear'/'cls')
- Uses ANSI escape sequence \033[H\033[2J instead
- Removed unused os import
- Added test verifying ANSI codes are used
2026-04-17 09:31:00 -04:00
Aaron Boxer 18bce1864a Validate server parameters on startup
- max_clients must be >= 1
- max_connection_time must be > 0
- batch_max_size must be >= 1 (when batch enabled)
- batch_window_ms must be >= 0 (when batch enabled)
- Added 5 new tests for parameter validation
2026-04-17 09:30:19 -04:00
Aaron Boxer 9e5e4a9970 Bound transcript memory and translation queue size
- Add MAX_TRANSCRIPT_LENGTH (500) and MAX_TRANSLATION_QUEUE_SIZE (100)
  class constants to ServeClientBase
- Trim transcript and text lists after each update_segments() call
- Create translation queue with maxsize to prevent unbounded growth
- Added tests for _trim_transcript()
2026-04-17 09:29:38 -04:00
Aaron Boxer 81cdbbca95 Add thread safety to ClientManager with threading.Lock
- All ClientManager methods (add_client, get_client, remove_client,
  get_wait_time, is_server_full, is_client_timeout) now protected by
  a threading.Lock
- cleanup() called outside the lock to avoid holding it during I/O
- is_server_full() computes wait time inline under lock instead of
  calling get_wait_time() to avoid nested lock acquisition
- Added concurrent thread safety tests for add/remove and get operations
2026-04-17 09:27:37 -04:00
Aaron Boxer f5340ddf1e audio: add support for raw pcm input via server flag
fixes #
2026-04-17 09:21:06 -04:00
Aaron Boxer b1cd51ac8a CI: expand test suite coverage
these new test cover issues such as thread safety, VAD thresholding,
message routing, error handling etc. that weren't covered by existing
tests. Mocking is used to avoid dependencies on GPU, ONNX etc.
2026-04-17 09:05:34 -04:00
ianwh02 e7e78a7151 Add unit tests for BatchInferenceWorker 2026-03-09 16:18:36 +00:00
makaveli10 5ce401d4c6 Update test_client to expect translation args
Signed-off-by: makaveli10 <vineet.suryan@collabora.com>
2025-07-22 09:06:31 +00:00
makaveli10 bf6251e3b8 Fix max_client, max_connection_time failed tests
Signed-off-by: makaveli10 <vineet.suryan@collabora.com>
2025-07-21 23:09:16 +05:30
giubots 9cfd8f85b6 test: add new parameters to tests 2025-05-02 11:58:17 +02:00
makaveli10 c1ac71ada0 Refactor 🔨
Signed-off-by: makaveli10 <vineet.suryan@collabora.com>
2025-03-24 16:48:33 +05:30
makaveli10 8d89de22d8 Update tests to incorporate the completed boolean in segments
Signed-off-by: makaveli10 <suryanvineet47@gmail.com>
2024-11-05 18:12:09 +05:30
makaveli10 8b87a0562d Fix unittest to exposed client manager args
Signed-off-by: makaveli10 <suryanvineet47@gmail.com>
2024-10-28 17:01:06 +05:30
makaveli 7c7a446478 Fix: mock pyaudio for ci to pass the server tests 2024-03-15 12:29:32 +05:30
John Sichi c0f37c77e9 Remove camelcase 2024-03-10 20:49:17 +09:00
John Sichi 3b15dc76b4 Add support for processing same audio stream via multiple clients with different tasks. 2024-03-10 20:44:15 +09:00
makaveli10 b42ced9816 fix: tests for end of speech message while mocking pyaudio 2024-02-16 20:31:38 +05:30
makaveli10 4471665085 remove test audio from tests 2024-02-15 19:09:57 +05:30
makaveli10 c1420cba0d add tests for server exception handling 2024-02-15 12:16:58 +05:30
makaveli10 4db91eed66 update vad tests after refactor 2024-02-15 12:16:39 +05:30
makaveli10 9fbff47126 🔨 refactor whisper_live according to flake8 2024-02-09 13:45:13 +05:30
makaveli10 cb570d28ce add vad tests 2024-02-08 14:03:57 +05:30
makaveli10 4e5e086c38 add server tests 2024-02-08 14:03:39 +05:30
makaveli10 cf78d5d608 add client tests 2024-02-08 14:03:13 +05:30
makaveli 6071cc1cc5 Revert "Test pypi upload" 2024-02-08 12:23:15 +05:30
makaveli10 98399707a3 add pyaudio mock 2024-02-08 11:12:57 +05:30
makaveli10 567ceb1246 add pyaudio mock; refactor 🔨 2024-02-08 11:12:40 +05:30
makaveli10 84a97f5fdd remove whisper_live from patch to mock websocket 2024-02-07 23:47:29 +05:30
makaveli10 444ce63440 add unit tests 2024-02-07 23:33:24 +05:30
makaveli10 091f6179d4 add sample audio for testing 2023-12-15 02:23:13 +08:00