diff dictation/main.py @ 282:6bd4a3990696 default tip

Add cross-platform canvas orchestration and typed composer Enable native ARM dependencies, macOS Copilot orchestration, portable service supervision, CPU dictation, and a shared N-key speak-or-type composer. Co-authored-by: Copilot <[email protected]> Copilot-Session: f68442b1-fa8f-46a0-9689-81710613bbd4
author MrJuneJune <me@mrjunejune.com>
date Thu, 20 Aug 2026 20:45:25 -0700
parents 78699f810817
children
line wrap: on
line diff
--- a/dictation/main.py	Tue Aug 18 22:18:15 2026 -0700
+++ b/dictation/main.py	Thu Aug 20 20:45:25 2026 -0700
@@ -37,20 +37,24 @@
 def preflight(config: DictationConfig) -> None:
     import ctranslate2
 
-    compute_types = sorted(ctranslate2.get_supported_compute_types("cuda"))
+    compute_types = sorted(
+        ctranslate2.get_supported_compute_types(config.device)
+    )
     if config.compute_type not in compute_types:
         raise RuntimeError(
-            f"{config.compute_type} is unsupported on CUDA; "
+            f"{config.compute_type} is unsupported on {config.device}; "
             f"available: {', '.join(compute_types)}"
         )
     result = {
-        "cudaDeviceCount": ctranslate2.get_cuda_device_count(),
+        "device": config.device,
         "computeTypes": compute_types,
         "selectedComputeType": config.compute_type,
         "modelDir": str(config.model_dir),
         "modelPresent": (config.model_dir / "model.bin").is_file(),
     }
-    if result["cudaDeviceCount"] < 1:
+    if config.device == "cuda":
+        result["cudaDeviceCount"] = ctranslate2.get_cuda_device_count()
+    if config.device == "cuda" and result["cudaDeviceCount"] < 1:
         raise RuntimeError("CTranslate2 did not detect a CUDA device")
     print(json.dumps(result, indent=2))
 
@@ -60,6 +64,7 @@
 
     transcriber = FasterWhisperTranscriber(
         config.model_dir,
+        config.device,
         config.compute_type,
     )
     try: