Gadersd / whisper-burn

A Rust implementation of OpenAI's Whisper model using the burn framework
MIT License
263 stars 29 forks source link

Panic while transcribing audio.wav #5

Closed meowcoder closed 1 year ago

meowcoder commented 1 year ago
thread 'main' panicked at 'slice index starts at 172409 but ends at 168511', 
/tmp/whisper-burn/src/transcribe.rs:101:22

https://github.com/Gadersd/whisper-burn/blob/3757c15fd18fe2ec2c398cb6a4697e108442ff3a/src/transcribe.rs#L95

Here waveform.len() could be less than n_samples_per_tensor, which results in iter_len to be extremely large:

[src/transcribe.rs:97] n_samples_per_tensor = 238559
[src/transcribe.rs:97] waveform.len() = 168511
[src/transcribe.rs:97] waveform.len() - n_samples_per_tensor = 18446744073709481568

Replacing subtraction with saturating_sub fixes the issue.

Gadersd commented 1 year ago

Nice catch! I just pushed your correction.