Sentences often end abruptly with the female voice styles (speech cut off while still loud), also with the reference runtime

#32
by sky-node - opened

Summary

With some takes, the speech stops while it is still at full volume, and the audio drops to the noise floor within about 20–30 ms. It sounds like someone pressed a mute button in the middle of the last sound. It happens much more often with the female voice styles than the male ones, and it is not specific to one language. It reproduces with the reference runtime (py/helper.py) and the full-precision onnx/ files, so it is not caused by quantization or by a third-party runtime.

What I measured

For each take I measure how loud the speech still is where it stops: the level of the last 5 ms frame that is louder than -45 dB, in dB below the take's peak. A take whose end is above -35 dB counts as "abrupt". Natural endings decay to about -40 dB or quieter; the abrupt ones end as loud as -12 to -25 dB.

Reference runtime, full-precision models, total_step=16, speed=1.0, 24 short sentences in 12 languages (ru, hu, tr, ja, ko, ar, hi, sv, en, de, fr, es) × 6 seeds = 144 takes per voice:

Voice style Takes that end abruptly
F1 28%
F2 9%
M1 3%

The same measurement through sherpa-onnx 1.13.8 gives F1 / F2 / M1 of 29% / 16% / 3% with the int8 models and 23% / 15% / 3% with the full-precision models, so the runtime and the quantization make no real difference.

With a cruder measure (the fade-out from -25 dB to -50 dB taking under 60 ms) on 10 languages × 2 sentences, all five female styles ended abruptly in 70–85% of sentences, against 35–45% for M1, M2, M4 and M5 (M3 was 75%). That was a single run per sentence, so treat it as rough.

Observations

  • With a fixed random seed (np.random.seed) a take is identical every time. Changing only the seed changes whether the sentence ends cleanly, so the noise draw decides it.
  • The predicted duration is the same for every seed (the raw clips have identical length), and there is audio after the point where the speech stops (about 0.3–0.6 s of low-level noise in the examples I looked at). So the abrupt stop is inside the generated audio, not just a crop at the predicted length.
  • Things that did not remove it: 32 denoising steps instead of 16, adding or removing the final punctuation, a trailing space, a different speed. Slowing the speech only helped partly (F1: 32% abrupt at speed 1.0, 21% at 0.85, 120 takes each), and it makes the speech slower.
  • I also tried fading the audio at the detected end. That hides the click but also cut the last word off one Russian male take, so I don't think it is safe to post-process.

Reproduction

Needs py/helper.py from the repo next to the script, and the onnx/ and voice_styles/ folders from this model in ./supertonic-3/.

import numpy as np

import helper

MODEL = "supertonic-3"
TEXTS = [
    ("ru", "Здравствуйте."), ("ru", "Как у вас дела сегодня?"),
    ("hu", "Jó napot."), ("hu", "Hogy van ma?"),
    ("tr", "Merhaba."), ("tr", "Bugün nasılsınız?"),
    ("ja", "こんにちは。"), ("ja", "今日はお元気ですか?"),
    ("ko", "안녕하세요."), ("ko", "오늘 어떠세요?"),
    ("ar", "مرحباً."), ("ar", "كيف حالك اليوم؟"),
    ("hi", "नमस्ते।"), ("hi", "आज आप कैसे हैं?"),
    ("sv", "Hej."), ("sv", "Hur mår du idag?"),
    ("en", "Hello."), ("en", "How are you today?"),
    ("de", "Guten Tag."), ("de", "Wie geht es Ihnen heute?"),
    ("fr", "Bonjour."), ("fr", "Comment allez-vous aujourd'hui ?"),
    ("es", "Hola."), ("es", "¿Cómo estás hoy?"),
]
SEEDS = range(6)

tts = helper.load_text_to_speech(f"{MODEL}/onnx")


def end_level_db(wav, sr):
    """Level of the last 5 ms frame above -45 dB, in dB below the take's peak."""
    peak = np.abs(wav).max()
    frame = int(sr * 0.005)
    for k in range(len(wav) // frame - 1, -1, -1):
        rms = np.sqrt(np.mean(wav[k * frame : (k + 1) * frame].astype(np.float64) ** 2))
        level = 20 * np.log10(max(rms, 1e-9) / peak)
        if level > -45:
            return level
    return -np.inf


for voice in ("F1", "F2", "M1"):
    style = helper.load_voice_style([f"{MODEL}/voice_styles/{voice}.json"])
    levels = []
    for lang, text in TEXTS:
        for seed in SEEDS:
            np.random.seed(seed)
            wav, duration = tts(text, lang, style, total_step=16, speed=1.0)
            wav = wav[0, : int(tts.sample_rate * duration[0].item())]
            levels.append(end_level_db(wav, tts.sample_rate))
    levels = np.array(levels)
    print(f"{voice}: {np.mean(levels > -35):4.0%} of {len(levels)} takes are still louder than -35 dB when they stop "
          f"(median {np.median(levels):.0f} dB, loudest {levels.max():.0f} dB)")

Output on my machine (onnxruntime 1.31.1, CPU):

F1:  28% of 144 takes are still louder than -35 dB when they stop (median -40 dB, loudest -17 dB)
F2:   9% of 144 takes are still louder than -35 dB when they stop (median -43 dB, loudest -12 dB)
M1:   3% of 144 takes are still louder than -35 dB when they stop (median -43 dB, loudest -25 dB)

Questions

  1. Is this known or expected for the female styles? Is it something the style vectors cause, or the latent/vocoder?
  2. Is there a recommended way to avoid it, for example a setting I missed, a longer duration margin, or a different step schedule?
  3. Is generating a few takes and keeping the one that ends quietly a sensible workaround? That is what I do now (it costs about 1.3 renders per sentence for F1), but I would prefer a fix in the model or its recommended settings.

I can attach audio examples of an abrupt and a clean take of the same sentence if that helps.

Sign up or log in to comment