refactor: Add regex check to detect false prediction in whisper-processing.cpp

This commit is contained in:
Roy Shilkrot
2024-06-03 00:34:38 -04:00
parent a6529a41d2
commit dfbacfff82

View File

@@ -18,6 +18,7 @@
#include <algorithm>
#include <chrono>
#include <regex>
struct vad_state {
bool vad_on;
@@ -275,6 +276,13 @@ struct DetectionResultWithText run_whisper_inference(struct transcription_filter
return {DETECTION_RESULT_SILENCE, "", t0, t1, {}};
}
// Check regex for "MBC .*" to detect false prediction
std::regex mbc_regex("MBC.*");
if (std::regex_match(text, mbc_regex)) {
obs_log(gf->log_level, "False prediction detected: %s", text.c_str());
return {DETECTION_RESULT_SILENCE, "", t0, t1, {}};
}
return {DETECTION_RESULT_SPEECH, text, t0, t1, tokens};
}
}