From 0e8c28d1fcc830d9b3d42d67c7f7cb6e9666c9ed Mon Sep 17 00:00:00 2001 From: Roy Shilkrot Date: Fri, 10 May 2024 08:47:38 -0400 Subject: [PATCH] refactor: Improve text conditioning logic in transcription-filter.cpp --- src/transcription-filter.cpp | 11 ++++++++--- src/whisper-utils/whisper-processing.h | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/transcription-filter.cpp b/src/transcription-filter.cpp index a612eed..e9e05e5 100644 --- a/src/transcription-filter.cpp +++ b/src/transcription-filter.cpp @@ -147,9 +147,14 @@ void set_text_callback(struct transcription_filter_data *gf, } gf->last_sub_render_time = now; - // recondition the text - std::string str_copy = fix_utf8(result.text); - str_copy = remove_leading_trailing_nonalpha(str_copy); + std::string str_copy = result.text; + + // recondition the text - only if the output is not English + if (gf->whisper_params.language != "en") { + str_copy = fix_utf8(str_copy); + } else { + str_copy = remove_leading_trailing_nonalpha(str_copy); + } // if suppression is enabled, check if the text is in the suppression list if (!gf->suppress_sentences.empty()) { diff --git a/src/whisper-utils/whisper-processing.h b/src/whisper-utils/whisper-processing.h index 6b764b1..7066d6d 100644 --- a/src/whisper-utils/whisper-processing.h +++ b/src/whisper-utils/whisper-processing.h @@ -6,9 +6,9 @@ // buffer size in msec #define DEFAULT_BUFFER_SIZE_MSEC 3000 // overlap in msec -#define DEFAULT_OVERLAP_SIZE_MSEC 150 +#define DEFAULT_OVERLAP_SIZE_MSEC 125 #define MAX_OVERLAP_SIZE_MSEC 1000 -#define MIN_OVERLAP_SIZE_MSEC 150 +#define MIN_OVERLAP_SIZE_MSEC 125 enum DetectionResult { DETECTION_RESULT_UNKNOWN = 0,