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

Function ngram_repeat_ratio

src/models/miotts/session.cpp:354–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352
353std::string detect_best_of_n_language(const std::string & text) {
354 const auto codepoints = utf8_codepoints(text, "MioTTS best_of_n text");
355 int64_t total = 0;
356 int64_t ja_count = 0;
357 int64_t en_count = 0;
358 for (const uint32_t cp : codepoints) {
359 if (cp == ' ' || cp == '\n' || cp == '\r' || cp == '\t') {
360 continue;
361 }
362 ++total;
363 if (is_japanese_codepoint(cp)) {
364 ++ja_count;
365 }
366 if (cp <= 0x7FU && is_ascii_alpha(static_cast<unsigned char>(cp))) {
367 ++en_count;
368 }
369 }
370 if (total == 0) {
371 return "auto";
372 }
373 if (static_cast<double>(ja_count) / static_cast<double>(total) >= 0.2) {
374 return "ja";

Callers 1

repeat_penaltyFunction · 0.85

Calls 2

to_stringFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected