@vaibhavgupta0786/opencode-voice 0.3.4 → 0.3.6
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.
- package/README.md +24 -0
- package/package.json +2 -2
- package/servers/mlx_server.py +9 -1
package/README.md
CHANGED
|
@@ -26,6 +26,30 @@ opencode plugin add @vaibhavgupta0786/opencode-voice
|
|
|
26
26
|
`f9` may be hijacked by macOS Fn keys — `Ctrl+P` → `dictate` (or
|
|
27
27
|
`/dictate`) works the same.
|
|
28
28
|
|
|
29
|
+
## Compatibility
|
|
30
|
+
|
|
31
|
+
V2-only — the `Plugin.define` TUI API and slots don't exist in V1.
|
|
32
|
+
|
|
33
|
+
| OpenCode V2 | Status | Verified |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| `2.0.12` | ✅ works | footer slot renders, zero errors |
|
|
36
|
+
| `2.0.28` | ✅ works | footer slot renders, zero errors |
|
|
37
|
+
| `2.1.3` | ✅ works | footer slot renders, zero plugin errors |
|
|
38
|
+
|
|
39
|
+
Verified with each version's real binary booted standalone against the
|
|
40
|
+
published npm package, checking load, slot render, and error logs. The
|
|
41
|
+
plugin only touches two documented-stable APIs —
|
|
42
|
+
`context.ui.slot({ append: "prompt.footer.status" })` and
|
|
43
|
+
`context.keymap.layer()` — no host OpenTUI internals, so the host-side
|
|
44
|
+
OpenTUI 0.5 → 0.6 migration doesn't affect it. Newer `2.x` releases are
|
|
45
|
+
expected to work; if one doesn't, file an issue.
|
|
46
|
+
|
|
47
|
+
Manifest note: `@opencode/plugin` is capped at `>=2.0.12 <2.0.21`, since
|
|
48
|
+
SDK `2.0.21+` raises its OpenTUI peer floor beyond this plugin's pinned
|
|
49
|
+
`0.5.12` runtime deps and would break fresh `npm install` resolutions.
|
|
50
|
+
This affects only local npm resolution — the host resolves the import at
|
|
51
|
+
runtime, so OpenCode host versions above are unaffected.
|
|
52
|
+
|
|
29
53
|
## Usage
|
|
30
54
|
|
|
31
55
|
| Input | Action |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaibhavgupta0786/opencode-voice",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Local-only push-to-talk dictation for OpenCode v2 \u2014 press F9, speak, press F9.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"typecheck": "tsc --noEmit"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@opencode/plugin": "2.0.12",
|
|
46
|
+
"@opencode/plugin": ">=2.0.12 <2.0.21",
|
|
47
47
|
"solid-js": "1.9.12",
|
|
48
48
|
"@opentui/solid": "0.5.12",
|
|
49
49
|
"@opentui/core": "0.5.12"
|
package/servers/mlx_server.py
CHANGED
|
@@ -22,6 +22,7 @@ from email.policy import default as email_policy
|
|
|
22
22
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
23
23
|
|
|
24
24
|
import numpy as np
|
|
25
|
+
import mlx.core as mx
|
|
25
26
|
import mlx_whisper
|
|
26
27
|
|
|
27
28
|
MODEL = os.environ.get("MLX_MODEL", "mlx-community/whisper-small-mlx")
|
|
@@ -79,7 +80,14 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
79
80
|
self._json(400, {"error": "no file part"})
|
|
80
81
|
return
|
|
81
82
|
samples = wav_bytes_to_float32(bytes(audio))
|
|
82
|
-
|
|
83
|
+
try:
|
|
84
|
+
result = mlx_whisper.transcribe(samples, path_or_hf_repo=_MODEL_REF)
|
|
85
|
+
finally:
|
|
86
|
+
# MLX's Metal buffer cache retains buffers for every unique
|
|
87
|
+
# tensor shape forever (~40 MB per new audio duration,
|
|
88
|
+
# measured with vmmap). Clearing it per request keeps the
|
|
89
|
+
# footprint flat (~0.7 GB) in long-running servers.
|
|
90
|
+
mx.clear_cache()
|
|
83
91
|
self._json(200, {"text": (result.get("text") or "").strip()})
|
|
84
92
|
except Exception as error: # keep the endpoint fail-closed with a reason
|
|
85
93
|
self._json(500, {"error": f"{type(error).__name__}: {error}"})
|