koby commited on
Commit
a8fb707
·
1 Parent(s): 4990590

outro check looks at song ending only

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -158,7 +158,9 @@ def generate(style, lyrics, cot, seed, cfg_scale, duration, ending):
158
  if not exact:
159
  # Natural: let the model finish on its own; close with a real [Outro]
160
  # tag (official YuE2 vocabulary) so it composes a proper ending.
161
- if not re.search(r"\[(outro|end|ending)\]", lyrics or "", re.I):
 
 
162
  lyrics = (lyrics or "").rstrip() + "\n[Outro]"
163
  gen_kwargs = dict(style=style, lyrics=lyrics, cot=cot, seed=seed)
164
  if cfg_scale and float(cfg_scale) != 1.0:
 
158
  if not exact:
159
  # Natural: let the model finish on its own; close with a real [Outro]
160
  # tag (official YuE2 vocabulary) so it composes a proper ending.
161
+ # Only the song's ENDING counts — a mid-song [outro] doesn't fool us.
162
+ tail = "\n".join([ln for ln in (lyrics or "").strip().splitlines() if ln.strip()][-3:])
163
+ if not re.search(r"\[(outro|end|ending)\]", tail, re.I):
164
  lyrics = (lyrics or "").rstrip() + "\n[Outro]"
165
  gen_kwargs = dict(style=style, lyrics=lyrics, cot=cot, seed=seed)
166
  if cfg_scale and float(cfg_scale) != 1.0: