python-voiceio 1.9.1__py3-none-any.whl → 1.9.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-voiceio
3
- Version: 1.9.1
3
+ Version: 1.9.2
4
4
  Summary: Voice dictation for Linux. Speak → text, locally, instantly.
5
5
  Author: Hugo Montenegro
6
6
  License-Expression: MIT
@@ -1,12 +1,12 @@
1
- python_voiceio-1.9.1.dist-info/licenses/LICENSE,sha256=Gz61o8jFTAvZUZyB3nWDB3DQQVuipjfPkVu9W8hBHM0,1072
2
- voiceio/__init__.py,sha256=zLfYDL3qj0evR4WN5tYKfgr6-_YC5xhqrm09sbhWoQQ,22
1
+ python_voiceio-1.9.2.dist-info/licenses/LICENSE,sha256=Gz61o8jFTAvZUZyB3nWDB3DQQVuipjfPkVu9W8hBHM0,1072
2
+ voiceio/__init__.py,sha256=FTcek0yfdI0OEbhOiGIFqV7WG2mj3gjw9X-8TnopjBM,22
3
3
  voiceio/__main__.py,sha256=xT5QCGGreYMisHO7Lh_Y-xAQ2TOzG2D7npKknGNcWSY,53
4
4
  voiceio/app.py,sha256=5tqDibXeok_psz9ewKOD47ka6ErR_Y4LD3jpOd2zZMw,43650
5
5
  voiceio/audio_source.py,sha256=rR6NRtNzmZ8uqmNPxareBWTJmuBaOxIGI5QINR_l-qc,9102
6
6
  voiceio/backends.py,sha256=-rs1YhPblub4NjFb6qCD7Ih9FqBRXtPuvjVv9bQoQ1w,368
7
7
  voiceio/clipboard_read.py,sha256=7f5aX644Fiy2S6MXxADfSgRtvO3P1U-r_VkzEgWrwKQ,5376
8
8
  voiceio/commands.py,sha256=Jz-txXSw32Adf8B912M8CzQIh4UMmEKRCZBPXU4bBaU,6014
9
- voiceio/config.py,sha256=Pv8Wx_ieY4y6xUJqP6fLkpBzCsiuKNcW8G8ox0Eit2M,22971
9
+ voiceio/config.py,sha256=10TQpa-lo3TmHIpXScYpUr3AZUZ9tOsyc1B-T7hXnnk,22968
10
10
  voiceio/consent.py,sha256=3stv3iZvYl_Dt4GUe-GUVOHEGi-2fOl-QqF3pDjraS4,1862
11
11
  voiceio/context_terms.py,sha256=rbVzEoqahroWdkYqiOmn4PJVsl6ftk_PDa-lXdoTBvA,11747
12
12
  voiceio/corrections.py,sha256=IIRViwjL9kkMy26-1dd0DtTfT0Tiedn6pmmHoaeayMQ,10047
@@ -32,7 +32,7 @@ voiceio/quiet_audio.py,sha256=AapeuhrJwR20fsl-Ksgv4qpptrcQezk6A2_i4Kr18Ks,11451
32
32
  voiceio/recorder.py,sha256=E3YwZecJqd06GGoRSjFi2Q-7GoRzBkAMBGspKVkF9rc,16746
33
33
  voiceio/retention.py,sha256=5ydw2dJ2gTQ39BYdg3Bk4mk-KNJkJcGUKzssndYwdY8,6137
34
34
  voiceio/service.py,sha256=q4_Mk8m3KCG14CGZ468ZrFvNvyXuWSOjKFUjRnksgAI,16391
35
- voiceio/streaming.py,sha256=67hHvAQ7Z99iwtwy6BXPBPqE0q9mNpoP0Lhh8-RufIk,25968
35
+ voiceio/streaming.py,sha256=PZoyAUVDjzdZsqQy3_XXDLdbDk7GeRHXY47hLHxSKVA,27970
36
36
  voiceio/suggest.py,sha256=jX4bCpnddyrteKfRBPbnUgf-Rk5145LFaSTat0_Ll2E,4836
