Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tps not initialized with 0, skip_special_tokens not exists in TextStreamer options #1091

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/webgpu-whisper/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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,
});

Expand Down Expand Up @@ -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.
Expand Down