From 7de456541067e2a1023fc4311dbae28bbf0a8821 Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Tue, 10 Dec 2024 16:27:19 +0800 Subject: [PATCH] fix: tps not initialized with 0, skip_special_tokens not exists in TextStreamer options --- examples/webgpu-whisper/src/worker.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/webgpu-whisper/src/worker.js b/examples/webgpu-whisper/src/worker.js index 12735b1cb..c64d19922 100644 --- a/examples/webgpu-whisper/src/worker.js +++ b/examples/webgpu-whisper/src/worker.js @@ -58,7 +58,7 @@ async function generate({ audio, language }) { const callback_function = (output) => { startTime ??= performance.now(); - let tps; + let tps = 0; if (numTokens++ > 0) { tps = numTokens / (performance.now() - startTime) * 1000; } @@ -70,7 +70,9 @@ async function generate({ audio, language }) { const streamer = new TextStreamer(tokenizer, { skip_prompt: true, - skip_special_tokens: true, + decode_kwargs: { + skip_special_tokens: true, + }, callback_function, }); @@ -100,6 +102,7 @@ async function load() { }); // Load the pipeline and save it for future use. + // eslint-disable-next-line no-unused-vars const [tokenizer, processor, model] = await AutomaticSpeechRecognitionPipeline.getInstance(x => { // We also add a progress callback to the pipeline so that we can // track model loading.