@vaibhavgupta0786/opencode-voice 0.3.3 → 0.3.5
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/package.json +23 -1
- package/servers/mlx_server.py +9 -1
package/package.json
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaibhavgupta0786/opencode-voice",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"opencode",
|
|
9
|
+
"opencode-plugin",
|
|
10
|
+
"opencode-tui",
|
|
11
|
+
"voice",
|
|
12
|
+
"dictation",
|
|
13
|
+
"push-to-talk",
|
|
14
|
+
"speech-to-text",
|
|
15
|
+
"stt",
|
|
16
|
+
"whisper",
|
|
17
|
+
"voice-input",
|
|
18
|
+
"tui",
|
|
19
|
+
"plugin",
|
|
20
|
+
"local",
|
|
21
|
+
"offline",
|
|
22
|
+
"mlx",
|
|
23
|
+
"macos"
|
|
24
|
+
],
|
|
25
|
+
"homepage": "https://github.com/vaibhavgupta0786/opencode-voice#readme",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/vaibhavgupta0786/opencode-voice/issues"
|
|
28
|
+
},
|
|
7
29
|
"exports": {
|
|
8
30
|
"./tui": "./tui.tsx"
|
|
9
31
|
},
|
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}"})
|