feat(voice): ensembles, per-speaker filters, unlabelled sections, parallel GPUs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-20 08:20:09 +02:00
1 parent 381296dffa
commit f1581babe7
4 files changed
+118 -24

No files matched your search

+24
View File
@@ -148,3 +148,27 @@ def test_map_speeches_drops_merges_and_keeps_interjections():
assert map_speeches(source, [Target(0, "a", 120, "x"), Target(1, "b", 5, "y")]) == {1: 1}
# short interjections are paired whatever the ratio
assert map_speeches([sp("b", 1)], [Target(0, "b", 4, "y")]) == {0: 0}
def test_unlabelled_section_is_one_speech_by_the_default_speaker():
section = (
"\nIn der Kapelle, davor Blumen.\n\nAch neige,\nDu Schmerzenreiche,\n\nDein Antlitz.\n"
)
assert parse_speeches(section, {}) == []
(speech,) = parse_speeches(section, {}, default_speaker="margarita", skip_paragraphs=1)
assert speech.speaker == "margarita"
assert speech.text == "Ach neige, Du Schmerzenreiche, Dein Antlitz."
def test_map_speeches_pairs_ensemble_ids_in_sequence():
source = [sp("crowd", 10), sp("faust", 10), sp("crowd", 10)]
targets = [
Target(0, "artisans", 10, "a"),
Target(1, "faust", 10, "b"),
Target(2, "citizens", 10, "c"),
]
assert map_speeches(source, targets) == {1: 1} # different ids never pair by default
ensembles = frozenset({"crowd", "artisans", "citizens"})
assert map_speeches(source, targets, ensembles) == {0: 0, 1: 1, 2: 2}
# an individual never stands in for an ensemble
assert map_speeches([sp("faust", 10)], [Target(0, "citizens", 10, "x")], ensembles) == {}
+30
View File
@@ -74,3 +74,33 @@ def test_voice_clips_are_copied_outside_audio_and_credited(tmp_path):
(root / "voice/clips/talk_0009.ogg").unlink() # no clip, no credit, no voice
assert voice_mod.voice_files(work) == {}
assert "Voces" not in dict(renpy_gen.credits_sections(work, None))
def test_cut_clip_applies_the_speaker_chain_before_loudnorm(monkeypatch, tmp_path):
calls = []
class Result:
stderr = json.dumps(
{
"input_i": "-20",
"input_tp": "-3",
"input_lra": "5",
"input_thresh": "-30",
"target_offset": "0.1",
}
)
def fake_run(cmd, **kwargs):
calls.append(cmd)
return Result()
monkeypatch.setattr(voice_mod, "run", fake_run)
(tmp_path / "x.part.ogg").write_bytes(b"")
voice_mod.cut_clip(Path("a.mp3"), 1.0, 3.0, tmp_path / "x.ogg", "highpass=f=80")
filters = [c[c.index("-af") + 1] for c in calls]
assert len(filters) == 2
assert all(f.startswith("highpass=f=80,loudnorm=") for f in filters)
calls.clear()
(tmp_path / "x.part.ogg").write_bytes(b"")
voice_mod.cut_clip(Path("a.mp3"), 1.0, 3.0, tmp_path / "x.ogg")
assert all(c[c.index("-af") + 1].startswith("loudnorm=") for c in calls)