text + 1 can break a multibyte character, e.g., Chinese in UTF-8. There is no space at the beginning in this case. (cherry picked from commit 1d06e8ddcd8c14232d0a3c2b1c21e50b232549b4)
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -215,7 +215,9 @@ static void run_transcription(AVFilterContext *ctx, AVFrame *frame, int samples) · 214 unmodified lines | |||
| 215 | 215 | ||
| 216 | for (int i = 0; i < n_segments; ++i) { | 216 | for (int i = 0; i < n_segments; ++i) { |
| 217 | const char *text = whisper_full_get_segment_text(wctx->ctx_wsp, i); | 217 | const char *text = whisper_full_get_segment_text(wctx->ctx_wsp, i); |
| 218 | char *text_cleaned = av_strireplace(text + 1, "[BLANK_AUDIO]", ""); | 218 | if (av_isspace(text[0])) |
| 219 | text++; | ||
| 220 | char *text_cleaned = av_strireplace(text, "[BLANK_AUDIO]", ""); | ||
| 219 | 221 | ||
| 220 | if (av_strnlen(text_cleaned, 1) == 0) { | 222 | if (av_strnlen(text_cleaned, 1) == 0) { |
| 221 | av_freep(&text_cleaned); | 223 | av_freep(&text_cleaned); |