summaryrefslogtreecommitdiffstats
path: root/Whisper/MF/AudioBuffer.h
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-02-26 18:57:07 -0800
committeryum <yum.food.vr@gmail.com>2023-02-26 19:49:40 -0800
commit00a0350a0218cf4b03d14acac84110bc1e882bee (patch)
tree433f8907ab398c9a53f79060a7f248f5352bbe51 /Whisper/MF/AudioBuffer.h
parenta6de8f9654c90c51713e77791ff7155f34d27c21 (diff)
Frames with no VAD are shortened, not dropped
On PCM buffers of length >= captureParams.dropStartSilence, a "no voice" VAD verdict would result in the PCM buffer being entirely cleared. The emergent behavior is that when VAD segments speech, words right after the segmentation window can frequently be dropped. By removing a prefix from the PCM buffer and clearing the VAD buffers, the transcription algorithm has access to "leading" frames before the frames which triggered VAD. This reduces cases where words are omitted in the middle of long statements.
Diffstat (limited to 'Whisper/MF/AudioBuffer.h')
-rw-r--r--Whisper/MF/AudioBuffer.h9
1 files changed, 9 insertions, 0 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