mirror of
https://github.com/royshil/obs-localvocal.git
synced 2026-01-10 04:48:02 -05:00
refactor: Add regex check to detect false prediction in whisper-processing.cpp
This commit is contained in:
@@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user