37
37
  voiceio/tokens.py,sha256=y9KBDgLukUMieO576rgyBn8qEQqElra66spQwoWXDXk,6321
38
38
  voiceio/ui.py,sha256=pwuH3zr9kMC7TovLwJwa3E3H8J5Fbt2VF4-DDTvqboQ,461
@@ -133,8 +133,8 @@ voiceio/typers/pynput_type.py,sha256=f3w131YWJfNGd4IAcWtuKd2Gcwu3467QwGW3OBUEXNI
133
133
  voiceio/typers/wtype.py,sha256=11vOAKHjMat-fITd4sUoUWwgniyVp65EbH3i4mL6Vhg,1762
134
134
  voiceio/typers/xdotool.py,sha256=OuT_zW_z07jSAqu9Cmn_gL1mJfQsiX62ecqFRvpAarQ,1332
135
135
  voiceio/typers/ydotool.py,sha256=oY5EXB-nI7PvxTL_5Tb3JjfvyhmLNYNnUFvkb1XUn_U,5978
136
- python_voiceio-1.9.1.dist-info/METADATA,sha256=8-ca8oLiqKgHtwOeWvM9oku34NdS2IZY2aD8Pyuq6h4,7519
137
- python_voiceio-1.9.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
138
- python_voiceio-1.9.1.dist-info/entry_points.txt,sha256=iDIDmhvQ3xeN_CWsFne1t9STZ08I25I_wp0xmde_vMs,94
139
- python_voiceio-1.9.1.dist-info/top_level.txt,sha256=piwtn309lD6uexQyXdZ-efAVBJF9y6Wfr48Z-8zkNhg,8
140
- python_voiceio-1.9.1.dist-info/RECORD,,
136
+ python_voiceio-1.9.2.dist-info/METADATA,sha256=WXmKdOKMoP9EdCj4LE6yGCHIw3U9Vl-3p8HzZLiDn40,7519
137
+ python_voiceio-1.9.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
138
+ python_voiceio-1.9.2.dist-info/entry_points.txt,sha256=iDIDmhvQ3xeN_CWsFne1t9STZ08I25I_wp0xmde_vMs,94
139
+ python_voiceio-1.9.2.dist-info/top_level.txt,sha256=piwtn309lD6uexQyXdZ-efAVBJF9y6Wfr48Z-8zkNhg,8
140
+ python_voiceio-1.9.2.dist-info/RECORD,,
voiceio/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.9.1"
1
+ __version__ = "1.9.2"
voiceio/config.py CHANGED
@@ -144,12 +144,12 @@ class OutputConfig:
144
144
  # On by default: nobody wants "um" in their notes. Set false for verbatim.
145
145
  remove_disfluencies: bool = True
146
146
  voice_input_prefix: str = "" # e.g. "[voice]" — empty disables
147
- # Incremental finalization: once the un-finalized audio tail grows past
148
- # this many seconds, it is cut at the nearest interior speech pause,
149
- # beam-decoded and frozen during recording, so interim passes and the
150
- # stop-time final decode only cover the short remaining tail. Smaller
151
- # chunks decode faster (less worker blocking) at slightly more boundary
152
- # risk. 0 disables (full re-decode at stop).
147
+ # Incremental finalization: during recording the audio is beam-decoded
148
+ # and frozen in chunks — at each speech pause the VAD reports, and,
149
+ # when no pause comes, once the un-finalized tail grows past this many
150
+ # seconds (cut at its quietest interior point) — so interim passes and
151
+ # the stop-time final decode only cover the short remaining tail.
152
+ # 0 disables both (full re-decode at stop).
153
153
  streaming_freeze_secs: float = 8.0
