Assertion failed: sourceOffset + samples <= rsi.mono.size(), file ...\Whisper\MF\PcmReader.cpp, line 25
Source audio file -- mono, 1656 frames
Hey there Unfortunatelly we still have exactly the same problem. We use the WhsiperNET DLL in C#. Anybody who found a solution yet?
Same problem here, we are using it in our C++ Project for Unreal. Have not found the solution or what caused it yet. It happens when we call whisper several times in our loop. The loop uses listener when a transcript is done, pass another file to whisper. Here is some call stack information I gathered from this assert. Hope it helps. I would check on the MelStreamer class more for this problem. As it is a thread related class, maybe something to do with thread that causes this problem? I don't have enough knowledge for this topic.
PcmReader.cpp line25 __forceinline void copyMono( PcmMonoChunk* rdi, const AudioBuffer& rsi, size_t sourceOffset, size_t samples ) { line25 assert( sourceOffset + samples <= rsi.mono.size() ); memcpy( rdi->mono.data(), &rsi.mono[ sourceOffset ], samples * 4 ); if( samples < FFT_STEP ) memset( rdi->mono.data() + samples, 0, ( FFT_STEP - samples ) * 4 ); }
PcmReader.cpp line50 void copyChunk( PcmMonoChunk* pMono, const AudioBuffer& rsi, size_t sourceOffset, size_t samples, PcmStereoChunk* pStereo ) const override final { line50 copyMono( pMono, rsi, sourceOffset, samples ); }
PcmReader.cpp line418 HRESULT PcmReader::readChunk( PcmMonoChunk& mono, PcmStereoChunk* stereo ){ if( availableSamples > 0 ) { // We have reached the end of stream of the reader, but the buffer still has a few samples. // Return the final incomplete chunk padded with zeros line418 sampleHandler->copyChunk( &mono, pcm, off, availableSamples, stereo ); bufferReadOffset = off + availableSamples; return S_OK; }}
MelStreamer.cpp line40 MelStreamer::ensurePcmChunks( size_t len ) { line 40 HRESULT hr = reader.readChunk( mono, stereo ); }
I have made a temporary bandage at PcmReader.cpp line 418 to skip the last availableSamples completely. It wouldn't effect my project to lose some data in my case. But the issue of (sourceOffset + samples) is bigger than buffer.size() still exist.
Here is the code to modify if you have this problem and does not mind skipping the last availableSamples. PcmReader.cpp line 418 if( availableSamples > 0 ) { // We have reached the end of stream of the reader, but the buffer still has a few samples. // Return the final incomplete chunk padded with zeros //sampleHandler->copyChunk( &mono, pcm, off, availableSamples, stereo ); //bufferReadOffset = off + availableSamples; return S_OK; }