diff dictation/transcriber.py @ 280:49e9e591c9bb

Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
author MrJuneJune <me@mrjunejune.com>
date Tue, 18 Aug 2026 19:14:53 -0700
parents 78699f810817
children
line wrap: on
line diff
--- a/dictation/transcriber.py	Mon Aug 17 22:22:36 2026 -0700
+++ b/dictation/transcriber.py	Tue Aug 18 19:14:53 2026 -0700
@@ -49,10 +49,10 @@
             loop = asyncio.get_running_loop()
             self._model = await loop.run_in_executor(
                 self._executor,
-                self._load,
+                self._load_and_warmup,
             )
 
-    def _load(self):
+    def _load_and_warmup(self):
         from faster_whisper import WhisperModel
 
         if not (self._model_dir / "model.bin").is_file():
@@ -60,12 +60,25 @@
                 f"Model not found at {self._model_dir}. "
                 "Run: bazel run //dictation:download_model"
             )
-        return WhisperModel(
+        model = WhisperModel(
             str(self._model_dir),
             device="cuda",
             compute_type=self._compute_type,
             local_files_only=True,
         )
+        # Loading weights does not initialize all CUDA kernels. Execute and
+        # consume one short silent inference now so the user's first utterance
+        # does not pay the one-time GPU setup cost.
+        segments, _ = model.transcribe(
+            np.zeros(8000, dtype=np.float32),
+            beam_size=1,
+            best_of=1,
+            condition_on_previous_text=False,
+            vad_filter=False,
+            without_timestamps=True,
+        )
+        list(segments)
+        return model
 
     async def transcribe(
         self,
@@ -89,10 +102,11 @@
     ) -> Transcript:
         segments, info = self._model.transcribe(
             samples,
-            beam_size=5 if final else 1,
-            best_of=5 if final else 1,
+            beam_size=1,
+            best_of=1,
             condition_on_previous_text=False,
             vad_filter=False,
+            without_timestamps=True,
         )
         text = "".join(segment.text for segment in segments).strip()
         return Transcript(