feat: 增加 NVIDIA 动态库依赖并默认自动选择计算类型
This commit is contained in:
@@ -15,7 +15,10 @@ class FakeSegment:
|
||||
|
||||
|
||||
class FakeWhisperModel:
|
||||
instances: list[tuple[tuple, dict]] = []
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
FakeWhisperModel.instances.append((args, kwargs))
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
|
||||
@@ -54,6 +57,7 @@ def test_format_timestamp() -> None:
|
||||
|
||||
|
||||
def test_success(tmp_path, monkeypatch) -> None:
|
||||
FakeWhisperModel.instances.clear()
|
||||
_install_fake_whisper(monkeypatch)
|
||||
(tmp_path / "audio.wav").write_bytes(b"fake")
|
||||
response = invoke(_request(tmp_path))
|
||||
@@ -61,6 +65,19 @@ def test_success(tmp_path, monkeypatch) -> None:
|
||||
content = Path(response.outputs["srt_uri"]).read_text(encoding="utf-8")
|
||||
assert "第一段" in content
|
||||
assert "01:00:00,500 --> 01:00:02,250" in content
|
||||
_, kwargs = FakeWhisperModel.instances[-1]
|
||||
assert kwargs["device"] == "auto"
|
||||
assert kwargs["compute_type"] == "auto"
|
||||
|
||||
|
||||
def test_compute_type_override(tmp_path, monkeypatch) -> None:
|
||||
FakeWhisperModel.instances.clear()
|
||||
_install_fake_whisper(monkeypatch)
|
||||
(tmp_path / "audio.wav").write_bytes(b"fake")
|
||||
response = invoke(_request(tmp_path, params={"language": "ja", "compute_type": "int8"}))
|
||||
assert response.status == "completed"
|
||||
_, kwargs = FakeWhisperModel.instances[-1]
|
||||
assert kwargs["compute_type"] == "int8"
|
||||
|
||||
|
||||
def test_model_raises(tmp_path, monkeypatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user