diff options
Diffstat (limited to 'candle-wasm-examples/whisper/src/worker.rs')
-rw-r--r-- | candle-wasm-examples/whisper/src/worker.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/candle-wasm-examples/whisper/src/worker.rs b/candle-wasm-examples/whisper/src/worker.rs index 09d4f580..db5e8bb1 100644 --- a/candle-wasm-examples/whisper/src/worker.rs +++ b/candle-wasm-examples/whisper/src/worker.rs @@ -129,7 +129,13 @@ impl Decoder { let transcribe_token = token_id(&tokenizer, m::TRANSCRIBE_TOKEN)?; let translate_token = token_id(&tokenizer, m::TRANSLATE_TOKEN)?; let eot_token = token_id(&tokenizer, m::EOT_TOKEN)?; - let no_speech_token = token_id(&tokenizer, m::NO_SPEECH_TOKEN)?; + let no_speech_token = m::NO_SPEECH_TOKENS + .iter() + .find_map(|token| token_id(&tokenizer, token).ok()); + let no_speech_token = match no_speech_token { + None => anyhow::bail!("unable to find any non-speech token"), + Some(n) => n, + }; let seed = 299792458; Ok(Self { model, |