braidio 0.0.74__tar.gz → 0.0.76__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.76}/PKG-INFO +1 -1
- {braidio-0.0.74 → braidio-0.0.76}/braidio/bodies/_domain.py +19 -1
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/tools.py +1 -1
- {braidio-0.0.74 → braidio-0.0.76}/braidio/render.py +21 -6
- {braidio-0.0.74 → braidio-0.0.76}/braidio/timeline.py +8 -1
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/__init__.py +27 -1
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_episode.py +35 -23
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_ingest.py +2 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_narration.py +7 -2
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_voice.py +9 -16
- {braidio-0.0.74 → braidio-0.0.76}/braidio/weave.py +194 -8
- {braidio-0.0.74 → braidio-0.0.76}/braidio/weave_config.py +107 -4
- {braidio-0.0.74 → braidio-0.0.76}/pyproject.toml +1 -1
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_body_schema_stability.py +2 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_transforms.py +5 -1
- braidio-0.0.76/tests/test_turn_overlap.py +574 -0
- {braidio-0.0.74 → braidio-0.0.76}/.editorconfig +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/.gitattributes +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/.gitignore +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/LICENSE +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/README.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/_paths.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/bodies/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/bodies/_render_nodes.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/bodies/_tiers.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/bodies/_video.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/captions.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/compose.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/conversation.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/cost.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/data/skills/braidio/SKILL.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/data/skills/braidio-commentary-video/SKILL.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/defaults.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/delivery.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/downloads.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/formats.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/genre.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/importing/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/importing/__main__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/importing/_catalog.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/importing/_manifest.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/importing/_writer.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/kinds.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/markdown_script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/__init__.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/_docs.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/_guide.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/_helpers.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/_media.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/credentials.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/metering.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/mcp/workspace.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/multivoice.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/music.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/pacing.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/project.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/provenance.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/relevance.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/rights.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/sources.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/structure.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/style.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/textprep.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_asset_refs.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_common.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_dialogue.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_segment.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_video_cut.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/transforms/_video_panels.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/tts.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/video.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/braidio/voice_library.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/conftest.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/Extraction and nw-App Design.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/research/commentary-formats-and-styles.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/research/conversational-vs-narration-tts.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/research/notebooklm-and-conversational-pacing.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/README.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/anti-platitude-checklist.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/commentary-voice-guide.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/_style-groups.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/amanda-dobbins.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/david-sims.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/griffin-newman.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/helen-molesworth.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/hrishikesh-hirway.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/jason-mantzoukas.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/john-mcwhorter.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/jon-caramanica.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/june-diane-raphael.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/karina-longworth.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/katy-hessel.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/louis-theroux.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/mallory-rubin.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/melvyn-bragg.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/michael-barbaro.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/nate-sloan-charlie-harding.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/paul-scheer.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/sean-fennessey.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/talk-art.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/style/voices/yasi-salek.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/misc/docs/youtube_ingest_credentials.md +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/_audio.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_conversation.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_cost.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_credits_card.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_defaults.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_delivery.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_downloads.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_expressiveness.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_formats.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_genre_placement.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_importing.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_markdown_script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_mcp.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_mcp_caller_key.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_media_auth.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_multivoice.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_music.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_namespaced_source.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_nw_app.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_pacing.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_packaging.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_render_settings.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_script.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_sources.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_structure.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_textprep_style.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_timeline.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_transforms_dialogue.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_transforms_episode_members.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_transforms_rights.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_transforms_secrets.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_transforms_structure.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_tts_api_key.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_video.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_video_bodies.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_video_footage.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_video_transforms.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_voice_library.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_weave.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/tests/test_weave_config.py +0 -0
- {braidio-0.0.74 → braidio-0.0.76}/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.76
|
|
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,24 @@ 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
|
+
voice_settings: Optional[dict] = Field(
|
|
117
|
+
None, description="Per-beat ElevenLabs voice settings; override the config's."
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
@model_serializer(mode="wrap")
|
|
121
|
+
def _omit_unset_voice(self, handler):
|
|
122
|
+
"""Leave ``voice`` / ``voice_settings`` out while unset, so a body written
|
|
123
|
+
before the fields existed is byte-identical on re-write (every writer,
|
|
124
|
+
not one call site)."""
|
|
125
|
+
data = handler(self)
|
|
126
|
+
for key in ("voice", "voice_settings"):
|
|
127
|
+
if data.get(key) is None:
|
|
128
|
+
data.pop(key, None)
|
|
129
|
+
return data
|
|
130
|
+
|
|
113
131
|
plays_clip: Optional[str] = Field(
|
|
114
132
|
None, description="Id of an audio-clip/v1 to play here."
|
|
115
133
|
)
|
|
@@ -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(
|
|
@@ -38,6 +38,7 @@ from __future__ import annotations
|
|
|
38
38
|
from nw import TransformInputs
|
|
39
39
|
|
|
40
40
|
from braidio.transforms._common import ELEVENLABS_SECRET
|
|
41
|
+
from braidio.weave_config import WeaveConfig
|
|
41
42
|
from braidio.transforms._ingest import ingest_script, IngestedScript
|
|
42
43
|
from braidio.transforms import ( # noqa: F401
|
|
43
44
|
_asset_refs,
|
|
@@ -89,6 +90,7 @@ VIDEO_CUT_FINISH_TRANSFORM = _video_cut.FINISH_NAME
|
|
|
89
90
|
video_cut_reuses_existing = _video_cut.reuses_existing_cut
|
|
90
91
|
|
|
91
92
|
__all__ = [
|
|
93
|
+
"format_config",
|
|
92
94
|
"ingest_script",
|
|
93
95
|
"IngestedScript",
|
|
94
96
|
"weave_project",
|
|
@@ -120,6 +122,23 @@ __all__ = [
|
|
|
120
122
|
]
|
|
121
123
|
|
|
122
124
|
|
|
125
|
+
def format_config(fmt=None, *, config=None, voice_id=None):
|
|
126
|
+
"""The weave-config a production records: one rule for every writer.
|
|
127
|
+
|
|
128
|
+
``config`` else the format's ``weave``, carrying the narration voice —
|
|
129
|
+
``voice_id`` else ``fmt.narration_voice`` — when there is one. ``weave_project``
|
|
130
|
+
and ``save_script`` both resolve through here, so saving and then weaving a
|
|
131
|
+
format never rewrites the config node (and so never re-stales its renders).
|
|
132
|
+
"""
|
|
133
|
+
if config is None and fmt is not None:
|
|
134
|
+
config = fmt.weave
|
|
135
|
+
if voice_id is None and fmt is not None:
|
|
136
|
+
voice_id = fmt.narration_voice
|
|
137
|
+
if voice_id is not None:
|
|
138
|
+
config = (config or WeaveConfig()).with_(narration_voice=voice_id)
|
|
139
|
+
return config
|
|
140
|
+
|
|
141
|
+
|
|
123
142
|
def weave_project(
|
|
124
143
|
project,
|
|
125
144
|
script,
|
|
@@ -132,6 +151,7 @@ def weave_project(
|
|
|
132
151
|
profile=None,
|
|
133
152
|
rights=None,
|
|
134
153
|
cast=None,
|
|
154
|
+
voice_id=None,
|
|
135
155
|
api_key=None,
|
|
136
156
|
):
|
|
137
157
|
"""Ingest ``script`` and run the whole commentary-weave chain, in order.
|
|
@@ -161,6 +181,12 @@ def weave_project(
|
|
|
161
181
|
``dialogue-cast/v1`` node only when the script has a dialogue beat, and
|
|
162
182
|
each ``dialogue-render/v1`` derives from it (thorwhalen/braidio#46).
|
|
163
183
|
|
|
184
|
+
``voice_id`` is the narration voice, resolved as on the fast path: the
|
|
185
|
+
beat's own voice, else ``voice_id``, else the format's ``narration_voice``,
|
|
186
|
+
else the config's pool. It is recorded in the weave-config, so changing it
|
|
187
|
+
re-stales (and re-bills) every narration render that did not name its own
|
|
188
|
+
voice. Left unset it writes nothing (thorwhalen/braidio#115).
|
|
189
|
+
|
|
164
190
|
``profile`` (a :class:`~braidio.rights.Profile`) and ``rights`` (a
|
|
165
191
|
:class:`~braidio.rights.RightsPolicy`) are the rights seam, and they mean
|
|
166
192
|
exactly what they mean on :func:`braidio.render.render_production`: the
|
|
@@ -192,8 +218,8 @@ def weave_project(
|
|
|
192
218
|
"""
|
|
193
219
|
import nw
|
|
194
220
|
|
|
221
|
+
config = format_config(fmt, config=config, voice_id=voice_id)
|
|
195
222
|
if fmt is not None:
|
|
196
|
-
config = config if config is not None else fmt.weave
|
|
197
223
|
structure = structure if structure is not None else fmt.structure
|
|
198
224
|
cast = cast if cast is not None else fmt.cast
|
|
199
225
|
|
|
@@ -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
|
|
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.
|
|
@@ -148,14 +142,6 @@ def _structure_and_bed(node: Annotation | None):
|
|
|
148
142
|
return MusicStructure(sting=sting, **(body.get("structure") or {})), bed
|
|
149
143
|
|
|
150
144
|
|
|
151
|
-
def _layout_knobs(config: dict) -> tuple[float, float]:
|
|
152
|
-
"""``(clip_edge_overlap_s, narration_crossfade_s)`` from a weave-config snapshot."""
|
|
153
|
-
return (
|
|
154
|
-
float(config.get("clip_edge_overlap_s", _DEFAULT_CLIP_EDGE_OVERLAP_S)),
|
|
155
|
-
float(config.get("crossfade_s", _DEFAULT_CROSSFADE_S)),
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
|
|
159
145
|
def _member_role(member: Annotation, index: dict, *, structure):
|
|
160
146
|
"""``(role, label, source_span)`` for one episode member — the timeline's
|
|
161
147
|
per-beat metadata, mirroring ``braidio.render``'s conventions exactly.
|
|
@@ -183,6 +169,22 @@ def _member_role(member: Annotation, index: dict, *, structure):
|
|
|
183
169
|
return style, text[:_LABEL_SNIPPET_CHARS], None
|
|
184
170
|
|
|
185
171
|
|
|
172
|
+
def _member_speaker(member: Annotation, index: dict) -> str | None:
|
|
173
|
+
"""The voice a member talks with, for speaker interruption (``None``: nobody).
|
|
174
|
+
|
|
175
|
+
Only a narration render has one — the voice its ``voice-assignment`` parent
|
|
176
|
+
carries. A dialogue render is several speakers in one file, a clip or a
|
|
177
|
+
break has none: the same rule as ``braidio.render``'s ``speakers``.
|
|
178
|
+
"""
|
|
179
|
+
if member.tier != TIER_NARRATION_RENDER:
|
|
180
|
+
return None
|
|
181
|
+
va = next(
|
|
182
|
+
(p for p in resolve_parents(member, index) if p.tier == TIER_VOICE_ASSIGNMENT),
|
|
183
|
+
None,
|
|
184
|
+
)
|
|
185
|
+
return speaker_key(va.body.get("voice_id")) if va is not None else None
|
|
186
|
+
|
|
187
|
+
|
|
186
188
|
def member_timeline(
|
|
187
189
|
members,
|
|
188
190
|
durations,
|
|
@@ -207,7 +209,9 @@ def member_timeline(
|
|
|
207
209
|
roles.append(role)
|
|
208
210
|
labels.append(label)
|
|
209
211
|
spans.append(span)
|
|
210
|
-
|
|
212
|
+
weave = WeaveConfig.from_snapshot(config) # omitted knobs → the defaults
|
|
213
|
+
edge_overlap_s, crossfade_s = weave.clip_edge_overlap_s, weave.crossfade_s
|
|
214
|
+
speakers = [_member_speaker(m, index) for m in members]
|
|
211
215
|
return build_timeline(
|
|
212
216
|
kinds=roles,
|
|
213
217
|
durations=[float(d) for d in durations],
|
|
@@ -215,6 +219,8 @@ def member_timeline(
|
|
|
215
219
|
source_spans=spans,
|
|
216
220
|
clip_edge_overlap_s=edge_overlap_s,
|
|
217
221
|
narration_crossfade_s=crossfade_s,
|
|
222
|
+
speakers=speakers,
|
|
223
|
+
overlap=weave.turn_overlap(),
|
|
218
224
|
title=title,
|
|
219
225
|
settings={
|
|
220
226
|
"weave": dict(config),
|
|
@@ -648,7 +654,8 @@ class WeaveToEpisode(BaseTransform):
|
|
|
648
654
|
structure, bed = _structure_and_bed(
|
|
649
655
|
next((a for a in parents if a.tier == TIER_PRODUCTION_STRUCTURE), None)
|
|
650
656
|
)
|
|
651
|
-
|
|
657
|
+
weave = WeaveConfig.from_snapshot(config) # omitted knobs → the defaults
|
|
658
|
+
target_lufs = weave.target_lufs
|
|
652
659
|
|
|
653
660
|
breaks_dir = project.root / "data" / "breaks"
|
|
654
661
|
items = [
|
|
@@ -666,7 +673,6 @@ class WeaveToEpisode(BaseTransform):
|
|
|
666
673
|
# The timeline is built from the SAME parts the mixer is about to lay
|
|
667
674
|
# out — probed the way weave_timeline probes them — and persisted on
|
|
668
675
|
# the episode, so the cut points survive the process (plan §3).
|
|
669
|
-
edge_overlap_s, crossfade_s = _layout_knobs(config)
|
|
670
676
|
timeline = member_timeline(
|
|
671
677
|
members,
|
|
672
678
|
[braidio.duration_s(it.path) for it in items],
|
|
@@ -679,15 +685,20 @@ class WeaveToEpisode(BaseTransform):
|
|
|
679
685
|
|
|
680
686
|
out_path = project.root / "data" / "episodes" / f"{skel.id}.mp3"
|
|
681
687
|
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
688
|
+
# Interruption is off unless the config asks: leave the call exactly as
|
|
689
|
+
# it was for a project that never set it (the absence rule, as above).
|
|
690
|
+
overlap = weave.turn_overlap() # also what member_timeline laid out
|
|
691
|
+
overlap_kw = {"overlap": overlap} if overlap.is_on else {}
|
|
682
692
|
braidio.weave_timeline(
|
|
683
693
|
items,
|
|
684
694
|
out_path,
|
|
685
|
-
clip_edge_overlap_s=
|
|
686
|
-
narration_crossfade_s=crossfade_s,
|
|
695
|
+
clip_edge_overlap_s=weave.clip_edge_overlap_s,
|
|
696
|
+
narration_crossfade_s=weave.crossfade_s,
|
|
687
697
|
target_lufs=target_lufs,
|
|
688
|
-
true_peak=
|
|
689
|
-
sample_rate=
|
|
698
|
+
true_peak=weave.true_peak_dbtp,
|
|
699
|
+
sample_rate=weave.sample_rate,
|
|
690
700
|
bed=bed,
|
|
701
|
+
**overlap_kw,
|
|
691
702
|
)
|
|
692
703
|
duration = safe_duration(out_path)
|
|
693
704
|
artifact = audio_artifact(
|
|
@@ -751,6 +762,7 @@ class WeaveToEpisode(BaseTransform):
|
|
|
751
762
|
kind="clip" if is_clip else "narration",
|
|
752
763
|
path=str(url_to_path(member.body["url"])),
|
|
753
764
|
placement="sequential",
|
|
765
|
+
speaker=_member_speaker(member, index),
|
|
754
766
|
spotlight=(
|
|
755
767
|
is_clip
|
|
756
768
|
and bed is not None
|
|
@@ -84,6 +84,11 @@ def _narration_cache_key(
|
|
|
84
84
|
)
|
|
85
85
|
|
|
86
86
|
|
|
87
|
+
def _beat_settings(beat, config: dict) -> dict:
|
|
88
|
+
"""The beat's own voice settings, else the config's — the fast path's rule."""
|
|
89
|
+
return beat.body.get("voice_settings") or config.get("voice_settings", {})
|
|
90
|
+
|
|
91
|
+
|
|
87
92
|
@register_transform(NAME)
|
|
88
93
|
class NarrationRenderTTS(BaseTransform):
|
|
89
94
|
"""Narrative beat (+ voice-assignment + weave-config) → ``narration-render/v1``."""
|
|
@@ -102,7 +107,7 @@ class NarrationRenderTTS(BaseTransform):
|
|
|
102
107
|
config = cfg.body.get("config", {})
|
|
103
108
|
voice_id = va.body.get("voice_id") or DEFAULT_VOICE_ID
|
|
104
109
|
model_id = config.get("model_id", DEFAULT_MODEL_ID)
|
|
105
|
-
settings =
|
|
110
|
+
settings = _beat_settings(beat, config)
|
|
106
111
|
cache_key = _narration_cache_key(
|
|
107
112
|
self, beat.body.get("text", ""), voice_id, model_id, settings
|
|
108
113
|
)
|
|
@@ -184,7 +189,7 @@ class NarrationRenderTTS(BaseTransform):
|
|
|
184
189
|
api_key=elevenlabs_key(secrets),
|
|
185
190
|
voice_id=va.body.get("voice_id") or DEFAULT_VOICE_ID,
|
|
186
191
|
model_id=model_id,
|
|
187
|
-
voice_settings=
|
|
192
|
+
voice_settings=_beat_settings(beat, config),
|
|
188
193
|
return_cache_status=True,
|
|
189
194
|
)
|
|
190
195
|
duration = safe_duration(out_path)
|
|
@@ -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.
|
|
@@ -28,7 +28,8 @@ from braidio.bodies._render_nodes import (
|
|
|
28
28
|
VOICE_ASSIGNMENT_V1,
|
|
29
29
|
VoiceAssignmentBodyV1,
|
|
30
30
|
)
|
|
31
|
-
from braidio.tts import
|
|
31
|
+
from braidio.tts import resolve_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,13 @@ 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 = config.cast_voice(
|
|
59
|
+
ordinal, override=beat.body.get("voice")
|
|
60
|
+
) or resolve_voice_id(None) # unset: BRAIDIO_TTS_VOICE, else the default
|
|
61
|
+
pool_label, seed = config.pool_label, config.voice_seed
|
|
69
62
|
|
|
70
63
|
full = TransformInputs(primary=(beat,), context={WEAVE_CONFIG_V1: (cfg,)})
|
|
71
64
|
skeleton = Annotation(
|