opencode-voice-dictation 0.6.0 → 0.6.1
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 +1 -1
- package/src/whisper/server.ts +17 -3
package/package.json
CHANGED
package/src/whisper/server.ts
CHANGED
|
@@ -42,7 +42,10 @@ function toWslPath(path: string): string {
|
|
|
42
42
|
|
|
43
43
|
function spawnWorker(python: string, model: string): ChildProcess {
|
|
44
44
|
const env = { ...process.env, WHISPER_MODEL: model, WHISPER_DEVICE: "cuda" }
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
// Inside `bash -lc`, a quoted `~` does not expand. Use $HOME instead.
|
|
47
|
+
const pythonArg = python.startsWith("~/") ? `"$HOME/${python.slice(2)}"` : `"${python}"`
|
|
48
|
+
const command = `${pythonArg} "${toWslPath(workerPath())}"`
|
|
46
49
|
|
|
47
50
|
if (process.platform === "win32") {
|
|
48
51
|
return spawn("wsl.exe", ["-d", "Ubuntu-22.04", "-e", "bash", "-lc", command], {
|
|
@@ -119,14 +122,25 @@ export class WhisperEngine {
|
|
|
119
122
|
|
|
120
123
|
child.on("close", (code) => {
|
|
121
124
|
clearTimeout(timer)
|
|
122
|
-
|
|
125
|
+
const detail = this.stderr.trim()
|
|
126
|
+
|
|
127
|
+
if (!this.status.ready) {
|
|
128
|
+
this.status = {
|
|
129
|
+
ready: false,
|
|
130
|
+
model: this.model,
|
|
131
|
+
device: "cuda",
|
|
132
|
+
error: detail || `Whisper worker exited with code ${code ?? "unknown"}`,
|
|
133
|
+
}
|
|
134
|
+
this.readyReject?.(new Error(this.status.error))
|
|
135
|
+
} else {
|
|
123
136
|
this.status = {
|
|
124
137
|
ready: false,
|
|
125
138
|
model: this.model,
|
|
126
139
|
device: "cuda",
|
|
127
|
-
error:
|
|
140
|
+
error: detail || `Whisper worker exited with code ${code ?? "unknown"}`,
|
|
128
141
|
}
|
|
129
142
|
}
|
|
143
|
+
|
|
130
144
|
this.failWaiters(new Error(this.status.error || "Whisper worker stopped"))
|
|
131
145
|
this.child = undefined
|
|
132
146
|
this.readyPromise = undefined
|