speech-opencode 1.1.5 → 1.1.7
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,qBAAqB,CAAA;AA8GvD,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gFAAgF;IAChF,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,qBAAqB,CAAA;AA8GvD,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,0FAA0F;IAC1F,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gFAAgF;IAChF,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAsWD,eAAO,MAAM,WAAW,GACrB,UAAS,kBAAuB,KAAG,MAwEnC,CAAA;;AAGH,wBAA4B"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
2
|
import OpenAI from "openai";
|
|
3
|
-
import { spawn } from "child_process";
|
|
3
|
+
import { spawn, spawnSync } from "child_process";
|
|
4
4
|
import { unlinkSync, readFileSync, existsSync, watch, mkdirSync, writeFileSync } from "fs";
|
|
5
5
|
import { tmpdir, homedir } from "os";
|
|
6
6
|
import { join, dirname } from "path";
|
|
@@ -255,7 +255,26 @@ def main():
|
|
|
255
255
|
print(f"[WakeWord] Detected! (score: {score:.3f})")
|
|
256
256
|
TRIGGER_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
257
257
|
TRIGGER_FILE.write_text("triggered")
|
|
258
|
-
|
|
258
|
+
|
|
259
|
+
# Close stream temporarily to release device for recording
|
|
260
|
+
stream.stop_stream()
|
|
261
|
+
stream.close()
|
|
262
|
+
|
|
263
|
+
# Wait for recording to likely finish (e.g. 5 seconds)
|
|
264
|
+
import time
|
|
265
|
+
time.sleep(5)
|
|
266
|
+
|
|
267
|
+
# Re-open stream
|
|
268
|
+
stream = audio.open(
|
|
269
|
+
format=pyaudio.paInt16,
|
|
270
|
+
channels=1,
|
|
271
|
+
rate=sample_rate,
|
|
272
|
+
input=True,
|
|
273
|
+
input_device_index=device_index,
|
|
274
|
+
frames_per_buffer=CHUNK_SIZE,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
cooldown = 0
|
|
259
278
|
|
|
260
279
|
except Exception as e:
|
|
261
280
|
if running:
|
|
@@ -277,7 +296,7 @@ function startWakeWordListener(wakeWord = "hey_jarvis", threshold = 0.5) {
|
|
|
277
296
|
// First, kill any existing instances to prevent duplicates/zombies
|
|
278
297
|
// This is crucial because multiple listeners will fight for the mic
|
|
279
298
|
try {
|
|
280
|
-
|
|
299
|
+
spawnSync("pkill", ["-f", "opencode-wakeword-listener.py"]);
|
|
281
300
|
}
|
|
282
301
|
catch {
|
|
283
302
|
// Ignore
|