]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
whisper.addon : fixed test to new async implementation (#686)
authorLucas Zanek <redacted>
Wed, 29 Mar 2023 20:59:17 +0000 (17:59 -0300)
committerGitHub <redacted>
Wed, 29 Mar 2023 20:59:17 +0000 (23:59 +0300)
* fixed blocking code on node addon

* modify the example to run async

* format

* added logic to see the whisper output

* added logic to see the whisper output

* removed extra function for more clean example

* fixed whisper test to new async implementation

examples/addon.node/__test__/whisper.spec.js

index b7d35406582407e276795acfbb0f82afad2c25c6..a8088b480142fae134f91d47681956df2e055839 100644 (file)
@@ -1,15 +1,22 @@
-const path = require('path');
-const { whisper } = require(path.join(__dirname, '../../../build/Release/whisper-addon'));
+const path = require("path");
+const { whisper } = require(path.join(
+  __dirname,
+  "../../../build/Release/whisper-addon"
+));
+const { promisify } = require("util");
+
+const whisperAsync = promisify(whisper);
 
 const whisperParamsMock = {
-    language: 'en',
-    model: path.join(__dirname, '../../../models/ggml-base.en.bin'),
-    fname_inp: path.join(__dirname, '../../../samples/jfk.wav'),
+  language: "en",
+  model: path.join(__dirname, "../../../models/ggml-base.en.bin"),
+  fname_inp: path.join(__dirname, "../../../samples/jfk.wav"),
 };
 
 describe("Run whisper.node", () => {
+  test("it should receive a non-empty value", async () => {
+    let result = await whisperAsync(whisperParamsMock);
 
-    test("it should receive a non-empty value", () => {
-        expect(whisper(whisperParamsMock).length).toBeGreaterThan(0);
-    });
+    expect(result.length).toBeGreaterThan(0);
+  });
 });