feat(workers): whisper loader with CUDA detect + CPU fallback
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
23
workers/tests/test_model.py
Normal file
23
workers/tests/test_model.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from unittest.mock import patch, MagicMock
|
||||
from void_workers import model
|
||||
|
||||
|
||||
def test_model_returns_singleton(monkeypatch):
|
||||
m = MagicMock()
|
||||
monkeypatch.setattr(model, "_whisper_model", None)
|
||||
with patch("void_workers.model.cuda_available", return_value=False):
|
||||
with patch("faster_whisper.WhisperModel", return_value=m):
|
||||
a = model.whisper_model()
|
||||
b = model.whisper_model()
|
||||
assert a is b
|
||||
|
||||
|
||||
def test_transcribe_returns_joined_segments(monkeypatch):
|
||||
seg1 = MagicMock(text=" Hello world ")
|
||||
seg2 = MagicMock(text=" second line")
|
||||
fake_model = MagicMock()
|
||||
fake_model.transcribe.return_value = ([seg1, seg2], MagicMock())
|
||||
monkeypatch.setattr(model, "_whisper_model", fake_model)
|
||||
out = model.whisper_transcribe("/tmp/whatever.opus")
|
||||
assert "Hello world" in out
|
||||
assert "second line" in out
|
||||
Reference in New Issue
Block a user