Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""Per-character dialogue parser — turns, expressive tags, voice assignment."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from app.services.audio.dialogue import parse_dialogue
|
|
|
|
|
|
def test_two_host_alternating_voices():
|
|
script = """Alex: Have you seen this?
|
|
Sam: No way, that's wild.
|
|
Alex: Right? It changed everything."""
|
|
result = parse_dialogue(script)
|
|
assert result.speakers == ("Alex", "Sam")
|
|
voices = {t.speaker: t.voice_id for t in result.turns}
|
|
# First-appearance order cycles the default voices.
|
|
assert voices["Alex"] == "host_a" and voices["Sam"] == "host_b"
|
|
assert len(result.turns) == 3
|
|
|
|
|
|
def test_expressive_tags_extracted_and_stripped():
|
|
script = "Alex: [laughs] I can't believe it (excited)"
|
|
result = parse_dialogue(script)
|
|
turn = result.turns[0]
|
|
assert turn.text == "I can't believe it" # tags removed
|
|
assert set(turn.tags) == {"laughs", "excited"}
|
|
|
|
|
|
def test_explicit_voice_mapping_wins():
|
|
result = parse_dialogue("Host: hi\nGuest: hello", voices={"Host": "eleven_rachel", "Guest": "eleven_josh"})
|
|
voices = {t.speaker: t.voice_id for t in result.turns}
|
|
assert voices["Host"] == "eleven_rachel" and voices["Guest"] == "eleven_josh"
|
|
|
|
|
|
def test_continuation_line_keeps_speaker():
|
|
script = """Alex: first thought
|
|
and a second thought on the same breath
|
|
Sam: my turn"""
|
|
result = parse_dialogue(script)
|
|
assert [t.speaker for t in result.turns] == ["Alex", "Alex", "Sam"]
|
|
|
|
|
|
def test_leading_line_without_speaker_is_narrator():
|
|
result = parse_dialogue("just an opening line\nAlex: hi")
|
|
assert result.turns[0].speaker == "narrator"
|
|
|
|
|
|
def test_tag_only_line_kept_as_expressive_beat():
|
|
# A line that is ONLY a tag (e.g. [pause]) is a legitimate expressive beat:
|
|
# kept with empty text + the tag so downstream TTS can render the pause.
|
|
result = parse_dialogue("Alex: [pause]")
|
|
assert len(result.turns) == 1
|
|
assert result.turns[0].text == "" and result.turns[0].tags == ("pause",)
|