Skip to content

Commit

Permalink
Set audio_ctx according to recommendation in whisper.cpp repo
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-msp committed Apr 2, 2024
1 parent d7cc252 commit c4fd60f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/whisper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ impl Whisper {
let mut params = FullParams::new(whisper_rs::SamplingStrategy::Greedy { best_of: 1 });
params.set_max_len(1);
params.set_split_on_word(true);
params.set_audio_ctx({
let blen = data.as_ref().len();
let audio_secs = blen as f32 / 16.0;
if audio_secs > 30.0 {
1500
} else {
(audio_secs as i32) / 30 * 1500 + 128
}
});

match state.full(params, data.as_ref()) {
Ok(0) => {}
Expand Down

0 comments on commit c4fd60f

Please sign in to comment.