Add Test & Download button for diarization model, clickable links

- Add diarize.download IPC handler that downloads the pyannote model
  and returns user-friendly error messages (missing license, bad token)
- Add download_diarize_model Tauri command
- Add "Test & Download Model" button in Speakers settings tab
- Update instructions to list both required model licenses
  (speaker-diarization-3.1 AND segmentation-3.0)
- Make all HuggingFace URLs clickable (opens in system browser)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 18:21:42 -08:00
parent baf820286f
commit a3612c986d
5 changed files with 186 additions and 10 deletions

View File

@@ -88,6 +88,57 @@ def make_diarize_handler() -> HandlerFunc:
return handler
def make_diarize_download_handler() -> HandlerFunc:
"""Create a handler that downloads/validates the diarization model."""
def handler(msg: IPCMessage) -> IPCMessage:
payload = msg.payload
hf_token = payload.get("hf_token")
try:
from pyannote.audio import Pipeline
print("[sidecar] Downloading diarization model...", file=sys.stderr, flush=True)
pipeline = Pipeline.from_pretrained(
"pyannote/speaker-diarization-3.1",
token=hf_token,
)
print("[sidecar] Diarization model downloaded successfully", file=sys.stderr, flush=True)
return IPCMessage(
id=msg.id,
type="diarize.download.result",
payload={"ok": True},
)
except Exception as e:
error_msg = str(e)
# Make common errors more user-friendly
if "403" in error_msg and "gated" in error_msg.lower():
# Extract which model needs access
if "segmentation" in error_msg:
error_msg = (
"Access denied for pyannote/segmentation-3.0. "
"Please visit huggingface.co/pyannote/segmentation-3.0 "
"and accept the license agreement."
)
elif "speaker-diarization" in error_msg:
error_msg = (
"Access denied for pyannote/speaker-diarization-3.1. "
"Please visit huggingface.co/pyannote/speaker-diarization-3.1 "
"and accept the license agreement."
)
else:
error_msg = (
"Access denied. Please accept the license agreements at: "
"huggingface.co/pyannote/speaker-diarization-3.1 and "
"huggingface.co/pyannote/segmentation-3.0"
)
elif "401" in error_msg:
error_msg = "Invalid token. Please check your HuggingFace token."
return error_message(msg.id, "download_error", error_msg)
return handler
def make_pipeline_handler() -> HandlerFunc:
"""Create a full pipeline handler (transcribe + diarize + merge)."""
from voice_to_notes.services.pipeline import PipelineService, pipeline_result_to_payload

View File

@@ -15,6 +15,7 @@ from voice_to_notes.ipc.handlers import ( # noqa: E402
HandlerRegistry,
hardware_detect_handler,
make_ai_chat_handler,
make_diarize_download_handler,
make_diarize_handler,
make_export_handler,
make_pipeline_handler,
@@ -32,6 +33,7 @@ def create_registry() -> HandlerRegistry:
registry.register("transcribe.start", make_transcribe_handler())
registry.register("hardware.detect", hardware_detect_handler)
registry.register("diarize.start", make_diarize_handler())
registry.register("diarize.download", make_diarize_download_handler())
registry.register("pipeline.start", make_pipeline_handler())
registry.register("export.start", make_export_handler())
registry.register("ai.chat", make_ai_chat_handler())