feat: 增加 NVIDIA 动态库依赖并默认自动选择计算类型

This commit is contained in:
cat-shark
2026-08-13 22:01:42 +08:00
parent 206275f7d6
commit 812d276998
4 changed files with 60 additions and 1 deletions
+17
View File
@@ -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: