python-voiceio 1.17.2__py3-none-any.whl → 1.18.0__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.17.2
3
+ Version: 1.18.0
4
4
  Summary: Voice dictation for Linux. Speak → text, locally, instantly.
5
5
  Author: Hugo Montenegro
6
6
  License-Expression: MIT
@@ -82,11 +82,14 @@ Install voiceio on this machine following https://voiceio.dev/llms.txt. Ask me w
82
82
  sudo apt install pipx build-essential python3-dev portaudio19-dev ibus gir1.2-ibus-1.0 python3-gi # Debian/Ubuntu
83
83
  sudo dnf install pipx gcc gcc-c++ make python3-devel portaudio-devel ibus ibus-libs python3-gobject # Fedora
84
84
  sudo pacman -S python-pipx base-devel portaudio ibus python-gobject # Arch
85
+ sudo emerge --ask media-libs/portaudio app-i18n/ibus dev-python/pygobject # Gentoo
85
86
 
86
- pipx install 'python-voiceio[desktop]'
87
+ pipx install 'python-voiceio[desktop]' # or: uv tool install 'python-voiceio[desktop]'
87
88
  voiceio setup # model, hotkey, autostart
88
89
  ```
89
90
 
91
+ `uvx` is fine for a quick try, but run `voiceio setup` from a `pipx` or `uv tool` install: uvx runs from uv's cache, which uv deletes on `uv cache clean`, and the autostart service would point there.
92
+
90
93
  **Or as a Debian/Ubuntu package** (new; bundles everything, nothing to compile):
91
94
 
92
95
  ```bash
@@ -1,5 +1,5 @@
1
- python_voiceio-1.17.2.dist-info/licenses/LICENSE,sha256=Gz61o8jFTAvZUZyB3nWDB3DQQVuipjfPkVu9W8hBHM0,1072
2
- voiceio/__init__.py,sha256=ZTulLPgBh4cnWgZEE-NU6oqIAg51m2VLZjl9bTHW2nw,23
1
+ python_voiceio-1.18.0.dist-info/licenses/LICENSE,sha256=Gz61o8jFTAvZUZyB3nWDB3DQQVuipjfPkVu9W8hBHM0,1072
2
+ voiceio/__init__.py,sha256=eOdR8Sg_yEJg0qk8bqKXxy1LJBKxzo3fV50mKHzE9zE,23
3
3
  voiceio/__main__.py,sha256=xT5QCGGreYMisHO7Lh_Y-xAQ2TOzG2D7npKknGNcWSY,53
4
4
  voiceio/announce.py,sha256=oqNJn1c4j5bTQ00-LXNWZ3_hIC9L9Lb3rkp0-LwkCfY,3798
5
5
  voiceio/app.py,sha256=tStX_aQyMhFK3NUFWvwowx0jW4a7szX6zkOoP7-lu60,49485
@@ -16,16 +16,17 @@ voiceio/display.py,sha256=ZGBNRjuvg3chkJjduyPJs4s5ZY5vqC_mcaov94PIPzo,5313
16
16
  voiceio/errorlog.py,sha256=e5UKVp4p-UBg0tTpcBREY5KoHMFZFJ9oNK3vOh8H6jw,7044
17
17
  voiceio/feedback.py,sha256=69Vepy2Z0gsDdpLzdLJbgrEHzSJm2luQ7yT4_nAnZCQ,9321
18
18
  voiceio/focus.py,sha256=PGj839UUZE7ZPwaiLDTAX3S8d_QjwaT4y6ugXyylL9M,4304
19
- voiceio/health.py,sha256=WB6j2Z_x7NmJaUdUcvnxGwvt1MXMBlxkOqGfkhJf2Cg,27948
19
+ voiceio/health.py,sha256=QYTmIk6GTLdRGorAFlfUbso2-fHBPo3EF7xt92bxRjg,27671
20
20
  voiceio/hints.py,sha256=wQPVie-zX-SFfz3C0YxL40_51SCkF1Xt8F1vwI_5yoY,1440
21
21
  voiceio/history.py,sha256=WNjfjakY8qwgRm3W6WBDlpS9CSgS8ecZ9RGGBZsW80w,5898
22
22
  voiceio/idle_audio.py,sha256=0GEbm0g-a2uVxIMWEKpaYus06mnrc8qvWr09a85FWS0,7225
23
+ voiceio/install_env.py,sha256=-r75IhF2ihp33drkHUVDeMCzBCvCafbjU7V2FjuC8As,6868
23
24
  voiceio/llm.py,sha256=s8nfahibR49OVFAulsXaoZ2kaaqGhVcxV26Ik3CtSis,9326
24
25
  voiceio/llm_api.py,sha256=4jJ5U1Dop-3uoM9RM3bjUMxB4kYNNjwKbOwIIj0ll3U,9390
25
26
  voiceio/mic_gain.py,sha256=lMSOz80-cb9X_ggShQttynjVRqcKd1tIUw9e64fEszM,4412
26
27
  voiceio/numbers.py,sha256=CXJtlMhmV6_9Z1FtKAF4-RXycw8voV-BYHPBpdw1I6Y,13571
27
28
  voiceio/pidlock.py,sha256=OZLNskUyv9_F3WgyHZWw8WmKt0W7ioxH6xgHitOwCww,1216
28
- voiceio/platform.py,sha256=glRFrS8KsyQTHbpvB42sEOQPdGr9H6ypjd415ziNZjs,22288
29
+ voiceio/platform.py,sha256=rf1pAZ9MTszRe6ZGw40PEvnXSPusFb2bssVwZWdeIso,25034
29
30
  voiceio/postcorrect.py,sha256=JN5l9xnyGfYq2_owSUwkJ513QiQQKxCrT3hjU5aJCpg,17322
30
31
  voiceio/postprocess.py,sha256=01ILYaPObF3LZ7oLdCZC1iFQfAFzzGayWFCjCU8RKz8,7121
31
32
  voiceio/power.py,sha256=mKiG5ioHbzgtW2S-OKGFOPzZFbG0HwUUyMn8kE5JRoQ,681
@@ -36,7 +37,7 @@ voiceio/quiet_audio.py,sha256=AapeuhrJwR20fsl-Ksgv4qpptrcQezk6A2_i4Kr18Ks,11451
36
37
  voiceio/recorder.py,sha256=3J42IETpTY68FHcFs4FetjxXgl7jdPbAMte5hcTxfrU,18763
37
38
  voiceio/report.py,sha256=DKuNhCAw5rZxnGy5WXIeJBEg83dRXvMGvkY2kQn1Suc,13255
38
39
  voiceio/retention.py,sha256=C_oAx7X8tIUDTFjIF6GWT_qFawiZ2HKTyfPz3hbiIRY,5994
39
- voiceio/service.py,sha256=I2DZBozfkBmUXmCOJ8lcHMpyFEa17hy4Sd92Za2erUs,18721
40
+ voiceio/service.py,sha256=0kUAJmpXifNzGeCy4ob2meVREdjnoI_En2qwJIxPBXI,19521
40
41
  voiceio/spool.py,sha256=k0rdBhDsocIoMa9xpo0GVFSyJ1CUCSSTtws8Sfw_ViA,4369
41
42
  voiceio/streaming.py,sha256=PZoyAUVDjzdZsqQy3_XXDLdbDk7GeRHXY47hLHxSKVA,27970
42
43
  voiceio/suggest.py,sha256=jX4bCpnddyrteKfRBPbnUgf-Rk5145LFaSTat0_Ll2E,4836
@@ -50,7 +51,7 @@ voiceio/wordfreq.py,sha256=AxmVgpQRfm2YAYQpHCRRrBUTpa12y_ngiFNScrGr4GM,3543
50
51
  voiceio/cli/__init__.py,sha256=nUgKtKbcVPoOyi68co9YPyfFSiwobfA7tY9ZZdTZ33k,9919
51
52
  voiceio/cli/configcmd.py,sha256=YF7t-LkwEYEGH4qcO86xehWVX0LvltqxjDFpMF5ljjA,2858
52
53
  voiceio/cli/corrections.py,sha256=OBjgiOhtWlTQpQq0HLAvk5-EfKJ7NNt-hnNBHm7obEc,4247
53
- voiceio/cli/doctor.py,sha256=yEK2JfSCgWd7u1aG8MW2EMdJLzj5gLdOg2w9h6aOLn4,11524
54
+ voiceio/cli/doctor.py,sha256=LZm_jmXDZ_Bf8sS9QV0UtwQgQYwFXKgfSI8Tzi4MAIk,13349
54
55
  voiceio/cli/history.py,sha256=7FvEEgdw8jf5XXvC7-4S7iIpcjBbn7dx4czIijg61C0,2597
55
56
  voiceio/cli/learn.py,sha256=RtGzDgosTW0q3poHjfZ2ZHiljvWBcGxa-xD6XERSkUU,38001
56
57
  voiceio/cli/models.py,sha256=3WFgljWKPXl706P2u3HvLZOKFQGWHMhV63kBNl_59QI,7732
@@ -106,10 +107,10 @@ voiceio/setup/__init__.py,sha256=cXNo-LYhkoVA6pEKcnaAKEGma_A9Aiqffa3VRvV6Jm8,430
106
107
  voiceio/setup/configfile.py,sha256=bDJdEhYlETjyXasVkCdfYTDq63ii9Dkh_Ywv5OT-P6M,4867
107
108
  voiceio/setup/extras.py,sha256=NGk_uAWl4GQAPwRfw_0nEPsPvma7ics9DnZqjoHgCUY,9685
108
109
  voiceio/setup/hotkey.py,sha256=xlDp2vWzsF73wbpvPSrwaqgjtiWnv294nzjlvHy0Ets,6473
109
- voiceio/setup/noninteractive.py,sha256=dQ9_8Wc2CEOgjNJvFErLHpmb0aLbgwIl6WTGFhR9Uvw,10890
110
+ voiceio/setup/noninteractive.py,sha256=__kYKPchvv_qYMik6nGlpBx3llqOgU5i2Y0Xs8yJaQg,11284
110
111
  voiceio/setup/speech.py,sha256=6rNGgJyi6-Plxi998o76UbjJv1F2A_sxGOH2Xshz188,9292
111
- voiceio/setup/steps.py,sha256=Q6nZPxUesFWyHfDSQzL4JNKoIHc5S6W7YN-fGTNCOQs,28610
112
- voiceio/setup/system.py,sha256=v6NniMk89lB5y55WCbn73ScQAnskkisa3215VSFZf2k,6657
112
+ voiceio/setup/steps.py,sha256=3uvhlLHKgVR8CWXpVdIhHBKvMwaZx3q4NqWxHXnXgno,29306
113
+ voiceio/setup/system.py,sha256=93S_VaPLBUz1Rnc4f76sW5Bc7HiMQJbWACytB4sGP8Y,6972
113
114
  voiceio/setup/ui.py,sha256=h1gmerT_8EfWftSONUn5K5Ri19elNTRP2lwFAuxsGPc,13401
