diff --git a/src/voice_dictation/core/model_manager.py b/src/voice_dictation/core/model_manager.py index d7b4427..903a396 100644 --- a/src/voice_dictation/core/model_manager.py +++ b/src/voice_dictation/core/model_manager.py @@ -3,6 +3,7 @@ from __future__ import annotations import hashlib +import shutil import sys import threading from collections.abc import Callable, Iterator @@ -171,6 +172,8 @@ class ModelManager: with self._lock(model_id): if self.is_installed(model_id): return path + if shutil.disk_usage(self.models_dir).free < spec.size + 16 * 1024 * 1024: + raise ModelError("Недостаточно свободного места для скачивания модели") partial = path.with_suffix(".bin.part") if partial.is_symlink(): raise ModelError("Временный путь модели не должен быть символической ссылкой") diff --git a/src/voice_dictation/ui/recognition_tab.py b/src/voice_dictation/ui/recognition_tab.py index 732414e..b9c70b2 100644 --- a/src/voice_dictation/ui/recognition_tab.py +++ b/src/voice_dictation/ui/recognition_tab.py @@ -23,7 +23,7 @@ def build_recognition_tab( """Build controls; all widget updates stay on the Tk main thread.""" config = store.load() manager = ModelManager(paths.models_dir) - labels = {f"{m.name} — {m.size_bytes / 1048576:.0f} МБ": m.id for m in CATALOG} + labels = {m.name: m.id for m in CATALOG} initial_label = next( (k for k, v in labels.items() if v == config.local_model), next(iter(labels)) ) @@ -42,7 +42,9 @@ def build_recognition_tab( justify="left", wraplength=620, ).pack(anchor="w", padx=12, pady=8) - ctk.CTkLabel(parent, text="Локальная модель (Whisper):").pack(anchor="w", padx=12) + ctk.CTkLabel( + parent, text="Локальная модель (Whisper; только CPU/Metal, macOS arm64 beta):" + ).pack(anchor="w", padx=12) ctk.CTkOptionMenu(parent, values=list(labels), variable=selected, width=460).pack( anchor="w", padx=12, pady=6 ) diff --git a/tests/unit/test_local_pipeline.py b/tests/unit/test_local_pipeline.py index c618913..8822bc1 100644 --- a/tests/unit/test_local_pipeline.py +++ b/tests/unit/test_local_pipeline.py @@ -145,3 +145,20 @@ def test_local_long_wav_splits_without_ffmpeg(tmp_paths): with wave.open(str(chunk.path), "rb") as audio: assert audio.getnframes() / audio.getframerate() <= 60.001 orchestrator.shutdown() + + +def test_checkpoint_model_change_is_rejected(tmp_paths): + from voice_dictation.core.models import RecordingResult + + engine = FakeTranscriber() + config = Config(transcription_backend="local", paste_delay_ms=0) + orchestrator = _make_orchestrator(tmp_paths, transcriber=engine, config=config) + source = orchestrator._session_store.create() + source.write_bytes(b"audio") + recording = RecordingResult(source, 2) + orchestrator._transcribe_session(recording, config) + with pytest.raises(TranscriptionError, match="изменились"): + orchestrator._transcribe_session( + recording, Config(transcription_backend="local", local_model="whisper-small") + ) + orchestrator.shutdown()