braidio 0.0.74__tar.gz → 0.0.75__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {braidio-0.0.74 → braidio-0.0.75}/PKG-INFO +1 -1
- {braidio-0.0.74 → braidio-0.0.75}/braidio/bodies/_domain.py +14 -1
- {braidio-0.0.74 → braidio-0.0.75}/braidio/render.py +21 -6
- {braidio-0.0.74 → braidio-0.0.75}/braidio/timeline.py +8 -1
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_episode.py +33 -15
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_ingest.py +1 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_voice.py +9 -15
- {braidio-0.0.74 → braidio-0.0.75}/braidio/weave.py +194 -8
- {braidio-0.0.74 → braidio-0.0.75}/braidio/weave_config.py +98 -3
- {braidio-0.0.74 → braidio-0.0.75}/pyproject.toml +1 -1
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_body_schema_stability.py +1 -0
- braidio-0.0.75/tests/test_turn_overlap.py +471 -0
- {braidio-0.0.74 → braidio-0.0.75}/.editorconfig +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/.gitattributes +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/.gitignore +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/LICENSE +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/README.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/_paths.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/bodies/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/bodies/_render_nodes.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/bodies/_tiers.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/bodies/_video.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/captions.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/compose.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/conversation.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/cost.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/data/skills/braidio/SKILL.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/data/skills/braidio-commentary-video/SKILL.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/defaults.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/delivery.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/downloads.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/formats.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/genre.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/importing/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/importing/__main__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/importing/_catalog.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/importing/_manifest.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/importing/_writer.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/kinds.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/markdown_script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/_docs.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/_guide.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/_helpers.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/_media.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/credentials.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/metering.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/tools.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/mcp/workspace.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/multivoice.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/music.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/pacing.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/project.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/provenance.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/relevance.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/rights.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/sources.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/structure.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/style.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/textprep.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_asset_refs.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_common.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_dialogue.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_narration.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_segment.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_video_cut.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/transforms/_video_panels.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/tts.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/video.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/braidio/voice_library.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/conftest.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/Extraction and nw-App Design.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/research/commentary-formats-and-styles.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/research/conversational-vs-narration-tts.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/research/notebooklm-and-conversational-pacing.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/README.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/anti-platitude-checklist.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/commentary-voice-guide.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/_style-groups.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/amanda-dobbins.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/david-sims.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/griffin-newman.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/helen-molesworth.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/hrishikesh-hirway.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/jason-mantzoukas.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/john-mcwhorter.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/jon-caramanica.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/june-diane-raphael.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/karina-longworth.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/katy-hessel.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/louis-theroux.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/mallory-rubin.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/melvyn-bragg.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/michael-barbaro.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/nate-sloan-charlie-harding.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/paul-scheer.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/sean-fennessey.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/talk-art.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/style/voices/yasi-salek.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/misc/docs/youtube_ingest_credentials.md +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/_audio.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_conversation.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_cost.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_credits_card.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_defaults.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_delivery.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_downloads.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_expressiveness.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_formats.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_genre_placement.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_importing.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_markdown_script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_mcp.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_mcp_caller_key.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_media_auth.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_multivoice.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_music.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_namespaced_source.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_nw_app.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_pacing.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_packaging.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_render_settings.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_sources.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_structure.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_textprep_style.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_timeline.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_transforms.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_transforms_dialogue.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_transforms_episode_members.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_transforms_rights.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_transforms_secrets.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_transforms_structure.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_tts_api_key.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_video.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_video_bodies.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_video_footage.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_video_transforms.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_voice_library.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_weave.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_weave_config.py +0 -0
- {braidio-0.0.74 → braidio-0.0.75}/tests/test_wire_descriptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: braidio
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.75
|
|
4
4
|
Summary: Weave narration with extracted media segments into audiovisual productions
|
|
5
5
|
Project-URL: Homepage, https://github.com/thorwhalen/braidio
|
|
6
6
|
Project-URL: Repository, https://github.com/thorwhalen/braidio
|
|
@@ -12,7 +12,7 @@ from __future__ import annotations
|
|
|
12
12
|
|
|
13
13
|
from typing import Literal, Optional
|
|
14
14
|
|
|
15
|
-
from pydantic import BaseModel, Field
|
|
15
|
+
from pydantic import BaseModel, Field, model_serializer
|
|
16
16
|
|
|
17
17
|
from lacing.schema import register_body_schema
|
|
18
18
|
|
|
@@ -110,6 +110,19 @@ class NarrativeBeatBodyV1(BaseModel):
|
|
|
110
110
|
default_factory=tuple,
|
|
111
111
|
description="Ids this beat is derived from (commentary / source / clip nodes).",
|
|
112
112
|
)
|
|
113
|
+
voice: Optional[str] = Field(
|
|
114
|
+
None, description="Per-beat voice id; overrides the weave-config pool."
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
@model_serializer(mode="wrap")
|
|
118
|
+
def _omit_unset_voice(self, handler):
|
|
119
|
+
"""Leave ``voice`` out while unset, so a body written before the field
|
|
120
|
+
existed is byte-identical on re-write (every writer, not one call site)."""
|
|
121
|
+
data = handler(self)
|
|
122
|
+
if data.get("voice") is None:
|
|
123
|
+
data.pop("voice", None)
|
|
124
|
+
return data
|
|
125
|
+
|
|
113
126
|
plays_clip: Optional[str] = Field(
|
|
114
127
|
None, description="Id of an audio-clip/v1 to play here."
|
|
115
128
|
)
|
|
@@ -38,7 +38,7 @@ from braidio.sources import SegmentSource
|
|
|
38
38
|
from braidio.structure import DEFAULT_STRUCTURE, prepare_pause, prepare_sting
|
|
39
39
|
from braidio.tts import narrate
|
|
40
40
|
from braidio.weave import TimelineItem, extract_padded, weave_timeline
|
|
41
|
-
from braidio.weave_config import WeaveConfig
|
|
41
|
+
from braidio.weave_config import WeaveConfig, speaker_key
|
|
42
42
|
|
|
43
43
|
_DEFAULT_LUFS = -16.0
|
|
44
44
|
_TRUE_PEAK = -1.5
|
|
@@ -337,6 +337,7 @@ def render_production(
|
|
|
337
337
|
spans: list[tuple[float, float] | None] = [] # source [start,end) for clips
|
|
338
338
|
labels: list[str] = []
|
|
339
339
|
spotlights: list[bool] = [] # per part: the bed drops out over it
|
|
340
|
+
speakers: list[str | None] = [] # per part: voice id talking (None: clip/sting)
|
|
340
341
|
for i, pb in enumerate(plan.beats):
|
|
341
342
|
orig = script.beats[pb.from_index]
|
|
342
343
|
clip_span: tuple[float, float] | None = None
|
|
@@ -358,9 +359,13 @@ def render_production(
|
|
|
358
359
|
labels.append(orig.label)
|
|
359
360
|
spans.append(None)
|
|
360
361
|
spotlights.append(False)
|
|
362
|
+
speakers.append(None)
|
|
361
363
|
continue
|
|
362
364
|
if pb.kind == "narration":
|
|
363
|
-
|
|
365
|
+
# per-beat override > the render's voice > the config's pool pick
|
|
366
|
+
beat_voice = getattr(orig, "voice", None) or voice_id
|
|
367
|
+
if beat_voice is None and config is not None:
|
|
368
|
+
beat_voice = config.cast_voice(pb.from_index)
|
|
364
369
|
beat_settings = (
|
|
365
370
|
getattr(orig, "voice_settings", None) or delivery.voice_settings
|
|
366
371
|
)
|
|
@@ -431,6 +436,8 @@ def render_production(
|
|
|
431
436
|
if normalize
|
|
432
437
|
else raw
|
|
433
438
|
)
|
|
439
|
+
# a dialogue beat is several speakers in one file: it never interrupts
|
|
440
|
+
speakers.append(speaker_key(beat_voice) if pb.kind == "narration" else None)
|
|
434
441
|
# dialogue + narration are spoken → treated as "narration" on the timeline
|
|
435
442
|
kinds.append("clip" if pb.kind == "clip" else "narration")
|
|
436
443
|
# a "under" clip becomes a ducked underlay; "before"/"after" play clean
|
|
@@ -457,9 +464,13 @@ def render_production(
|
|
|
457
464
|
has_under = "under" in placements
|
|
458
465
|
edge_overlap = config.clip_edge_overlap_s if config is not None else 0.0
|
|
459
466
|
crossfade = config.crossfade_s if config is not None else crossfade_s
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
467
|
+
turn_overlap = config.turn_overlap() if config is not None else None
|
|
468
|
+
# a music bed also needs the mix path (even for narration-only productions);
|
|
469
|
+
# so does a speaker interruption, which a plain concat cannot place
|
|
470
|
+
woven = (
|
|
471
|
+
music_bed is not None
|
|
472
|
+
or ("clip" in kinds and (edge_overlap > 0 or has_under))
|
|
473
|
+
or (turn_overlap is not None and turn_overlap.max_s > 0)
|
|
463
474
|
)
|
|
464
475
|
|
|
465
476
|
if woven:
|
|
@@ -470,8 +481,9 @@ def render_production(
|
|
|
470
481
|
placement=pl,
|
|
471
482
|
duck_db=(duck_db if pl == "under" else 0.0),
|
|
472
483
|
spotlight=sp,
|
|
484
|
+
speaker=spk,
|
|
473
485
|
)
|
|
474
|
-
for k, p, pl, sp in zip(kinds, parts, placements, spotlights)
|
|
486
|
+
for k, p, pl, sp, spk in zip(kinds, parts, placements, spotlights, speakers)
|
|
475
487
|
]
|
|
476
488
|
weave_timeline(
|
|
477
489
|
items,
|
|
@@ -480,6 +492,7 @@ def render_production(
|
|
|
480
492
|
narration_crossfade_s=crossfade,
|
|
481
493
|
target_lufs=target_lufs,
|
|
482
494
|
bed=music_bed,
|
|
495
|
+
overlap=turn_overlap,
|
|
483
496
|
)
|
|
484
497
|
else:
|
|
485
498
|
# `crossfade`, not `crossfade_s`: the config's crossfade was read by the
|
|
@@ -507,6 +520,8 @@ def render_production(
|
|
|
507
520
|
source_spans=spans,
|
|
508
521
|
clip_edge_overlap_s=edge_overlap,
|
|
509
522
|
narration_crossfade_s=crossfade,
|
|
523
|
+
speakers=speakers,
|
|
524
|
+
overlap=turn_overlap,
|
|
510
525
|
title=script.title,
|
|
511
526
|
# The settings that produced these timings, not the ones asked for:
|
|
512
527
|
# `crossfade`/`edge_overlap`/`target_lufs`/`duck_db` are the values
|
|
@@ -26,7 +26,7 @@ import html as _html
|
|
|
26
26
|
from dataclasses import dataclass, field
|
|
27
27
|
from typing import TYPE_CHECKING, Any, Mapping
|
|
28
28
|
|
|
29
|
-
from braidio.weave import layout_placed
|
|
29
|
+
from braidio.weave import TurnOverlap, layout_placed
|
|
30
30
|
|
|
31
31
|
if TYPE_CHECKING: # pragma: no cover - typing only
|
|
32
32
|
from braidio.delivery import Delivery
|
|
@@ -200,6 +200,8 @@ def build_timeline(
|
|
|
200
200
|
narration_crossfade_s: float = 0.12,
|
|
201
201
|
title: str = "",
|
|
202
202
|
settings: Mapping[str, Any] | None = None,
|
|
203
|
+
speakers: list[str | None] | None = None,
|
|
204
|
+
overlap: TurnOverlap | None = None,
|
|
203
205
|
) -> TimelineBreakdown:
|
|
204
206
|
"""Assemble a :class:`TimelineBreakdown` from per-beat render data (pure).
|
|
205
207
|
|
|
@@ -208,6 +210,9 @@ def build_timeline(
|
|
|
208
210
|
the per-beat ``"sequential"``/``"under"`` used by the weave; offsets are
|
|
209
211
|
computed with the same :func:`~braidio.weave.layout_placed` the renderer uses.
|
|
210
212
|
|
|
213
|
+
``speakers`` (one voice id per beat, ``None`` for a clip/sting) and ``overlap``
|
|
214
|
+
place a change of speaker as an interruption — pass what the render passed.
|
|
215
|
+
|
|
211
216
|
``settings`` is the optional render record (:func:`render_settings`) — what
|
|
212
217
|
produced these durations. It stays optional so building a timeline by hand
|
|
213
218
|
(tests, a hand-cut episode, the captions/video doctests) needs nothing
|
|
@@ -224,6 +229,8 @@ def build_timeline(
|
|
|
224
229
|
placements,
|
|
225
230
|
clip_edge_overlap_s=clip_edge_overlap_s,
|
|
226
231
|
narration_crossfade_s=narration_crossfade_s,
|
|
232
|
+
speakers=speakers,
|
|
233
|
+
overlap=overlap,
|
|
227
234
|
)
|
|
228
235
|
spans = tuple(
|
|
229
236
|
BeatSpan(
|
|
@@ -67,6 +67,7 @@ from nw.transforms._provenance import derive_provenance
|
|
|
67
67
|
|
|
68
68
|
from braidio.weave import TimelineItem
|
|
69
69
|
from braidio.timeline import TimelineBreakdown, build_timeline
|
|
70
|
+
from braidio.weave_config import WeaveConfig, speaker_key, turn_overlap_of
|
|
70
71
|
from braidio.bodies._domain import SCENE_BREAK_V1
|
|
71
72
|
from braidio.rights import (
|
|
72
73
|
DEFAULT_PROFILE,
|
|
@@ -93,6 +94,7 @@ from braidio.transforms._common import (
|
|
|
93
94
|
TIER_PRODUCTION_STRUCTURE,
|
|
94
95
|
TIER_RENDER_PROFILE,
|
|
95
96
|
TIER_NARRATION_RENDER,
|
|
97
|
+
TIER_VOICE_ASSIGNMENT,
|
|
96
98
|
TIER_DIALOGUE_RENDER,
|
|
97
99
|
TIER_SEGMENT_EXTRACTION,
|
|
98
100
|
TIER_SCENE_BREAK,
|
|
@@ -117,14 +119,6 @@ NAME = "weave_to_episode.default"
|
|
|
117
119
|
#: convention in ``braidio.render``), so a span planner can see what is said.
|
|
118
120
|
_LABEL_SNIPPET_CHARS = 48
|
|
119
121
|
|
|
120
|
-
# Weave defaults, applied when the weave-config snapshot omits a knob. They
|
|
121
|
-
# mirror braidio.weave.weave_timeline's own signature defaults.
|
|
122
|
-
_DEFAULT_CLIP_EDGE_OVERLAP_S = 0.5
|
|
123
|
-
_DEFAULT_CROSSFADE_S = 0.12
|
|
124
|
-
_DEFAULT_TARGET_LUFS = -16.0
|
|
125
|
-
_DEFAULT_TRUE_PEAK = -1.0
|
|
126
|
-
_DEFAULT_SAMPLE_RATE = 44100
|
|
127
|
-
|
|
128
122
|
|
|
129
123
|
def _structure_and_bed(node: Annotation | None):
|
|
130
124
|
"""``(MusicStructure, MusicBed | None)`` from a ``production-structure`` node.
|
|
@@ -150,10 +144,8 @@ def _structure_and_bed(node: Annotation | None):
|
|
|
150
144
|
|
|
151
145
|
def _layout_knobs(config: dict) -> tuple[float, float]:
|
|
152
146
|
"""``(clip_edge_overlap_s, narration_crossfade_s)`` from a weave-config snapshot."""
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
float(config.get("crossfade_s", _DEFAULT_CROSSFADE_S)),
|
|
156
|
-
)
|
|
147
|
+
cfg = WeaveConfig.from_snapshot(config)
|
|
148
|
+
return cfg.clip_edge_overlap_s, cfg.crossfade_s
|
|
157
149
|
|
|
158
150
|
|
|
159
151
|
def _member_role(member: Annotation, index: dict, *, structure):
|
|
@@ -183,6 +175,22 @@ def _member_role(member: Annotation, index: dict, *, structure):
|
|
|
183
175
|
return style, text[:_LABEL_SNIPPET_CHARS], None
|
|
184
176
|
|
|
185
177
|
|
|
178
|
+
def _member_speaker(member: Annotation, index: dict) -> str | None:
|
|
179
|
+
"""The voice a member talks with, for speaker interruption (``None``: nobody).
|
|
180
|
+
|
|
181
|
+
Only a narration render has one — the voice its ``voice-assignment`` parent
|
|
182
|
+
carries. A dialogue render is several speakers in one file, a clip or a
|
|
183
|
+
break has none: the same rule as ``braidio.render``'s ``speakers``.
|
|
184
|
+
"""
|
|
185
|
+
if member.tier != TIER_NARRATION_RENDER:
|
|
186
|
+
return None
|
|
187
|
+
va = next(
|
|
188
|
+
(p for p in resolve_parents(member, index) if p.tier == TIER_VOICE_ASSIGNMENT),
|
|
189
|
+
None,
|
|
190
|
+
)
|
|
191
|
+
return speaker_key(va.body.get("voice_id")) if va is not None else None
|
|
192
|
+
|
|
193
|
+
|
|
186
194
|
def member_timeline(
|
|
187
195
|
members,
|
|
188
196
|
durations,
|
|
@@ -208,6 +216,7 @@ def member_timeline(
|
|
|
208
216
|
labels.append(label)
|
|
209
217
|
spans.append(span)
|
|
210
218
|
edge_overlap_s, crossfade_s = _layout_knobs(config)
|
|
219
|
+
speakers = [_member_speaker(m, index) for m in members]
|
|
211
220
|
return build_timeline(
|
|
212
221
|
kinds=roles,
|
|
213
222
|
durations=[float(d) for d in durations],
|
|
@@ -215,6 +224,8 @@ def member_timeline(
|
|
|
215
224
|
source_spans=spans,
|
|
216
225
|
clip_edge_overlap_s=edge_overlap_s,
|
|
217
226
|
narration_crossfade_s=crossfade_s,
|
|
227
|
+
speakers=speakers,
|
|
228
|
+
overlap=turn_overlap_of(config),
|
|
218
229
|
title=title,
|
|
219
230
|
settings={
|
|
220
231
|
"weave": dict(config),
|
|
@@ -648,7 +659,8 @@ class WeaveToEpisode(BaseTransform):
|
|
|
648
659
|
structure, bed = _structure_and_bed(
|
|
649
660
|
next((a for a in parents if a.tier == TIER_PRODUCTION_STRUCTURE), None)
|
|
650
661
|
)
|
|
651
|
-
|
|
662
|
+
weave = WeaveConfig.from_snapshot(config) # omitted knobs → the defaults
|
|
663
|
+
target_lufs = weave.target_lufs
|
|
652
664
|
|
|
653
665
|
breaks_dir = project.root / "data" / "breaks"
|
|
654
666
|
items = [
|
|
@@ -679,15 +691,20 @@ class WeaveToEpisode(BaseTransform):
|
|
|
679
691
|
|
|
680
692
|
out_path = project.root / "data" / "episodes" / f"{skel.id}.mp3"
|
|
681
693
|
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
694
|
+
# Interruption is off unless the config asks: leave the call exactly as
|
|
695
|
+
# it was for a project that never set it (the absence rule, as above).
|
|
696
|
+
overlap = turn_overlap_of(config) # also what member_timeline laid out
|
|
697
|
+
overlap_kw = {"overlap": overlap} if overlap.is_on else {}
|
|
682
698
|
braidio.weave_timeline(
|
|
683
699
|
items,
|
|
684
700
|
out_path,
|
|
685
701
|
clip_edge_overlap_s=edge_overlap_s,
|
|
686
702
|
narration_crossfade_s=crossfade_s,
|
|
687
703
|
target_lufs=target_lufs,
|
|
688
|
-
true_peak=
|
|
689
|
-
sample_rate=
|
|
704
|
+
true_peak=weave.true_peak_dbtp,
|
|
705
|
+
sample_rate=weave.sample_rate,
|
|
690
706
|
bed=bed,
|
|
707
|
+
**overlap_kw,
|
|
691
708
|
)
|
|
692
709
|
duration = safe_duration(out_path)
|
|
693
710
|
artifact = audio_artifact(
|
|
@@ -751,6 +768,7 @@ class WeaveToEpisode(BaseTransform):
|
|
|
751
768
|
kind="clip" if is_clip else "narration",
|
|
752
769
|
path=str(url_to_path(member.body["url"])),
|
|
753
770
|
placement="sequential",
|
|
771
|
+
speaker=_member_speaker(member, index),
|
|
754
772
|
spotlight=(
|
|
755
773
|
is_clip
|
|
756
774
|
and bed is not None
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A deterministic, no-synthesis Transform: given a narrative beat and the
|
|
4
4
|
weave-config (the voice pool + seed), it records which voice the beat's
|
|
5
|
-
narration will use. It derives from ``[beat, weave-config]`` so a pool/seed
|
|
5
|
+
narration will use — the beat's own ``voice`` when it names one. It derives from ``[beat, weave-config]`` so a pool/seed
|
|
6
6
|
change re-stales every voice-assignment (and, transitively, the narration
|
|
7
7
|
renders that read them) — the freshness edge braidio's ``record_render``
|
|
8
8
|
models, now on the nw project graph.
|
|
@@ -29,6 +29,7 @@ from braidio.bodies._render_nodes import (
|
|
|
29
29
|
VoiceAssignmentBodyV1,
|
|
30
30
|
)
|
|
31
31
|
from braidio.tts import DEFAULT_VOICE_ID
|
|
32
|
+
from braidio.weave_config import WeaveConfig
|
|
32
33
|
from braidio.transforms._common import (
|
|
33
34
|
TIER_VOICE_ASSIGNMENT,
|
|
34
35
|
fresh_equivalent,
|
|
@@ -38,15 +39,6 @@ from braidio.transforms._common import (
|
|
|
38
39
|
NAME = "beat_to_voice_assignment.default"
|
|
39
40
|
|
|
40
41
|
|
|
41
|
-
def _pick_voice(voices: list[str], *, seed: int, ordinal: int) -> str:
|
|
42
|
-
"""Deterministic voice for beat ``ordinal`` from ``voices`` (+ ``seed``)."""
|
|
43
|
-
if not voices:
|
|
44
|
-
return DEFAULT_VOICE_ID
|
|
45
|
-
if len(voices) == 1:
|
|
46
|
-
return voices[0]
|
|
47
|
-
return voices[(seed + ordinal) % len(voices)]
|
|
48
|
-
|
|
49
|
-
|
|
50
42
|
@register_transform(NAME)
|
|
51
43
|
class BeatToVoiceAssignment(BaseTransform):
|
|
52
44
|
"""Narrative beat (+ weave-config) → ``voice-assignment/v1``."""
|
|
@@ -60,12 +52,14 @@ class BeatToVoiceAssignment(BaseTransform):
|
|
|
60
52
|
) -> tuple[Plan, tuple[Annotation, ...]]:
|
|
61
53
|
beat = inputs.primary[0]
|
|
62
54
|
cfg = singleton(project, "weave-configs")
|
|
63
|
-
config = cfg.body.get("config", {})
|
|
64
|
-
voices = list(config.get("voices") or [DEFAULT_VOICE_ID])
|
|
65
|
-
seed = int(config.get("voice_seed", 0))
|
|
66
|
-
pool_label = config.get("pool_label", "single")
|
|
55
|
+
config = WeaveConfig.from_snapshot(cfg.body.get("config", {}))
|
|
67
56
|
ordinal = int(beat.body.get("beat_id", "0") or 0)
|
|
68
|
-
|
|
57
|
+
# the beat's own override, else the pool — the fast path's rule exactly
|
|
58
|
+
voice_id = (
|
|
59
|
+
config.cast_voice(ordinal, override=beat.body.get("voice"))
|
|
60
|
+
or DEFAULT_VOICE_ID
|
|
61
|
+
)
|
|
62
|
+
pool_label, seed = config.pool_label, config.voice_seed
|
|
69
63
|
|
|
70
64
|
full = TransformInputs(primary=(beat,), context={WEAVE_CONFIG_V1: (cfg,)})
|
|
71
65
|
skeleton = Annotation(
|
|
@@ -21,6 +21,7 @@ refinement (see #21 / the research).
|
|
|
21
21
|
from __future__ import annotations
|
|
22
22
|
|
|
23
23
|
import json
|
|
24
|
+
import random
|
|
24
25
|
import shutil
|
|
25
26
|
import subprocess
|
|
26
27
|
from dataclasses import dataclass
|
|
@@ -28,6 +29,64 @@ from pathlib import Path
|
|
|
28
29
|
|
|
29
30
|
_LOUDNESS_RANGE = 11 # loudnorm LRA target for the mastered mix
|
|
30
31
|
|
|
32
|
+
#: Upper bound of the intelligible range for a speaker interruption: past it two
|
|
33
|
+
#: voices talking over each other stop being understood (Hamilton#22).
|
|
34
|
+
MAX_OVERLAP_TURN_S = 0.4
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass(frozen=True)
|
|
38
|
+
class TurnOverlap:
|
|
39
|
+
"""How much the next speaker may start before the previous one finishes.
|
|
40
|
+
|
|
41
|
+
The pure, render-time view of :class:`~braidio.weave_config.WeaveConfig`'s
|
|
42
|
+
``overlap_*`` knobs, so the layout and the mixer take one value instead of
|
|
43
|
+
four loose floats. ``max_s == 0`` means no interruption (the historical
|
|
44
|
+
butt-join with a crossfade). It lives here, not in ``weave_config``, so the
|
|
45
|
+
weave stays free of the TTS/mixing imports that module carries.
|
|
46
|
+
|
|
47
|
+
``jitter`` shortens each overlap by a seeded random fraction up to that
|
|
48
|
+
amount (so it is not mechanical); ``duck_db`` (≤ 0) lowers the outgoing voice
|
|
49
|
+
over the overlap; ``seed`` makes both reproducible — ``WeaveConfig`` passes
|
|
50
|
+
its ``voice_seed``, so one seed fixes the casting and the interruptions.
|
|
51
|
+
|
|
52
|
+
The overlap is measured between *file* boundaries: the layout sees each
|
|
53
|
+
part's duration only, so a beat that opens with its own lead silence
|
|
54
|
+
(``Narration.lead_gap_s``) spends the overlap on that silence first — an
|
|
55
|
+
incoming beat with a lead gap ≥ the overlap is not heard to interrupt.
|
|
56
|
+
|
|
57
|
+
>>> TurnOverlap(max_s=0.5)
|
|
58
|
+
Traceback (most recent call last):
|
|
59
|
+
...
|
|
60
|
+
ValueError: TurnOverlap.max_s (WeaveConfig.overlap_turn_s) must be in [0, 0.4], got 0.5
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
max_s: float = 0.0
|
|
64
|
+
jitter: float = 0.3
|
|
65
|
+
duck_db: float = 0.0
|
|
66
|
+
seed: int = 0
|
|
67
|
+
|
|
68
|
+
def __post_init__(self) -> None:
|
|
69
|
+
if not (0.0 <= self.max_s <= MAX_OVERLAP_TURN_S):
|
|
70
|
+
raise ValueError(
|
|
71
|
+
"TurnOverlap.max_s (WeaveConfig.overlap_turn_s) must be in "
|
|
72
|
+
f"[0, {MAX_OVERLAP_TURN_S}], got {self.max_s}"
|
|
73
|
+
)
|
|
74
|
+
if not (0.0 <= self.jitter <= 1.0):
|
|
75
|
+
raise ValueError(
|
|
76
|
+
"TurnOverlap.jitter (WeaveConfig.overlap_jitter) must be in [0, 1], "
|
|
77
|
+
f"got {self.jitter}"
|
|
78
|
+
)
|
|
79
|
+
if self.duck_db > 0:
|
|
80
|
+
raise ValueError(
|
|
81
|
+
"TurnOverlap.duck_db (WeaveConfig.overlap_duck_db) must be <= 0 "
|
|
82
|
+
f"(it attenuates), got {self.duck_db}"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def is_on(self) -> bool:
|
|
87
|
+
"""Whether a change of speaker is laid out as an interruption."""
|
|
88
|
+
return self.max_s > 0
|
|
89
|
+
|
|
31
90
|
|
|
32
91
|
def _require_ffmpeg() -> None:
|
|
33
92
|
if shutil.which("ffmpeg") is None or shutil.which("ffprobe") is None:
|
|
@@ -122,6 +181,8 @@ class TimelineItem:
|
|
|
122
181
|
placement: str = "sequential" # "sequential" | "under"
|
|
123
182
|
duck_db: float = 0.0 # attenuation applied when placement == "under" (e.g. -15)
|
|
124
183
|
spotlight: bool = False # the bed drops out over this part (see braidio.structure)
|
|
184
|
+
# who talks (voice id); None = no speaker (clips, stings)
|
|
185
|
+
speaker: str | None = None
|
|
125
186
|
|
|
126
187
|
|
|
127
188
|
def layout_placed(
|
|
@@ -131,6 +192,8 @@ def layout_placed(
|
|
|
131
192
|
*,
|
|
132
193
|
clip_edge_overlap_s: float,
|
|
133
194
|
narration_crossfade_s: float,
|
|
195
|
+
speakers: list[str | None] | None = None,
|
|
196
|
+
overlap: TurnOverlap | None = None,
|
|
134
197
|
) -> list[float]:
|
|
135
198
|
"""Start offset (s) of each part, placement-aware. Pure function.
|
|
136
199
|
|
|
@@ -140,28 +203,135 @@ def layout_placed(
|
|
|
140
203
|
An ``"under"`` part starts *at* the cursor (concurrent with the next
|
|
141
204
|
sequential part) and does **not** advance it — so it overlays what follows.
|
|
142
205
|
Clamped ≥ 0.
|
|
206
|
+
|
|
207
|
+
With ``speakers`` (one id per part, ``None`` = no speaker) and an ``overlap``
|
|
208
|
+
that is on, each boundary :func:`interrupting_boundaries` names starts up to
|
|
209
|
+
``max_s`` early instead (an interruption), capped by both turns' lengths and
|
|
210
|
+
shortened by a jitter drawn from ``Random(f"{seed}:{i}")`` — per part index,
|
|
211
|
+
so editing one boundary does not reshuffle the others. Overlap is measured
|
|
212
|
+
between file boundaries, lead silence included (see :class:`TurnOverlap`).
|
|
213
|
+
|
|
214
|
+
While overlap is on, two floors keep it to two voices at once: a part laid
|
|
215
|
+
after a non-clip part never starts before the end of any earlier sequential
|
|
216
|
+
part but the last, and a narration part never starts before the end of any
|
|
217
|
+
earlier narration but the most recent. Neither applies with overlap off, so
|
|
218
|
+
the default layout is unchanged.
|
|
219
|
+
|
|
220
|
+
>>> layout_placed(["narration"] * 3, [2.0, 0.3, 2.0], ["sequential"] * 3,
|
|
221
|
+
... clip_edge_overlap_s=0.5, narration_crossfade_s=0.12,
|
|
222
|
+
... speakers=["a", "b", "b"], overlap=TurnOverlap(0.4, 0.0))
|
|
223
|
+
[0.0, 1.7, 2.0]
|
|
143
224
|
"""
|
|
225
|
+
on = overlap is not None and overlap.is_on
|
|
226
|
+
cuts = (
|
|
227
|
+
set(interrupting_boundaries(kinds, placements, speakers, overlap))
|
|
228
|
+
if on
|
|
229
|
+
else set()
|
|
230
|
+
)
|
|
144
231
|
starts: list[float] = [0.0] * len(kinds)
|
|
232
|
+
ends: list[float] = [0.0] * len(kinds)
|
|
145
233
|
cursor = 0.0
|
|
146
234
|
prev_seq_kind: str | None = None
|
|
235
|
+
seq: list[int] = [] # indices of the sequential parts laid so far
|
|
236
|
+
talk: list[int] = [] # indices of the narration parts laid so far
|
|
147
237
|
for i, kind in enumerate(kinds):
|
|
148
238
|
if placements[i] == "under":
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
239
|
+
# overlay the following sequential part; cursor unchanged
|
|
240
|
+
starts[i] = cursor
|
|
241
|
+
ends[i] = cursor + durs[i]
|
|
242
|
+
if kind == "narration":
|
|
243
|
+
talk.append(i)
|
|
152
244
|
continue
|
|
245
|
+
floor = 0.0
|
|
153
246
|
if prev_seq_kind is None:
|
|
154
247
|
start = 0.0
|
|
155
248
|
elif kind == "clip" or prev_seq_kind == "clip":
|
|
156
249
|
start = max(0.0, cursor - clip_edge_overlap_s)
|
|
157
250
|
else:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
251
|
+
lead = narration_crossfade_s
|
|
252
|
+
if (seq[-1], i) in cuts:
|
|
253
|
+
lead = max(lead, _jittered_overlap(overlap, i, durs[seq[-1]], durs[i]))
|
|
254
|
+
if on: # no third part under the two at this boundary
|
|
255
|
+
floor = max((ends[j] for j in seq[:-1]), default=0.0)
|
|
256
|
+
start = max(0.0, cursor - lead)
|
|
257
|
+
if on and kind == "narration": # no third voice, whatever lies between
|
|
258
|
+
floor = max([floor] + [ends[j] for j in talk[:-1]])
|
|
259
|
+
start = max(start, floor)
|
|
260
|
+
starts[i], ends[i] = start, start + durs[i]
|
|
261
|
+
cursor = ends[i]
|
|
161
262
|
prev_seq_kind = kind
|
|
263
|
+
seq.append(i)
|
|
264
|
+
if kind == "narration":
|
|
265
|
+
talk.append(i)
|
|
162
266
|
return starts
|
|
163
267
|
|
|
164
268
|
|
|
269
|
+
def interrupting_boundaries(
|
|
270
|
+
kinds: list[str],
|
|
271
|
+
placements: list[str],
|
|
272
|
+
speakers: list[str | None] | None,
|
|
273
|
+
overlap: TurnOverlap | None,
|
|
274
|
+
) -> list[tuple[int, int]]:
|
|
275
|
+
"""The ``(prev, cur)`` sequential-part pairs where ``cur`` interrupts ``prev``.
|
|
276
|
+
|
|
277
|
+
The one definition :func:`layout_placed` (where to start) and
|
|
278
|
+
:func:`duck_regions` (what to duck) share: overlap is on, both parts are
|
|
279
|
+
narration (a clip or sting never interrupts nor is interrupted), both have a
|
|
280
|
+
speaker, and the speakers differ.
|
|
281
|
+
|
|
282
|
+
>>> interrupting_boundaries(
|
|
283
|
+
... ["narration", "narration", "clip", "narration", "narration"],
|
|
284
|
+
... ["sequential"] * 5, ["a", "b", None, "b", "c"], TurnOverlap(0.3))
|
|
285
|
+
[(0, 1), (3, 4)]
|
|
286
|
+
"""
|
|
287
|
+
if not (overlap is not None and overlap.is_on and speakers):
|
|
288
|
+
return []
|
|
289
|
+
seq = [i for i, p in enumerate(placements) if p != "under"]
|
|
290
|
+
|
|
291
|
+
def _talks(i: int) -> bool:
|
|
292
|
+
return kinds[i] == "narration" and speakers[i] is not None
|
|
293
|
+
|
|
294
|
+
return [
|
|
295
|
+
(prev, cur)
|
|
296
|
+
for prev, cur in zip(seq, seq[1:])
|
|
297
|
+
if _talks(prev) and _talks(cur) and speakers[prev] != speakers[cur]
|
|
298
|
+
]
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def _jittered_overlap(
|
|
302
|
+
overlap: TurnOverlap, index: int, prev_dur: float, cur_dur: float
|
|
303
|
+
) -> float:
|
|
304
|
+
"""Part ``index``'s overlap: ``max_s`` shortened by a seeded fraction, capped
|
|
305
|
+
by both turns' lengths. The draw is keyed on ``(seed, index)``, not on a
|
|
306
|
+
shared stream, so it does not depend on how many boundaries came before."""
|
|
307
|
+
draw = random.Random(f"{overlap.seed}:{index}").random()
|
|
308
|
+
amount = overlap.max_s * (1.0 - overlap.jitter * draw)
|
|
309
|
+
return min(amount, prev_dur, cur_dur)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def duck_regions(
|
|
313
|
+
starts: list[float],
|
|
314
|
+
durs: list[float],
|
|
315
|
+
kinds: list[str],
|
|
316
|
+
placements: list[str],
|
|
317
|
+
speakers: list[str | None] | None,
|
|
318
|
+
overlap: TurnOverlap | None,
|
|
319
|
+
) -> dict[int, tuple[float, float]]:
|
|
320
|
+
"""Per part, the ``(from_s, to_s)`` span *within its own audio* to duck.
|
|
321
|
+
|
|
322
|
+
The tail of an outgoing voice that the next speaker talks over, at each of
|
|
323
|
+
:func:`interrupting_boundaries`; empty when ``overlap.duck_db`` is 0. Pure,
|
|
324
|
+
from the laid-out starts.
|
|
325
|
+
"""
|
|
326
|
+
if not (overlap is not None and overlap.duck_db):
|
|
327
|
+
return {}
|
|
328
|
+
regions = {}
|
|
329
|
+
for prev, cur in interrupting_boundaries(kinds, placements, speakers, overlap):
|
|
330
|
+
if starts[cur] < starts[prev] + durs[prev]:
|
|
331
|
+
regions[prev] = (starts[cur] - starts[prev], durs[prev])
|
|
332
|
+
return regions
|
|
333
|
+
|
|
334
|
+
|
|
165
335
|
def layout_starts(
|
|
166
336
|
kinds: list[str],
|
|
167
337
|
durs: list[float],
|
|
@@ -190,6 +360,7 @@ def weave_timeline(
|
|
|
190
360
|
true_peak: float = -1.0,
|
|
191
361
|
sample_rate: int = 44100,
|
|
192
362
|
bed=None, # optional braidio.music.MusicBed — instrumental underscore under all
|
|
363
|
+
overlap: TurnOverlap | None = None,
|
|
193
364
|
) -> Path:
|
|
194
365
|
"""Place items on a timeline and mix. Clips overlap neighbours by
|
|
195
366
|
``clip_edge_overlap_s`` (their faded edges tuck under narration); narration
|
|
@@ -202,19 +373,29 @@ def weave_timeline(
|
|
|
202
373
|
:func:`braidio.music.bed_regions`); with none marked the bed is the single
|
|
203
374
|
whole-span file. Falls back to a plain concat feel when
|
|
204
375
|
``clip_edge_overlap_s == 0`` and there's nothing to overlay.
|
|
376
|
+
|
|
377
|
+
``overlap`` (a :class:`TurnOverlap`, e.g. ``WeaveConfig.turn_overlap()``)
|
|
378
|
+
lays a change of speaker as an interruption and, with ``duck_db``, lowers
|
|
379
|
+
the outgoing voice's talked-over tail (see :func:`layout_placed`).
|
|
205
380
|
"""
|
|
206
381
|
_require_ffmpeg()
|
|
207
382
|
if not items:
|
|
208
383
|
raise ValueError("weave_timeline needs at least one item")
|
|
209
384
|
|
|
210
385
|
durs = [duration_s(it.path) for it in items]
|
|
386
|
+
kinds = [it.kind for it in items]
|
|
387
|
+
placements = [it.placement for it in items]
|
|
388
|
+
speakers = [it.speaker for it in items]
|
|
211
389
|
starts = layout_placed(
|
|
212
|
-
|
|
390
|
+
kinds,
|
|
213
391
|
durs,
|
|
214
|
-
|
|
392
|
+
placements,
|
|
215
393
|
clip_edge_overlap_s=clip_edge_overlap_s,
|
|
216
394
|
narration_crossfade_s=narration_crossfade_s,
|
|
395
|
+
speakers=speakers,
|
|
396
|
+
overlap=overlap,
|
|
217
397
|
)
|
|
398
|
+
ducks = duck_regions(starts, durs, kinds, placements, speakers, overlap)
|
|
218
399
|
out = Path(out_path)
|
|
219
400
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
220
401
|
|
|
@@ -233,6 +414,11 @@ def weave_timeline(
|
|
|
233
414
|
# ducked underlay: attenuate before delaying so it sits beneath the talk.
|
|
234
415
|
if it.placement == "under" and it.duck_db:
|
|
235
416
|
chain += f",volume={it.duck_db}dB"
|
|
417
|
+
if i in ducks: # lower the outgoing voice while the next speaker cuts in
|
|
418
|
+
lo, hi = ducks[i]
|
|
419
|
+
chain += (
|
|
420
|
+
f",volume={overlap.duck_db}dB:enable='between(t,{lo:.3f},{hi:.3f})'"
|
|
421
|
+
)
|
|
236
422
|
chain += f",adelay={delay_ms}:all=1[{lbl}]"
|
|
237
423
|
filters.append(chain)
|
|
238
424
|
labels.append(f"[{lbl}]")
|