114
115
  voiceio/sounds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
116
  voiceio/sounds/alert.wav,sha256=raqr2ZVADP49Uv9VUJM7E1itMq0uOp-o5WTyIrGy7gk,38852
@@ -142,8 +143,8 @@ voiceio/typers/pynput_type.py,sha256=f3w131YWJfNGd4IAcWtuKd2Gcwu3467QwGW3OBUEXNI
142
143
  voiceio/typers/wtype.py,sha256=11vOAKHjMat-fITd4sUoUWwgniyVp65EbH3i4mL6Vhg,1762
143
144
  voiceio/typers/xdotool.py,sha256=OuT_zW_z07jSAqu9Cmn_gL1mJfQsiX62ecqFRvpAarQ,1332
144
145
  voiceio/typers/ydotool.py,sha256=oY5EXB-nI7PvxTL_5Tb3JjfvyhmLNYNnUFvkb1XUn_U,5978
145
- python_voiceio-1.17.2.dist-info/METADATA,sha256=Vm4uegiW4U831n6-FZMdbVEZ75l-1o_ocAZY6ZkopG4,9264
146
- python_voiceio-1.17.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
147
- python_voiceio-1.17.2.dist-info/entry_points.txt,sha256=iDIDmhvQ3xeN_CWsFne1t9STZ08I25I_wp0xmde_vMs,94
148
- python_voiceio-1.17.2.dist-info/top_level.txt,sha256=piwtn309lD6uexQyXdZ-efAVBJF9y6Wfr48Z-8zkNhg,8
149
- python_voiceio-1.17.2.dist-info/RECORD,,
146
+ python_voiceio-1.18.0.dist-info/METADATA,sha256=6BnPXtcckbZCLbhq_eayupufpx8Y7hYXssrrUJiySWE,9629
147
+ python_voiceio-1.18.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
148
+ python_voiceio-1.18.0.dist-info/entry_points.txt,sha256=iDIDmhvQ3xeN_CWsFne1t9STZ08I25I_wp0xmde_vMs,94
149
+ python_voiceio-1.18.0.dist-info/top_level.txt,sha256=piwtn309lD6uexQyXdZ-efAVBJF9y6Wfr48Z-8zkNhg,8
150
+ python_voiceio-1.18.0.dist-info/RECORD,,
voiceio/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.17.2"
1
+ __version__ = "1.18.0"
voiceio/cli/doctor.py CHANGED
@@ -92,6 +92,15 @@ def _cmd_doctor(args: argparse.Namespace) -> None:
92
92
  for path, mode, expected in perm_issues:
93
93
  print(f" {oct(mode)[2:]:>4} → {oct(expected)[2:]:>4} {path}")
94
94
 
95
+ # Units and launchers that run voiceio from uv's cache (uvx) or a path
96
+ # that is gone: they work until uv prunes it, then autostart breaks.
97
+ from voiceio import install_env
98
+ stale_paths = install_env.stale_install_paths()
99
+ if stale_paths:
100
+ print(install_env.stale_paths_report(stale_paths))
101
+ elif install_env.running_ephemeral():
102
+ print("\nNote: " + install_env.ephemeral_message())
103
+
95
104
  # System-dependency preflight: the #1 install funnel killer.
96
105
  from voiceio import platform as plat
97
106
  missing_deps = plat.check_system_deps()
@@ -115,7 +124,7 @@ def _cmd_doctor(args: argparse.Namespace) -> None:
115
124
  print("Run 'voiceio doctor --fix' to tighten file permissions.")
116
125
  from voiceio.hints import hint
117
126
  hint("vocab_suggest", "Run 'voiceio vocab suggest' to find names it keeps mishearing")
118
- healthy = report.all_ok and not perm_issues and not missing_deps
127
+ healthy = report.all_ok and not perm_issues and not missing_deps and not stale_paths
119
128
  if args.report or _offer_report(args, healthy and not report.warnings):
120
129
  _share_report(args, report, missing_deps, [p for p, _, _ in perm_issues])
121
130
  sys.exit(0 if healthy else 1)
@@ -161,6 +170,9 @@ def _cmd_doctor(args: argparse.Namespace) -> None:
161
170
  except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as e:
162
171
  print(f" Failed: {e}")
163
172
 
173
+ if stale_paths and not install_env.running_ephemeral():
174
+ fixed_any = _rewrite_stale_paths(stale_paths) or fixed_any
175
+
164
176
  # CLI symlinks
165
177
  if not report.cli_in_path:
166
178
  print(" Fixing CLI: creating symlinks in ~/.local/bin/")
@@ -235,10 +247,40 @@ def _cmd_doctor(args: argparse.Namespace) -> None:
235
247
 
236
248
  missing_deps = plat.check_system_deps()
237
249
  perm_issues = _config.check_permissions()
238
- healthy = report.all_ok and not perm_issues and not missing_deps and not report.warnings
250
+ stale_paths = install_env.stale_install_paths()
251
+ healthy = (report.all_ok and not perm_issues and not missing_deps and not report.warnings
252
+ and not stale_paths)
239
253
  if args.report or _offer_report(args, healthy):
240
254
  _share_report(args, report, missing_deps, [p for p, _, _ in perm_issues])
241
- sys.exit(0 if report.all_ok else 1)
255
+ sys.exit(0 if report.all_ok and not stale_paths else 1)
256
+
257
+
258
+ def _rewrite_stale_paths(stale: list[tuple[str, str, str]]) -> bool:
259
+ """Rewrite each file stale_install_paths() flagged for the running install."""
260
+ from voiceio import service
261
+ whats = " ".join(what for what, _, _ in stale)
262
+ fixed = False
263
+ for label, needed, fix in (
264
+ ("autostart service", "autostart service", service.install_service),
265
+ ("learning service", "learning service", service.refresh_learn_timer),
266
+ ("IBus launcher", "IBus launcher", None),
267
+ ("command links", "command link", service.install_symlinks),
268
+ ):
269
+ if needed not in whats:
270
+ continue
271
+ print(f" Fixing {label}: pointing it at {service._find_voiceio_bin()}")
272
+ try:
273
+ if fix is None:
274
+ from voiceio.ibus import install
275
+ ok = install.install_component()
276
+ else:
277
+ ok = bool(fix())
278
+ except Exception as e: # noqa: BLE001 — report, keep fixing the rest
279
+ print(f" Failed: {e}")
280
+ continue
281
+ print(" Done." if ok else " Failed: run 'voiceio setup' again.")
282
+ fixed = fixed or ok
283
+ return fixed
242
284
 
243
285
 
244
286
  def _offer_report(args: argparse.Namespace, healthy: bool) -> bool:
voiceio/health.py CHANGED
@@ -80,15 +80,9 @@ def check_health(p: plat.Platform | None = None) -> HealthReport:
80
80
  ))
81
81
 
82
82
  # Check audio
83
- try:
83
+ report.audio_reason = plat.audio_problem()
84
+ if not report.audio_reason:
84
85
  import sounddevice as _sd
85
- except OSError:
86
- # sounddevice imports but PortAudio's shared library is missing.
87
- report.audio_reason = ("PortAudio library not found — install: "
88
- + plat.system_deps_install_cmd(["portaudio"]))
89
- except ImportError:
90
- report.audio_reason = plat.desktop_dep_hint("sounddevice")
91
- else:
92
86
  try:
93
87
  _sd.query_devices(kind="input")
94
88
  report.audio_ok = True
