Keep the TTS echo at unity gain so the level drives the repeats

This commit is contained in:
Fisto
2026-09-21 18:29:13 +02:00
parent 63083c54ec
commit 267c31337c
4 changed files with 24 additions and 6 deletions
+1 -1
View File
@@ -665,7 +665,7 @@ Inputs: `{out}`, `{text_file}`, optional positional voice/speed/pitch/expression
| --- | --- |
| `VESKSLOP_TTS_PROFILE` | `pitch:27:...`/`key=value,...` overrides; the wrapper writes the full profile (defaults + overrides) to the Wine registry with `wine reg import` before every synthesis. |
| `VESKSLOP_TTS_HIGHPASS` | High-pass Hz, 40-400 (default 40). |
| `VESKSLOP_TTS_ECHO` | Mono echo 0-100 (`aecho`), default 0. |
| `VESKSLOP_TTS_ECHO` | Mono echo 0-100 (`aecho`), default 0. The echo is mixed under the dry voice, so the voice level does not change. |
| `VESKSLOP_TTS_WORDS` / `VESKSLOP_TTS_WORD_GAP_MS` | Word-by-word synthesis with silence gaps (Flextalk only). |
Placeholders `{profile}`, `{highpass}`, `{echo}`, `{words}`, `{word_gap_ms}` mirror the env vars.
+13 -3
View File
@@ -17,7 +17,8 @@
# VESKSLOP_TTS_HIGHPASS high-pass Hz (40-400, default 40)
# VESKSLOP_TTS_ECHO mono echo amount 0-100 (default 0)
# VESKSLOP_TTS_ECHO_DELAY_MS echo delay 10-400 (default 60)
# VESKSLOP_TTS_ECHO_LEVEL echo output gain 0-0.95 (default 0.85)
# VESKSLOP_TTS_ECHO_LEVEL echo repeat level 0-0.95, relative to the
# dry voice (default 0.85)
# VESKSLOP_TTS_CRUNCH off | hl90 | hl90hq | telephone | adpcm | crush
# (1990s lossy character, applied last)
# VESKSLOP_TTS_CRUNCH_BITS 1-16, overrides the preset bit depth
@@ -495,9 +496,18 @@ ECHO_LEVEL=$(awk -v v="$ECHO_LEVEL" 'BEGIN{ if (v<0) v=0; if (v>0.95) v=0.95; pr
SIL="silenceremove=start_periods=1:start_duration=0.05:start_silence=0.03:start_threshold=-50dB"
PRE="highpass=f=$HIGHPASS,$SIL,afade=t=in:st=0:d=0.008,areverse,$SIL,afade=t=in:st=0:d=0.008,areverse"
# aecho's in_gain/out_gain scale the dry signal as well, so a low ECHO_LEVEL used to
# quiet the whole line (and the streaming path, which skips the loudness measurement,
# had nothing to make it up). Keep both gains at unity and let the repeats' decay carry
# the level; the limiter absorbs the summed peaks.
if [ "$ECHO" -gt 0 ]; then
DECAY=$(awk -v e="$ECHO" 'BEGIN{printf "%.2f", 0.2 + e * 0.006}')
PRE="$PRE,aecho=0.8:${ECHO_LEVEL}:${ECHO_DELAY}:${DECAY}"
DECAY=$(awk -v e="$ECHO" -v l="$ECHO_LEVEL" 'BEGIN{
d = (0.2 + e * 0.006) * (l / 0.85);
if (d < 0.02) d = 0.02;
if (d > 0.95) d = 0.95;
printf "%.2f", d
}')
PRE="$PRE,aecho=1:1:${ECHO_DELAY}:${DECAY},alimiter=limit=0.98:level=disabled"
fi
# Compression stage ("crunch"): the lossy 1990s codec character, built as its own