Spaces:
Running
Running
node : add win platform check for require path (#3363)
Browse filesThis commit adds a check to the platform in use and adjust the path to
the addon.node shared library.
The motivation for this change is that on windows addon.node library is
built into build\bin\Release and on linux into build/Release.
Resolves: https://github.com/ggml-org/whisper.cpp/issues/3360
examples/addon.node/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
-
const path = require(
|
| 2 |
-
const
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
const { promisify } = require("util");
|
| 7 |
|
| 8 |
const whisperAsync = promisify(whisper);
|
|
|
|
| 1 |
+
const path = require('path');
|
| 2 |
+
const os = require('os');
|
| 3 |
+
|
| 4 |
+
const isWindows = os.platform() === 'win32';
|
| 5 |
+
const buildPath = isWindows ? "../../build/bin/Release/addon.node" : "../../build/Release/addon.node";
|
| 6 |
+
|
| 7 |
+
const { whisper } = require(path.join(__dirname, buildPath));
|
| 8 |
const { promisify } = require("util");
|
| 9 |
|
| 10 |
const whisperAsync = promisify(whisper);
|