From 8ea08d534bda6733f44c59c60a8783863cb554a4 Mon Sep 17 00:00:00 2001 From: Matija Pevec Date: Fri, 27 Jan 2023 01:44:45 +0100 Subject: [PATCH] Update whisper.cpp --- whisper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/whisper.cpp b/whisper.cpp index d52143f..abfc7f1 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -2863,11 +2863,13 @@ static int whisper_wrap_segment(struct whisper_context & ctx, int max_len) { } const auto txt = whisper_token_to_str(&ctx, token.id); + std::string s = txt; const int cur = strlen(txt); - if (acc + cur > max_len && i > 0) { + if (acc + cur > max_len && i > 0 && s.substr(0, 1) == " ") { // split here + ::trim(text); ctx.result_all.back().text = std::move(text); ctx.result_all.back().t1 = token.t0; ctx.result_all.back().tokens.resize(i); @@ -2895,6 +2897,7 @@ static int whisper_wrap_segment(struct whisper_context & ctx, int max_len) { } } + ::trim(text); ctx.result_all.back().text = std::move(text); return res;