voiceio/install_env.py ADDED
@@ -0,0 +1,169 @@
1
+ """Where this voiceio install lives, and whether it will still be there tomorrow.
2
+
3
+ `uvx 'python-voiceio[desktop]'` runs voiceio from a throwaway environment in
4
+ uv's cache (``~/.cache/uv/archive-v0/<hash>/``). uv deletes it on
5
+ ``uv cache clean`` / ``uv cache prune`` or when a newer version is resolved, so
6
+ a systemd unit, IBus launcher or ~/.local/bin link that points there breaks
7
+ some day without warning. Setup refuses to write such paths, and doctor flags
8
+ the ones already written.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ import sys
14
+ from pathlib import Path
15
+
16
+ UV_TOOL_INSTALL = "uv tool install 'python-voiceio[desktop]'"
17
+ PIPX_INSTALL = "pipx install 'python-voiceio[desktop]'"
18
+
19
+ # The Cache Directory Tagging Specification (bford.info/cachedir): a directory
20
+ # holding this file, with this first line, is a cache whose contents may be
21
+ # deleted at any time. uv writes it at the root of every cache it uses,
22
+ # including the temporary one of `uvx --no-cache`.
23
+ CACHEDIR_TAG = "CACHEDIR.TAG"
24
+ _CACHEDIR_SIGNATURE = "Signature: 8a477f597d28d172789f06886806bc55"
25
+
26
+
27
+ def uv_cache_dir() -> Path:
28
+ """uv's default cache directory, resolved the way uv resolves it:
29
+ $UV_CACHE_DIR, else the platform cache dir ($XDG_CACHE_HOME or ~/.cache
30
+ on Linux and macOS, %LOCALAPPDATA% on Windows) + ``uv``."""
31
+ if env := os.environ.get("UV_CACHE_DIR"):
32
+ return Path(env).expanduser()
33
+ if sys.platform == "win32":
34
+ base = os.environ.get("LOCALAPPDATA") or str(Path.home() / "AppData" / "Local")
35
+ return Path(base) / "uv" / "cache"
36
+ xdg = os.environ.get("XDG_CACHE_HOME", "")
37
+ # XDG: a relative value is invalid and must be ignored.
38
+ base = Path(xdg) if xdg and os.path.isabs(xdg) else Path.home() / ".cache"
39
+ return base / "uv"
40
+
41
+
42
+ def _is_cachedir(d: Path) -> bool:
43
+ try:
44
+ with open(d / CACHEDIR_TAG, encoding="utf-8", errors="replace") as f:
45
+ return f.read(len(_CACHEDIR_SIGNATURE)) == _CACHEDIR_SIGNATURE
46
+ except OSError:
47
+ return False
48
+
49
+
50
+ def in_uv_cache(path: str | os.PathLike) -> bool:
51
+ """True when ``path`` lies inside uv's cache (or any tagged cache dir).
52
+
53
+ Two checks, either suffices: the path is under uv_cache_dir(), or one of
54
+ its parent directories carries a CACHEDIR.TAG (catches `--cache-dir`,
55
+ `--no-cache` and a UV_CACHE_DIR that differed when the file was written).
56
+ uv sets no variable that marks an ephemeral run: `$UV` is also set by
57
+ `uv run` in a project and inherited by every child, and pyvenv.cfg's
58
+ `uv = ...` line is also in `uv tool install` and `uv venv` environments.
59
+ """
60
+ p = Path(os.path.abspath(os.path.expanduser(os.fspath(path))))
61
+ try:
62
+ p = p.resolve()
63
+ except OSError:
64
+ pass
65
+ cache = uv_cache_dir()
66
+ for c in {cache, Path(os.path.abspath(cache))}:
67
+ try:
68
+ c = c.resolve()
69
+ except OSError:
70
+ pass
71
+ if p == c or c in p.parents:
72
+ return True
73
+ return any(_is_cachedir(d) for d in p.parents if d != d.parent)
74
+
75
+
76
+ def running_ephemeral() -> bool:
77
+ """This interpreter runs from a uvx environment that uv may delete."""
78
+ return in_uv_cache(sys.prefix)
79
+
80
+
81
+ def persistent_install_hint() -> str:
82
+ """What to run instead of uvx, for messages."""
83
+ return (f"Install voiceio permanently, then run setup again:\n"
84
+ f" {UV_TOOL_INSTALL} (or: {PIPX_INSTALL})\n"
85
+ f" voiceio setup")
86
+
87
+
88
+ def ephemeral_message() -> str:
89
+ """Why setup refuses to run from a uvx environment, and what to do."""
90
+ return (f"voiceio is running from a temporary uvx environment ({sys.prefix}).\n"
91
+ "uv deletes it on `uv cache clean`, `uv cache prune` or the next version, so\n"
92
+ "the autostart service and IBus launcher setup writes would stop working.\n"
93
+ + persistent_install_hint())
94
+
95
+
96
+ def _exec_start(unit: Path) -> str | None:
97
+ """The program a systemd unit runs (ExecStart's first word)."""
98
+ import shlex
99
+ try:
100
+ text = unit.read_text()
101
+ except OSError:
102
+ return None
103
+ for line in text.splitlines():
104
+ if line.startswith("ExecStart="):
105
+ try:
106
+ words = shlex.split(line.removeprefix("ExecStart="))
107
+ except ValueError:
108
+ return None
109
+ # Strip systemd's special-executable prefixes (-, @, :, +, !).
110
+ return words[0].lstrip("-@:+!") if words else None
111
+ return None
112
+
113
+
114
+ def _launcher_paths(launcher: Path) -> list[str]:
115
+ """Paths the IBus launcher bakes in: VOICEIO_PKG_ROOT, SYSTEM_PY, INSTALL_PY."""
116
+ try:
117
+ text = launcher.read_text()
118
+ except OSError:
119
+ return []
120
+ found = []
121
+ for line in text.splitlines():
122
+ for var in ("VOICEIO_PKG_ROOT", "SYSTEM_PY", "INSTALL_PY"):
123
+ if line.startswith(f'{var}="') and line.endswith('"'):
124
+ found.append(line[len(var) + 2:-1])
125
+ return found
126
+
127
+
128
+ def stale_install_paths() -> list[tuple[str, str, str]]:
129
+ """(what, path, problem) for each file voiceio wrote whose program lives
130
+ in uv's cache or no longer exists. Empty when everything is durable."""
131
+ from voiceio import service
132
+ from voiceio.ibus import install as ibus_install
133
+
134
+ refs: list[tuple[str, str]] = []
135
+ for label, unit in (("autostart service", service.SERVICE_PATH),
136
+ ("learning service", service.LEARN_SERVICE_PATH)):
137
+ if prog := _exec_start(unit):
138
+ refs.append((f"{label} {unit}", prog))
139
+ refs += [(f"IBus launcher {ibus_install.LAUNCHER_PATH}", p)
140
+ for p in _launcher_paths(ibus_install.LAUNCHER_PATH)]
141
+ for name in service.SCRIPT_NAMES:
142
+ link = service.LOCAL_BIN / name
143
+ if link.is_symlink():
144
+ refs.append((f"command link {link}", os.path.join(link.parent, os.readlink(link))))
145
+
146
+ stale = []
147
+ for what, path in refs:
148
+ if not os.path.isabs(path):
149
+ continue # a bare name (`voiceio`) is looked up on PATH at run time
150
+ cached = in_uv_cache(path)
151
+ exists = os.path.exists(path)
152
+ if cached:
153
+ stale.append((what, path, "in uv's cache" if exists
154
+ else "in uv's cache, already deleted"))
155
+ elif not exists:
156
+ stale.append((what, path, "no longer exists"))
157
+ return stale
158
+
159
+
160
+ def stale_paths_report(stale: list[tuple[str, str, str]]) -> str:
161
+ """Doctor's text for stale_install_paths() findings."""
162
+ lines = ["\nInstall paths that will break (or already did):"]
163
+ lines += [f" ✗ {what}\n → {path} ({problem})" for what, path, problem in stale]
164
+ if running_ephemeral():
165
+ lines.append("\n" + ephemeral_message())
166
+ else:
167
+ lines.append("\nRun 'voiceio doctor --fix' or 'voiceio setup' to rewrite them for this "
168
+ "install.\nIf voiceio came from uvx: " + persistent_install_hint())
169
+ return "\n".join(lines)
voiceio/platform.py CHANGED
@@ -33,11 +33,15 @@ class LazySounddevice:
33
33
 
34
34
  def desktop_dep_hint(package: str) -> str:
35
35
  """One-line message for a desktop dependency that failed to import."""
36
- return (
37
- f"{package} is not installed. The dictation app needs voiceio's "
38
- f"'desktop' extra: {DESKTOP_EXTRA_INSTALL} "
39
- "(or pip install 'python-voiceio[desktop]' in your venv)"
40
- )
36
+ from voiceio.install_env import running_ephemeral
37
+ if running_ephemeral():
38
+ # `uvx python-voiceio` resolves the base package only.
39
+ fix = ("run it as uvx 'python-voiceio[desktop]' ..., or install it: "
40
+ "uv tool install 'python-voiceio[desktop]'")
41
+ else:
42
+ fix = (f"{DESKTOP_EXTRA_INSTALL} (or uv tool install --force "
43
+ "'python-voiceio[desktop]', or pip install 'python-voiceio[desktop]' in your venv)")
44
+ return f"{package} is not installed. The dictation app needs voiceio's 'desktop' extra: {fix}"
41
45
 
42
46
 
43
47
  @dataclass(frozen=True)
@@ -238,6 +242,8 @@ _INSTALL_CMDS: dict[str, str] = {
238
242
  "zypper": "sudo zypper install",
239
243
  "xbps": "sudo xbps-install -S",
240
244
  "apk": "sudo apk add",
245
+ # emerge asks before merging; _assume_yes drops --ask when nobody can answer.
246
+ "emerge": "sudo emerge --ask",
241
247
  # NixOS has no imperative install; point at the declarative config.
242
248
  "nix": "add to environment.systemPackages:",
243
249
  "brew": "brew install",
@@ -272,8 +278,15 @@ def _sudo_without_password() -> bool:
272
278
  return False
273
279
 
274
280
 
281
+ # Flags that make a package manager prompt; dropped instead (emerge has no
282
+ # subcommand to put a yes-flag after, and without --ask it never asks).
283
+ _ASK_FLAGS: dict[str, tuple[str, ...]] = {"emerge": ("--ask", "-a")}
284
+
285
+
275
286
  def _assume_yes(argv: list[str]) -> list[str]:
276
287
  """`apt install x` -> `apt install -y x` (flag after the subcommand)."""
288
+ if argv and (ask := _ASK_FLAGS.get(os.path.basename(argv[0]))):
289
+ return [a for a in argv if a not in ask]
277
290
  flag = _ASSUME_YES.get(os.path.basename(argv[0])) if argv else None
278
291
  if not flag or flag in argv or len(argv) < 2:
279
292
  return argv
@@ -341,6 +354,20 @@ _PKG_NAMES: dict[str, dict[str, str]] = {
341
354
  "portaudio19-dev": "portaudio-dev",
342
355
  "gir1.2-ayatanaappindicator3-0.1": "libayatana-appindicator",
343
356
  },
357
+ # Gentoo atoms. Names not listed stay bare (`emerge ydotool`), which
358
+ # emerge resolves when the name is unique in the tree.
359
+ "emerge": {
360
+ "ibus": "app-i18n/ibus",
361
+ "gir1.2-ibus-1.0": "app-i18n/ibus", # typelib comes with USE=introspection
362
+ "python3-gi": "dev-python/pygobject",
363
+ "portaudio19-dev": "media-libs/portaudio",
364
+ "gir1.2-ayatanaappindicator3-0.1": "dev-libs/libayatana-appindicator",
365
+ "espeak-ng": "app-accessibility/espeak-ng",
366
+ "xdotool": "x11-misc/xdotool",
367
+ "xclip": "x11-misc/xclip",
368
+ "wl-clipboard": "gui-apps/wl-clipboard",
369
+ "wtype": "gui-apps/wtype",
370
+ },
344
371
  "nix": {
345
372
  "gir1.2-ibus-1.0": "ibus",
346
373
  "python3-gi": "python3Packages.pygobject3",
@@ -357,7 +384,7 @@ def _detect_pkg_manager() -> str:
357
384
  return "nix"
358
385
  for mgr, binary in (
359
386
  ("apt", "apt"), ("dnf", "dnf"), ("pacman", "pacman"), ("zypper", "zypper"),
360
- ("xbps", "xbps-install"), ("apk", "apk"), ("brew", "brew"),
387
+ ("xbps", "xbps-install"), ("apk", "apk"), ("emerge", "emerge"), ("brew", "brew"),
361
388
  ):
362
389
  if shutil.which(binary):
363
390
  return mgr
@@ -401,6 +428,7 @@ SYSTEM_DEPS: dict[str, dict[str, list[str]]] = {
401
428
  "zypper": ["gcc", "gcc-c++", "make", "python3-devel"],
402
429
  "xbps": ["base-devel", "python3-devel"],
403
430
  "apk": ["build-base", "python3-dev", "linux-headers"],
431
+ "emerge": ["sys-devel/gcc"], # Python headers ship with dev-lang/python
404
432
  "nix": ["gcc"],
405
433
  },
406
434
  # PortAudio backs sounddevice (microphone capture).
@@ -411,6 +439,7 @@ SYSTEM_DEPS: dict[str, dict[str, list[str]]] = {
411
439
  "zypper": ["portaudio-devel"],
412
440
  "xbps": ["portaudio-devel"],
413
441
  "apk": ["portaudio-dev"],
442
+ "emerge": ["media-libs/portaudio"],
414
443
  "nix": ["portaudio"],
415
444
  },
416
445
  # IBus engine + GObject bindings — the only reliable Wayland text injection.
@@ -421,6 +450,7 @@ SYSTEM_DEPS: dict[str, dict[str, list[str]]] = {
421
450
  "zypper": ["ibus", "typelib-1_0-IBus-1_0", "python3-gobject"],
422
451
  "xbps": ["ibus", "python3-gobject"],
423
452
  "apk": ["ibus", "py3-gobject3"],
453
+ "emerge": ["app-i18n/ibus", "dev-python/pygobject"],
424
454
  "nix": ["ibus", "python3Packages.pygobject3"],
425
455
  },
426
456
  }
@@ -443,12 +473,37 @@ def _probe_compiler() -> bool:
443
473
  return shutil.which("cc") is not None or shutil.which("gcc") is not None
444
474
 
445
475
 
476
+ def _portaudio_lib_present() -> bool:
477
+ """Is the PortAudio shared library installed? The lookup sounddevice does."""
478
+ import ctypes.util
479
+ return ctypes.util.find_library("portaudio") is not None
480
+
481
+
446
482
  def _probe_portaudio() -> bool:
447
483
  try:
448
484
  import sounddevice # noqa: F401
449
485
  return True
450
- except (OSError, ImportError):
451
- return False
486
+ except OSError:
487
+ return False # sounddevice is there, the PortAudio library is not
488
+ except ImportError:
489
+ # The pip package is missing (no [desktop] extra), which says nothing
490
+ # about the system library: audio_problem() names the extra instead.
491
+ return _portaudio_lib_present()
492
+
493
+
494
+ def audio_problem() -> str:
495
+ """Why sounddevice can't be used, or "" when it imports. A missing pip
496
+ package (the desktop extra) and a missing system PortAudio need
497
+ different fixes, so they get different messages."""
498
+ try:
499
+ import sounddevice # noqa: F401
500
+ except OSError:
501
+ return "PortAudio library not found — install: " + system_deps_install_cmd(["portaudio"])
502
+ except ImportError:
503
+ return desktop_dep_hint("sounddevice")
504
+ except Exception as e: # PortAudioError: library there, sound server isn't
505
+ return f"PortAudio could not start: {e}"
506
+ return ""
452
507
 
453
508
 
454
509
  def _probe_ibus() -> bool:
voiceio/service.py CHANGED
@@ -58,6 +58,16 @@ def _find_voiceio_bin() -> str:
58
58
  return "voiceio"
59
59
 
60
60
 
61
+ def _refuse_ephemeral(bin_path: str) -> bool:
62
+ """True (and says why) when ``bin_path`` lives in uv's cache: a unit
63
+ pointing there breaks the day uv prunes it."""
64
+ from voiceio.install_env import ephemeral_message, in_uv_cache
65
+ if not in_uv_cache(bin_path):
66
+ return False
67
+ print(ephemeral_message(), file=sys.stderr)
68
+ return True
69
+
70
+
61
71
  def _service_unit(bin_path: str) -> str:
62
72
  """Generate the systemd unit file content."""
63
73
  return f"""\
@@ -170,7 +180,10 @@ def install_learn_timer(auto_promote: bool = False) -> bool:
170
180
  return False
171
181
  from voiceio import config
172
182
  learn = config.load().learn
173
- service, timer = _learn_units(_find_voiceio_bin(), auto_promote,
183
+ bin_path = _find_voiceio_bin()
184
+ if _refuse_ephemeral(bin_path):
185
+ return False
186
+ service, timer = _learn_units(bin_path, auto_promote,
174
187
  learn_calendar(learn.at, learn.every))
175
188
  SERVICE_DIR.mkdir(parents=True, exist_ok=True)
176
189
  LEARN_SERVICE_PATH.write_text(service)
@@ -262,6 +275,8 @@ def install_windows_startup() -> bool:
262
275
  """Create a .bat file in the Windows Startup folder."""
263
276
  bat_path = _windows_startup_bat()
264
277
  voiceio_bin = _find_voiceio_bin()
278
+ if _refuse_ephemeral(voiceio_bin):
279
+ return False
265
280
  bat_path.parent.mkdir(parents=True, exist_ok=True)
266
281
  bat_path.write_text(f'@echo off\nstart /B "" "{voiceio_bin}"\n')
267
282
  log.info("Windows startup script created: %s", bat_path)
@@ -292,6 +307,8 @@ def install_service() -> bool:
292
307
  return False
293
308
 
294
309
  bin_path = _find_voiceio_bin()
310
+ if _refuse_ephemeral(bin_path):
311
+ return False
295
312
 
296
313
  SERVICE_DIR.mkdir(parents=True, exist_ok=True)
297
314
  SERVICE_PATH.write_text(_service_unit(bin_path))
@@ -453,6 +470,12 @@ def install_symlinks() -> list[str]:
453
470
  # The package installed them in /usr/bin.
454
471
  return [name for name in SCRIPT_NAMES if shutil.which(name)]
455
472
 
473
+ from voiceio.install_env import running_ephemeral
474
+ if running_ephemeral():
475
+ # Links into uv's cache dangle once uv prunes it.
476
+ log.warning("Not linking commands into ~/.local/bin from a uvx environment")
477
+ return []
478
+
456
479
  venv_bin = Path(sys.prefix) / "bin"
457
480
  LOCAL_BIN.mkdir(parents=True, exist_ok=True)
458
481
  for name in _LEGACY_SCRIPT_NAMES:
@@ -66,6 +66,13 @@ def run_setup_noninteractive(answers: dict | None = None, *, install_deps: bool
66
66
  if not hotkey:
67
67
  return _fail("validate", "hotkey must not be empty", 2)
68
68
 
69
+ from voiceio.install_env import UV_TOOL_INSTALL, running_ephemeral
70
+ if running_ephemeral():
71
+ # The service and IBus launcher would point into uv's cache.
72
+ return _fail("install", "running from a temporary uvx environment that uv may "
73
+ f"delete; install it with: {UV_TOOL_INSTALL} (or pipx), "
74
+ "then run voiceio setup again", 3)
75
+
69
76
  _progress("start", mode="noninteractive", model=model, language=language, hotkey=hotkey)
70
77
 
71
78
  from voiceio import platform as plat
@@ -99,9 +106,9 @@ def run_setup_noninteractive(answers: dict | None = None, *, install_deps: bool
99
106
  checks = _check_system()
100
107
  system_error: tuple[str, int] | None = None # (reason, exit code)
101
108
  if not checks["audio"]:
102
- _progress("system", check="audio", status="missing",
103
- reason=repr("no microphone/audio input device found"))
104
- system_error = ("no microphone/audio input device found", 5)
109
+ reason = checks.get("audio_reason") or "no microphone/audio input device found"
110
+ _progress("system", check="audio", status="missing", reason=repr(reason))
111
+ system_error = (reason, 5)
105
112
  if checks["is_windows"] or checks["is_mac"]:
106
113
  if not checks["pynput"]:
107
114
  _progress("system", check="typer", status="missing",
voiceio/setup/steps.py CHANGED
@@ -98,6 +98,7 @@ class SetupState:
98
98
 
99
99
 
100
100
  def run_wizard() -> None:
101
+ _refuse_ephemeral_env()
101
102
  state = _welcome()
102
103
  _preflight_deps(interactive=True)
103
104
  _step_system_check(state) # 1
@@ -111,6 +112,15 @@ def run_wizard() -> None:
111
112
  _print_ready_panel(state.hotkey, autostart=state.autostart)
112
113
 
113
114
 
115
+ def _refuse_ephemeral_env() -> None:
116
+ """Setup bakes this install's paths into the service, IBus launcher and
117
+ ~/.local/bin; from a uvx environment they would point into uv's cache."""
118
+ from voiceio.install_env import ephemeral_message, running_ephemeral
119
+ if running_ephemeral():
120
+ print(f"\n {YELLOW}⚠{RESET} " + ephemeral_message().replace("\n", "\n "))
121
+ sys.exit(3)
122
+
123
+
114
124
  def _welcome() -> SetupState:
115
125
  print(LOGO)
116
126
  is_rerun = CONFIG_PATH.exists()
@@ -142,7 +152,8 @@ def _step_system_check(state: SetupState) -> None:
142
152
  def _print_capability_checks(checks: dict) -> None:
143
153
  _print_check("Platform", True, checks["display"])
144
154
  _print_check("Audio input", checks["audio"],
145
- f"{len(checks['audio_devices'])} device(s)" if checks["audio"] else "no devices found")
155
+ f"{len(checks['audio_devices'])} device(s)" if checks["audio"]
156
+ else checks.get("audio_reason") or "no devices found")
146
157
 
147
158
  if checks["is_windows"] or checks["is_mac"]:
148
159
  _print_check("pynput", checks["pynput"],
@@ -219,6 +230,10 @@ def _ensure_cli_commands() -> None:
219
230
  def _require_mic_and_typer(state: SetupState) -> None:
220
231
  """Exit unless there is a microphone and some text injection backend."""
221
232
  checks = state.checks
233
+ reason = checks.get("audio_reason", "")
234
+ if not checks["audio"] and reason and "microphone" not in reason:
235
+ print(f"\n {RED}{reason}{RESET}") # a missing package, not a missing mic
236
+ sys.exit(1)
222
237
  if not checks["audio"]:
223
238
  print(f"\n {RED}No microphone found. Connect one and try again.{RESET}")
224
239
  sys.exit(1)
voiceio/setup/system.py CHANGED
@@ -104,7 +104,11 @@ def _check_system() -> dict:
104
104
  checks["ibus_gi"] = has_ibus_gi()
105
105
 
106
106
  # Audio
107
+ from voiceio.platform import audio_problem
108
+ checks["audio_reason"] = audio_problem()
107
109
  try:
110
+ if checks["audio_reason"]:
111
+ raise RuntimeError(checks["audio_reason"])
108
112
  import sounddevice as sd
109
113
  devices = sd.query_devices()
110
114
  input_devs = [d for d in devices if d["max_input_channels"] > 0]
@@ -113,6 +117,8 @@ def _check_system() -> dict:
113
117
  except Exception:
114
118
  checks["audio"] = False
115
119
  checks["audio_devices"] = []
120
+ if not checks["audio"] and not checks["audio_reason"]:
121
+ checks["audio_reason"] = "no microphone/audio input device found"
116
122
 
117
123
  # GPU
118
124
  try: