diff options
| -rw-r--r-- | Whisper/MF/AudioBuffer.h | 9 | ||||
| -rw-r--r-- | Whisper/Whisper/ContextImpl.capture.cpp | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Whisper/MF/AudioBuffer.h b/Whisper/MF/AudioBuffer.h index 93a6ace..b12dff4 100644 --- a/Whisper/MF/AudioBuffer.h +++ b/Whisper/MF/AudioBuffer.h @@ -43,5 +43,14 @@ namespace Whisper if( !stereo.empty() ) stereo.resize( len * 2 ); } + + void dropFirst(size_t len) + { + assert(len <= mono.size()); + size_t remainder = mono.size() - len; + auto tmp = std::vector<float>(remainder); + memcpy(tmp.data(), mono.data() + len, remainder); + mono = std::move(tmp); + } }; }
\ No newline at end of file diff --git a/Whisper/Whisper/ContextImpl.capture.cpp b/Whisper/Whisper/ContextImpl.capture.cpp index 0062c2a..0b213b8 100644 --- a/Whisper/Whisper/ContextImpl.capture.cpp +++ b/Whisper/Whisper/ContextImpl.capture.cpp @@ -242,7 +242,7 @@ namespace if( newSamples < captureParams.dropStartSilence ) return S_OK; - pcm.clear(); + pcm.dropFirst(1024); vad.clear(); pcmStartTime = nextSampleTime; return S_OK; |
