diff --git a/README.md b/README.md index 8a8381d..4d2a825 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ You can get a list of supported devices with: ### Options +* `asar`: For electron applications, whether asar archiving is enabled or not. Default `false`. * `consecutiveFramesForSilence`: How many frames of audio must be silent before `onChunkEnd` is fired. Default `10`. * `consecutiveFramesForSpeaking`: How many frames of audio must be speech before `onChunkStart` is fired. Default `1`. * `leadingBufferFrames`: How many frames of audio to keep in a buffer that's included in `onChunkStart`. Default `10`. diff --git a/src/index.js b/src/index.js index fd98de0..2baf031 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ const { SpeechRecorder, devices } = require("bindings")("speechrecorder.node"); class Wrapper { constructor(options, model) { options = options ? options : {}; + options.asar = options.asar !== undefined ? options.asar : false; options.consecutiveFramesForSilence = options.consecutiveFramesForSilence !== undefined ? options.consecutiveFramesForSilence : 10; options.consecutiveFramesForSpeaking = @@ -33,8 +34,11 @@ class Wrapper { options.webrtcVadResultsSize = options.webrtcVadResultsSize !== undefined ? options.webrtcVadResultsSize : 10; + let defaultModelPath = path.join(__dirname, "..", "lib", "resources", "vad.onnx"); + if (options.asar) defaultModelPath = defaultModelPath.replace('app.asar', 'app.asar.unpacked'); + this.inner = new SpeechRecorder( - model !== undefined ? model : path.join(__dirname, "..", "lib", "resources", "vad.onnx"), + model !== undefined ? model : defaultModelPath, (event, data) => { if (event == "chunkStart") { options.onChunkStart({ audio: data.audio });