MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / punctuation_bonus_seconds

Function punctuation_bonus_seconds

src/models/miotts/session.cpp:390–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390double punctuation_bonus_seconds(const std::string & text) {
391 double bonus = 0.0;
392 for (size_t i = 0; i < text.size(); ++i) {
393 const char ch = text[i];
394 if (ch == '.' && i + 2 < text.size() && text[i + 1] == '.' && text[i + 2] == '.') {
395 bonus += 1.0;
396 i += 2;
397 } else if (ch == ',' || ch == ';' || ch == ':') {
398 bonus += 0.20;
399 } else if (ch == '.' || ch == '!' || ch == '?') {
400 bonus += 0.40;
401 } else if (ch == '-' && i + 1 < text.size() && text[i + 1] == '-') {
402 bonus += 0.12;
403 ++i;
404 }
405 }
406 if (!text.empty()) {
407 const char last = text.back();
408 if ((last == '.' || last == '!' || last == '?') && bonus >= 0.40) {
409 bonus -= 0.40;
410 }
411 }
412 return std::min(10.0, bonus);
413}
414
415double length_penalty(const std::string & text, const std::vector<int32_t> & tokens, const std::string & language) {
416 const double duration_sec = static_cast<double>(tokens.size()) / kBestOfNTokenRateHz;

Callers 1

length_penaltyFunction · 0.85

Calls 3

minFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected