sandrohanea / whisper.net

Whisper.net. Speech to text made simple using Whisper Models
MIT License
512 stars 78 forks source link

GetAvgSamplesAsync reads beyond data chunk #86

Closed nightman94 closed 1 year ago

nightman94 commented 1 year ago

The GetAvgSamples() method reads the number of samples from the stream based on the value in SamplesCount. However the async version of that method reads until the end of the stream without considering SamplesCount. If there are other chunks after the data chunk this leads to an out of bounds exception. A workaround right now is processor.ProcessAsync(new WaveParser(fileStream).GetAvgSamples())), effectively reading sync, but still processing async.

sandrohanea commented 1 year ago

Hello @nightman94 , I checked the code and indeed it seems like a bug in the different implementations of GetAvgSamples (Async vs Non-Async). Will fix it asap and unify these methods, similar to InitializeCore in https://github.com/sandrohanea/whisper.net/blob/main/Whisper.net/Wave/WaveParser.cs