154
154
  # Mirror transcribed text to the system clipboard so it can be pasted:
155
155
  # "off" — never
voiceio/streaming.py CHANGED
@@ -46,6 +46,15 @@ _FREEZE_SILENCE_FLOOR = 1e-4 # digital silence is always quiet
46
46
  # spot beats re-decoding an ever-growing tail at stop (observed: 17 long
47
47
  # dictations never froze, one decoding 121s of audio after stop).
48
48
  _FREEZE_SEARCH_SECS = 8.0
49
+ # Pause freezes: when the recorder reports a speech pause (its VAD heard
50
+ # silence_duration of non-speech), the tail up to that pause is frozen as soon
51
+ # as it holds this much audio, rather than waiting for freeze_secs. Stop then
52
+ # decodes only the speech after the last pause instead of up to
53
+ # freeze_secs + search span of it.
54
+ _PAUSE_FREEZE_MIN_SECS = 4.0
55
+ # The pause is reported once the silence has lasted a while: cut this far
56
+ # before that point so the cut sits inside the silence, not at its edge.
57
+ _PAUSE_CUT_BACKOFF_SECS = 0.3
49
58
  # Whisper conditions on ~224 prompt tokens; more frozen context is wasted.
50
59
  _FREEZE_CONTEXT_CHARS = 400
51
60
 
@@ -197,6 +206,8 @@ class StreamingSession:
197
206
  # been beam-decoded into _frozen_raw and is never decoded again.
198
207
  # Interim and final passes only decode the tail after this offset.
199
208
  self._freeze_secs = freeze_secs
209
+ # Sample offset of the latest speech pause the recorder reported.
210
+ self._pause_at: int | None = None
200
211
  self._frozen_samples = 0
201
212
  self._frozen_raw = ""
202
213
  self._frozen_segments: list[dict] = []
@@ -318,7 +329,12 @@ class StreamingSession:
318
329
  return None
319
330
 
320
331
  def _on_vad_pause(self) -> None:
321
- """Called from audio thread on speech pause. Signals worker."""
332
+ """Called from audio thread on speech pause. Signals worker, and
333
+ remembers where the pause is: a clean place to freeze."""
334
+ recorder = self._recorder
335
+ audio = recorder.get_audio_so_far() if recorder is not None else None
336
+ if audio is not None:
337
+ self._pause_at = len(audio)
322
338
  self._pending.set()
323
339
 
324
340
  def _worker_loop(self) -> None:
@@ -353,7 +369,28 @@ class StreamingSession:
353
369
  context = self._frozen_raw[-_FREEZE_CONTEXT_CHARS:] if self._frozen_raw else None
354
370
  return self._bias.with_context(context)
355
371
 
