From 7bbc92f1cf5014aef9868493b86839c80e8301d1 Mon Sep 17 00:00:00 2001 From: ae9is <125031666+ae9is@users.noreply.github.com> Date: Sun, 15 Dec 2024 00:31:35 +0000 Subject: [PATCH] Fix Whisper language detection pipeline test --- tests/pipelines.test.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/pipelines.test.js b/tests/pipelines.test.js index 7142ed267..cf13d36aa 100644 --- a/tests/pipelines.test.js +++ b/tests/pipelines.test.js @@ -774,27 +774,19 @@ xdescribe("Pipelines", () => { ); it( - models[1], + `${models[1]}-language-detect`, async () => { let transcriber = await pipeline("automatic-speech-recognition", models[1]); - - let url = "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/french-audio.wav"; + let url = "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/japanese-audio.wav"; let audioData = await loadAudio(url); - { - // Transcribe French by autodetecting language + // Transcribe Japanese by autodetecting language + // Note: this sample needs to be hard enough for Whisper not to be able to transcribe it properly + // with the fallback 'en' language set! let output = await transcriber(audioData, { language: null, task: "transcribe" }); expect(output.text.length).toBeGreaterThan(20); - const expected = " J'adore, j'aime, je n'aime pas, je déteste."; - compareString(expected, output.text); - } - - { - // Translate French to English with language autodetect - let output = await transcriber(audioData, { language: null, task: "translate" }); - expect(output.text.length).toBeGreaterThan(20); - const expected = " I love, I like, I don't like, I hate."; - compareString(expected, output.text); + const expected = "モリナガの美味しい牛乳は濃い青色に牛乳瓶を払ったゼザインのパック牛乳である。"; + compareString(expected, output.text, 0.8); } await transcriber.dispose(); },