Skip to content

Commit

Permalink
Expose configurable tail paddings in WhisperConfig (#84)
Browse files Browse the repository at this point in the history
When running on shorter audio samples, you might get an ONNX exception:
```
 Non-zero status code returned while running Expand node. Name:'/Expand' Status Message: invalid expand shape
```
The issues for sherpa-onnx indicate the value should be more carefully
tuned in this case to a more appropriate value.
  • Loading branch information
vlovich authored Jan 24, 2025
1 parent 1ad02d7 commit 6fde4cd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/sherpa-rs/src/whisper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct WhisperConfig {
pub tokens: String,
pub language: String,
pub bpe_vocab: Option<String>,
pub tail_paddings: Option<i32>,

pub provider: Option<String>,
pub num_threads: Option<i32>,
Expand All @@ -30,6 +31,7 @@ impl Default for WhisperConfig {
tokens: String::new(),
language: String::from("en"),
bpe_vocab: None,
tail_paddings: None,
debug: false,
provider: None,
num_threads: Some(1),
Expand All @@ -48,7 +50,7 @@ impl WhisperRecognizer {

// Whisper
let bpe_vocab_ptr = cstring_from_str(&config.bpe_vocab.unwrap_or("".into()));
let tail_paddings = 0;
let tail_paddings = config.tail_paddings.unwrap_or(0);
let decoder_ptr = cstring_from_str(&config.decoder);
let encoder_ptr = cstring_from_str(&config.encoder);
let language_ptr = cstring_from_str(&config.language);
Expand Down Expand Up @@ -181,6 +183,7 @@ mod tests {
encoder: "sherpa-onnx-whisper-tiny/tiny-encoder.onnx".into(),
tokens: "sherpa-onnx-whisper-tiny/tiny-tokens.txt".into(),
language: "en".into(),
tail_paddings: None,
debug: true,
provider: None,
num_threads: None,
Expand Down

0 comments on commit 6fde4cd

Please sign in to comment.