Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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 });
Expand Down