Skip to content

[Whisper]: Split on unicode non whitespace languages#4131

Open
as-suvorov wants to merge 1 commit into
openvinotoolkit:masterfrom
as-suvorov:as/whisper_word_timestamps_cn
Open

[Whisper]: Split on unicode non whitespace languages#4131
as-suvorov wants to merge 1 commit into
openvinotoolkit:masterfrom
as-suvorov:as/whisper_word_timestamps_cn

Conversation

@as-suvorov

@as-suvorov as-suvorov commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes #4113

Checklist:

  • This PR follows GenAI Contributing guidelines.
  • Tests have been updated or added to cover the new code.
  • This PR fully addresses the ticket.
  • [NA] I have made corresponding changes to the documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses incorrect Whisper word-level timestamps for no-space (scriptio continua) languages by making the token-to-word grouping logic language-aware and by propagating detected language into the word-timestamping path.

Changes:

  • Updates add_word_level_timestamps() to accept SotTokensResult (tokens + detected language) instead of raw sot_tokens.
  • Adds language-dependent splitting: uses unicode-based splitting for zh/ja/th/lo/my/yue, and space-based splitting otherwise.
  • Updates Whisper generation call sites to pass SotTokensResult through to word-timestamp generation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/cpp/src/whisper/word_level_timestamps.hpp Changes add_word_level_timestamps signatures to take SotTokensResult so language can influence splitting.
src/cpp/src/whisper/word_level_timestamps.cpp Introduces language-aware token splitting and uses detected language when generating word-level timestamps.
src/cpp/src/whisper/whisper.cpp Threads SotTokensResult through generation and into word-timestamp processing.
src/cpp/src/whisper/pipeline_static.cpp Threads SotTokensResult through the static pipeline and into word-timestamp processing.

Comment on lines +410 to +414
bool is_no_space_language(const std::string& language) {
static const std::set<std::string> no_space_languages = {"zh", "ja", "th", "lo", "my", "yue"};

return no_space_languages.count(language) > 0;
}
Comment on lines +418 to +422
split_to_word_tokens(const std::vector<int64_t>& tokens, ov::genai::Tokenizer& tokenizer, const std::string& language) {
if (is_no_space_language(language)) {
return split_tokens_on_unicode(tokens, tokenizer);
}
return split_tokens_on_spaces(tokens, tokenizer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Whisper word timestamps wrong for no-space languages (potential fix included)

2 participants