Repository navigation
OmniVoice: match Python duration weights for Bengali marks, danda and digits - #1110
Merged
Merged
Conversation
… digits The duration estimator's char_weight() only treated Latin combining-mark blocks as marks, so every Bengali code point fell into the "indic" range and weighed 1.8. Python's RuleDurationEstimator classifies by Unicode category instead: vowel signs, hasanta, candrabindu/anusvara/visarga and nukta are marks (0), danda/double danda and Bengali currency/symbols are punctuation (0.5), Bengali digits are digits (3.5). The mismatch made audio.cpp pick a different number of target frames for Bengali text, so speech came out too fast or too slow depending on the mark density of the target vs. the reference text. Examples (same model, text and reference): long sentence, clone: Python 514 frames, audio.cpp 453 -> now 514 short sentence, clone: Python 124 frames, audio.cpp 118 -> now 124 short sentence, auto: Python 117 frames, audio.cpp 174 -> now 117 Code points are taken from Python's unicodedata (Unicode 13.0).
Owner
|
@kawshikbuet17 Good catch! PR merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OmniVoice's duration estimator (
char_weight()insrc/models/omnivoice/prompt_builder.cpp) gives Bengali combining marks and punctuation different weights from the reference Python implementation (RuleDurationEstimatorin k2-fsa/OmniVoice). As a result, audio.cpp picks a different number of target frames for Bengali text, and the speech comes out noticeably too fast or too slow. This PR makes the Bengali weights match Python.Problem
Python decides each character's weight from its Unicode category.
char_weight()only treats the Latin combining-mark blocks as marks, so every Bengali code point (U+0980–U+09FF) falls into theindicrange and gets 1.8:The estimate is
target_weight / ref_weight × ref_frames, so the error does not cancel out. It depends on how many marks the target and reference each contain, and it can go either way. Without a reference voice, the fallback reference is English and is not inflated, so Bengali output is always too long.Fix
Inside
char_weight(), just before the script-range lookup, classify Bengali-block marks, punctuation/symbols and digits (plus U+0964/U+0965 dandas) using the same categories as Python'sunicodedata(Unicode 13.0). Bengali letters are unchanged (still 1.8). No other scripts are affected.Results
Same model, text, reference audio and settings in Python OmniVoice and audio.cpp:
For the long sentence, the output WAV goes from 18.17 s to 20.76 s, matching Python's 20.76 s.
Testing
std::mt19937), as before.