whisper.addon : fixed test to new async implementation (#686)

* 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
This commit is contained in:
Lucas Zanek 2023-03-29 17:59:17 -03:00 committed by GitHub
parent 18e6fb0287
commit 86ecfc6333
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,22 @@
const path = require('path'); const path = require("path");
const { whisper } = require(path.join(__dirname, '../../../build/Release/whisper-addon')); const { whisper } = require(path.join(
__dirname,
"../../../build/Release/whisper-addon"
));
const { promisify } = require("util");
const whisperAsync = promisify(whisper);
const whisperParamsMock = { const whisperParamsMock = {
language: 'en', language: "en",
model: path.join(__dirname, '../../../models/ggml-base.en.bin'), model: path.join(__dirname, "../../../models/ggml-base.en.bin"),
fname_inp: path.join(__dirname, '../../../samples/jfk.wav'), fname_inp: path.join(__dirname, "../../../samples/jfk.wav"),
}; };
describe("Run whisper.node", () => { 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(result.length).toBeGreaterThan(0);
expect(whisper(whisperParamsMock).length).toBeGreaterThan(0);
}); });
}); });