356
- def _freeze_chunk(self, audio: np.ndarray, chunk: np.ndarray) -> None:
372
+ def _pause_cut(self, tail_len: int) -> int | None:
373
+ """Tail offset to freeze at: the latest reported speech pause, once
374
+ the speech before it is long enough to decode on its own."""
375
+ pause, self._pause_at = self._pause_at, None
376
+ if self._freeze_secs <= 0 or pause is None:
377
+ return None
378
+ # Cut inside the pause, not at its end: speech may resume right there.
379
+ cut = pause - self._frozen_samples - int(_PAUSE_CUT_BACKOFF_SECS * self._sample_rate)
380
+ if cut < _PAUSE_FREEZE_MIN_SECS * self._sample_rate or cut > tail_len:
381
+ return None
382
+ return cut
383
+
384
+ def _long_tail_cut(self, tail: np.ndarray) -> int | None:
385
+ """Tail offset to freeze at once the tail outgrows freeze_secs: its
386
+ quietest interior window (see _find_freeze_cut)."""
387
+ if self._freeze_secs <= 0 or len(tail) < self._freeze_secs * self._sample_rate:
388
+ return None
389
+ # Past the whole search span with no pause found: force a cut.
390
+ force = len(tail) >= (self._freeze_secs + _FREEZE_SEARCH_SECS) * self._sample_rate
391
+ return _find_freeze_cut(tail, self._sample_rate, self._freeze_secs, force=force)
392
+
393
+ def _freeze_chunk(self, audio: np.ndarray, chunk: np.ndarray, cut: str = "long") -> None:
357
394
  """Beam-decode `chunk` (the tail up to a pause cut) and freeze it.
358
395
 
359
396
  On decode failure the boundary is left untouched — the audio will be
@@ -375,6 +412,7 @@ class StreamingSession:
375
412
  self.trace.append({
376
413
  "t": round(time.monotonic() - self._t0, 2),
377
414
  "kind": "freeze",
415
+ "cut": cut,
378
416
  "frozen_secs": round(self._frozen_samples / self._sample_rate, 2),
379
417
  "tail_secs": round(len(chunk) / self._sample_rate, 2),
380
418
  "secs": round(t_decode, 3),
@@ -411,30 +449,31 @@ class StreamingSession:
411
449
  tail = audio[self._frozen_samples:]
412
450
  if not final and len(tail) < self._sample_rate * min_seconds:
413
451
  return # not enough new audio since the last freeze
414
- grown_secs = (len(audio) - self._last_decode_end) / self._sample_rate
415
- if not final and grown_secs < max(min_seconds, self._last_decode_secs):
416
- return # backpressure: don't decode faster than we can keep up
417
-
418
- # Freeze: once the tail is long enough, cut it at an interior speech
419
- # pause and beam-decode ONLY that chunk (its text is never decoded
420
- # again). The freeze pass does not touch the display — the interim
421
- # text already covers this audio; the next interim refreshes it.
422
- if (not final and self._freeze_secs > 0
423
- and len(tail) >= self._freeze_secs * self._sample_rate):
424
- # Past the whole search span with no pause found: force a cut.
425
- force = len(tail) >= (self._freeze_secs + _FREEZE_SEARCH_SECS) * self._sample_rate
426
- cut = _find_freeze_cut(tail, self._sample_rate, self._freeze_secs, force=force)
427
- if cut is not None:
428
- with self._freeze_lock:
429
- # Stop may have won the race for the lock and already
430
- # finalized from the current boundary.
431
- if not self._stop_event.is_set():
432
- self._freeze_pending_end = self._frozen_samples + cut
433
- try:
434
- self._freeze_chunk(audio, tail[:cut])
435
- finally:
436
- self._freeze_pending_end = None
437
- return
452
+
453
+ # Freeze: cut the tail at a speech pause and beam-decode ONLY that
454
+ # chunk (its text is never decoded again). The freeze pass does not
455
+ # touch the display — the interim text already covers this audio;
456
+ # the next interim refreshes it.
457
+ # A pause the recorder reported is frozen even under backpressure:
458
+ # it shrinks every later decode, the stop-time one included.
459
+ cut = None if final else self._pause_cut(len(tail))
460
+ reason = "pause"
461
+ if cut is None and not final:
462
+ grown_secs = (len(audio) - self._last_decode_end) / self._sample_rate
463
+ if grown_secs < max(min_seconds, self._last_decode_secs):
464
+ return # backpressure: don't decode faster than we can keep up
465
+ cut, reason = self._long_tail_cut(tail), "long"
466
+ if cut is not None:
467
+ with self._freeze_lock:
468
+ # Stop may have won the race for the lock and already
469
+ # finalized from the current boundary.
470
+ if not self._stop_event.is_set():
471
+ self._freeze_pending_end = self._frozen_samples + cut
472
+ try:
473
+ self._freeze_chunk(audio, tail[:cut], reason)
474
+ finally:
475
+ self._freeze_pending_end = None
476
+ return
438
477
 
439
478
  tail_text = ""
440
479
  tail_segments: list[dict] = []