History

avfilter/af_whisper: fix broken output for multibyte character

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)

Zhao Zhili committed 1 year ago

Commit bb65f511 parent d1f31a81 file · +3 −1Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/af_whisper.c+3−1
@@ -215,7 +215,9 @@ static void run_transcription(AVFilterContext *ctx, AVFrame *frame, int samples) · 214 unmodified lines
215215
216216 for (int i = 0; i < n_segments; ++i) {
217217 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]", "");
219221
220222 if (av_strnlen(text_cleaned, 1) == 0) {
221223 av_freep(&text_cleaned);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t