Skip to content

Commit

Permalink
refactor: Improve text conditioning logic in transcription-filter.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed May 10, 2024
1 parent fc9383f commit 0e8c28d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/transcription-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions src/whisper-utils/whisper-processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0e8c28d

Please sign in to comment.