braidio 0.0.2__py3-none-any.whl

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.
@@ -0,0 +1,121 @@
1
+ """WeaveConfig — every editing choice for weaving narration + segments (#20).
2
+
3
+ One frozen config object that exposes **all** the knobs (casting, turns, pacing,
4
+ timing, clip weaving, loudness) so a composer picks combinations rather than
5
+ inheriting one hardcoded style (the "enable all choices" mandate of #18/#28).
6
+
7
+ Defaults come from ``docs/research/podcast-audio-weaving-editing.md``. This
8
+ module is deliberately **Hamilton-agnostic** — no Genius/LRCLIB/episode imports —
9
+ so it can move to the reusable weave package unchanged (#19). It references the
10
+ generic voice pools/ids only.
11
+
12
+ The config is designed to serialize cleanly (:meth:`WeaveConfig.to_dict`) into a
13
+ ``render-config`` provenance node (#26), so a render is reproducible from its
14
+ recorded choices.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ from dataclasses import asdict, dataclass, field, replace
20
+ from typing import Any, Mapping
21
+
22
+ from braidio.multivoice import POOL_4, POOL_MANY
23
+ from braidio.tts import DEFAULT_VOICE_ID
24
+
25
+ # Research-recommended base narration settings (v2-tuned).
26
+ _DEFAULT_VOICE_SETTINGS: dict[str, Any] = {
27
+ "stability": 0.35,
28
+ "similarity_boost": 0.75,
29
+ "style": 0.35,
30
+ "use_speaker_boost": True,
31
+ }
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class WeaveConfig:
36
+ """All editing choices for a narration+segment weave. Frozen + serializable."""
37
+
38
+ # --- Casting ------------------------------------------------------------
39
+ voices: tuple[str, ...] = (DEFAULT_VOICE_ID,) # 1 id = single; >1 = cycled pool
40
+ pool_label: str = "single"
41
+ voice_seed: int = 7
42
+ avoid_immediate_repeat: bool = True
43
+
44
+ # --- Delivery (TTS) -----------------------------------------------------
45
+ model_id: str = "eleven_multilingual_v2"
46
+ voice_settings: Mapping[str, Any] = field(
47
+ default_factory=lambda: dict(_DEFAULT_VOICE_SETTINGS)
48
+ )
49
+
50
+ # --- Segmentation / turns ----------------------------------------------
51
+ segmentation_unit: str = "sentence" # sentence | clause | paragraph | beat
52
+ min_turn: int = 2 # segments a voice speaks before switching
53
+ max_turn: int = 4
54
+
55
+ # --- Pacing -------------------------------------------------------------
56
+ speed_base: float = 1.0
57
+ speed_jitter: float = 0.04 # ± per turn
58
+
59
+ # --- Timing between turns ----------------------------------------------
60
+ crossfade_s: float = 0.12
61
+ gap_turn_s: float = 0.0 # silence between turns (mutually exclusive w/ crossfade)
62
+ overlap_turn_s: float = 0.0 # speaker interruption (#22 — not yet rendered)
63
+
64
+ # --- Clip weaving (#21) -------------------------------------------------
65
+ clip_pre_roll_s: float = 0.4 # extend extraction before the words
66
+ clip_post_roll_s: float = 0.3 # …and after — capture words cleanly
67
+ clip_fade_in_s: float = 0.5
68
+ clip_fade_out_s: float = 0.8
69
+ clip_edge_overlap_s: float = 0.5 # tuck faded clip edges under narration
70
+ duck_db: float = -15.0 # duck clip under speech (speech dominant)
71
+
72
+ # --- Global mix ---------------------------------------------------------
73
+ target_lufs: float = -16.0
74
+ true_peak_dbtp: float = -1.0
75
+ sample_rate: int = 44100
76
+
77
+ def __post_init__(self) -> None:
78
+ if not self.voices:
79
+ raise ValueError("WeaveConfig.voices must have at least one voice id")
80
+ if not (1 <= self.min_turn <= self.max_turn):
81
+ raise ValueError("require 1 <= min_turn <= max_turn")
82
+
83
+ @property
84
+ def is_multivoice(self) -> bool:
85
+ return len(self.voices) > 1
86
+
87
+ def with_(self, **changes: Any) -> "WeaveConfig":
88
+ """Return a copy with fields overridden (e.g. ``cfg.with_(min_turn=1)``)."""
89
+ return replace(self, **changes)
90
+
91
+ def to_dict(self) -> dict[str, Any]:
92
+ """Stable serialization for a ``render-config`` provenance node (#26)."""
93
+ d = asdict(self)
94
+ d["voices"] = list(self.voices)
95
+ d["voice_settings"] = dict(self.voice_settings)
96
+ return d
97
+
98
+
99
+ # --- Presets -----------------------------------------------------------------
100
+
101
+ _POOL_4_IDS = tuple(v.id for v in POOL_4)
102
+ _POOL_MANY_IDS = tuple(v.id for v in POOL_MANY)
103
+
104
+ SINGLE_NARRATOR = WeaveConfig(voices=(DEFAULT_VOICE_ID,), pool_label="single")
105
+
106
+ DOCUMENTARY_LYRICS = WeaveConfig( # the research default: one narrator, tight turns
107
+ voices=(DEFAULT_VOICE_ID,), pool_label="single", min_turn=1, max_turn=3
108
+ )
109
+
110
+ PANEL_4 = WeaveConfig(voices=_POOL_4_IDS, pool_label="panel-4", min_turn=2, max_turn=4)
111
+
112
+ INTERVIEW_MANY = WeaveConfig( # Hamilton's chosen default
113
+ voices=_POOL_MANY_IDS, pool_label="interview-many", min_turn=2, max_turn=4
114
+ )
115
+
116
+ PRESETS: dict[str, WeaveConfig] = {
117
+ "single_narrator": SINGLE_NARRATOR,
118
+ "documentary_lyrics": DOCUMENTARY_LYRICS,
119
+ "panel_4": PANEL_4,
120
+ "interview_many": INTERVIEW_MANY,
121
+ }
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: braidio
3
+ Version: 0.0.2
4
+ Summary: Weave narration with extracted media segments into audiovisual productions
5
+ Project-URL: Homepage, https://github.com/thorwhalen/braidio
6
+ Project-URL: Repository, https://github.com/thorwhalen/braidio
7
+ Project-URL: Documentation, https://thorwhalen.github.io/braidio
8
+ Author: Thor Whalen
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: audio,elevenlabs,ffmpeg,narration,podcast,tts
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: elevenlabs
14
+ Requires-Dist: mixing
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
17
+ Requires-Dist: pytest>=7.0; extra == 'dev'
18
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
19
+ Provides-Extra: docs
20
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
21
+ Requires-Dist: sphinx>=6.0; extra == 'docs'
22
+ Provides-Extra: graph
23
+ Requires-Dist: lacing; extra == 'graph'
24
+ Provides-Extra: nw-app
25
+ Requires-Dist: falaw; extra == 'nw-app'
26
+ Requires-Dist: lacing; extra == 'nw-app'
27
+ Requires-Dist: nw; extra == 'nw-app'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # braidio
31
+
32
+ **Weave *commentary* — solo, duo, panel, debate, interview, documentary — with
33
+ source clips into a production.**
34
+
35
+ `braidio` braids the strands of a piece that talks *about* something (a song, a
36
+ book, a film, an event) into one rendered production. The **talk is the spine** —
37
+ a single presenter, two hosts, a panel, a narrator — and **source clips and
38
+ narration bridges are the "illustration" layers** woven onto it. Audio today,
39
+ with visual support to follow (it braids A/V — *braid-io*, and it sounds like
40
+ *radio*).
41
+
42
+ Two things braidio gives you:
43
+
44
+ 1. **Ready-made format templates** under the standard, industry names people
45
+ already recognize — *Deep Dive*, *Song Exploder-style*, *Panel*, *Debate*,
46
+ *Documentary VO* — each a high-quality bundle of defaults you can render in one
47
+ call.
48
+ 2. **Full parametrization** underneath, so any style is expressible: a `Script`
49
+ of beats, cast via a `ConversationCast`, tuned by `WeaveConfig` + `Delivery`,
50
+ with per-beat voice/delivery overrides.
51
+
52
+ > Status: early. `braidio` is extracted from the
53
+ > [Hamilton lyrics-podcast](https://github.com/thorwhalen/Hamilton) (its first
54
+ > application) into a reusable engine. APIs will move quickly.
55
+
56
+ ## The model
57
+
58
+ A production is a **`Script`** — an ordered list of **beats**:
59
+
60
+ | Beat | What it is |
61
+ |---|---|
62
+ | `Narration(text, voice?, voice_settings?, …)` | one voice reading — a narrator **or** a solo presenter. `voice` / `voice_settings` override per beat, so one timeline can carry a lively **presenter** *and* a graver **book-narrator**. |
63
+ | `Dialogue(turns=[(role, text)])` | a multi-speaker exchange, synthesized in **one pass** (so it sounds like people *talking to each other*, not alternating monologues). A `ConversationCast` maps roles → voices. |
64
+ | `SegmentBeat(reference)` | a span of source media to cut and weave in (resolved by a pluggable `SegmentSource` — quote → `[start, end]`). |
65
+
66
+ `WeaveConfig` holds every editing knob (casting, turns, pacing, clip pre/post-roll,
67
+ duck, crossfades, loudness). `Delivery` presets bundle the TTS model + voice
68
+ settings (e.g. `V2_PRESENTER` lively vs `V2_NARRATOR` grave). The renderer
69
+ loudness-normalizes every part, tucks clips under the speech (speech stays
70
+ dominant), and masters the result.
71
+
72
+ ## Ready-made formats
73
+
74
+ Pick a standard format and render it — the template supplies the cast, voices,
75
+ delivery and mix defaults:
76
+
77
+ ```python
78
+ from braidio import DEEP_DIVE, render_format
79
+
80
+ render_format(DEEP_DIVE, script, source=my_source, out_path="episode.mp3")
81
+ ```
82
+
83
+ | Preset id | Standard name | Shape |
84
+ |---|---|---|
85
+ | `solo_explainer` | Solo-Presenter Explainer (video/audio essay, close reading) | one presenter + exhibits |
86
+ | `deep_dive` | Two-Host Conversation (*"Deep Dive"*, Switched on Pop, NotebookLM) | two hosts; one teaches, one probes |
87
+ | `interview` | Interview (host + guest) | Q→A, guest is the center |
88
+ | `interview_host_removed` | *Song Exploder*-style (host removed) | guest monologue; each claim illustrated by its isolated stem; full artifact at the tail |
89
+ | `panel` | Panel / Roundtable (Pop Culture Happy Hour) | moderator routes distinct voices |
90
+ | `debate` | Debate (Oxford-style) | proposition / opposition / moderator, phased |
91
+ | `documentary_vo` | Documentary Voice-Over (*"Voice of God"*, This American Life) | narrator on top; interviews + clips + actuality beneath |
92
+
93
+ **Narration bridges** and **source clips** are optional *illustration layers*
94
+ usable with any format. The taxonomy, weaving grammar, exemplar recipes and the
95
+ full template specs are in
96
+ [`misc/docs/research/commentary-formats-and-styles.md`](misc/docs/research/commentary-formats-and-styles.md).
97
+
98
+ *Render support note:* the cast, per-role voices, narration deliveries, loudness
99
+ master, **per-clip placement** — `SegmentBeat(placement="before" | "under" |
100
+ "after")`, where `under` lays the clip concurrently beneath the talk, ducked —
101
+ and a **music bed** (`MusicBed`, an app-supplied instrumental laid under the whole
102
+ production) are applied today. Scene stings and fade-to-spotlight (dropping the
103
+ bed before a key exhibit) remain on the render-side roadmap (braidio#1).
104
+
105
+ ## Parametrize anything
106
+
107
+ The templates are just good defaults over the primitives — compose directly for
108
+ full control:
109
+
110
+ ```python
111
+ from braidio import Script, Dialogue, Narration, SegmentBeat, WeaveConfig
112
+ from braidio.conversation import ConversationCast, JESSICA, CHRIS
113
+ from braidio import V2_NARRATOR, render_production
114
+
115
+ script = Script(
116
+ title="…",
117
+ id_slug="01",
118
+ beats=[
119
+ Dialogue(
120
+ (("A", "First thing that gets me…"), ("B", "right — but isn't that…"))
121
+ ),
122
+ SegmentBeat("the lyric being discussed", label="hook"),
123
+ Narration(
124
+ "Here's how the book tells it —", voice_settings=V2_NARRATOR.voice_settings
125
+ ), # graver, per-beat
126
+ ],
127
+ )
128
+ render_production(
129
+ script,
130
+ source=my_source,
131
+ cast=ConversationCast(roles={"A": JESSICA, "B": CHRIS}),
132
+ config=WeaveConfig(),
133
+ out_path="out.mp3",
134
+ )
135
+ ```
136
+
137
+ ## What it deliberately does *not* do
138
+
139
+ braidio is a thin orchestration layer. It **delegates**:
140
+
141
+ | Concern | Owner |
142
+ |---|---|
143
+ | Content acquisition (Genius, audiobooks, news…) | the consuming app, via `SegmentSource` adapters |
144
+ | Linked-artifact graph / content-addressed media | [`lacing`](https://github.com/thorwhalen/lacing) |
145
+ | Project workflow, provenance, plan/execute, partial re-render | [`nw`](https://github.com/thorwhalen/nw) |
146
+ | Video render + visual support | [`reelee`](https://github.com/thorwhalen/reelee) |
147
+ | Raw audio DSP + TTS (crop, concat, duck, loudnorm, synth) | [`mixing`](https://github.com/thorwhalen/mixing) / `falaw` |
148
+
149
+ braidio orchestrates these; it never reimplements the DSP or the graph.
150
+
151
+ ## Ecosystem
152
+
153
+ `braidio` is a **production kind** on top of `nw` — a reusable definition of
154
+ "commentary that weaves talk with extracted media" — the way a music video is
155
+ another production kind. It sits on `lacing` (graph) + `nw` (workflow /
156
+ provenance) + `mixing`/`falaw` (audio/TTS), and will use `reelee` for video. The
157
+ optional nw-app layer (`braidio.HAS_GRAPH` / `HAS_NW`) records render choices as
158
+ provenance so a change re-renders only the affected parts.
159
+
160
+ ## Install
161
+
162
+ ```bash
163
+ pip install braidio # (once published)
164
+ ```
165
+
166
+ ## License
167
+
168
+ MIT
@@ -0,0 +1,25 @@
1
+ braidio/__init__.py,sha256=KVLssvBEDrufzyNBgn36jHQsD0uOFk0uJbHUHMSD0I8,5536
2
+ braidio/compose.py,sha256=fLzkg_CP2B5gC4-M_odBU0q6JpWzpOMXPXyII5kGD4U,2476
3
+ braidio/conversation.py,sha256=2WI5eJ2TUdBb7YIopUWbsMUcLJwLsg9Z5G5eTtmrWIA,6251
4
+ braidio/delivery.py,sha256=JxfEKd7mYlqG81C2c2b9-5rdUxMxU18p6TA6TgQe_fI,4083
5
+ braidio/formats.py,sha256=dBjyTLYQs8nmLLM2lO2Xy9DQqoHoDl40nqvwamhkRXM,14263
6
+ braidio/kinds.py,sha256=r4wNjCaKs11gHbt7_rrRV0jOXGD7n9L_aE_3UdGWf_0,333
7
+ braidio/multivoice.py,sha256=KlBsjNP4ImtGKZCil5bzIFbdDpiZZ07kMw77sDcZ3ko,8373
8
+ braidio/music.py,sha256=D9LeXbIf1uLKJtf1a2zOATYFSRaINvFv_KbYrnDigW0,3824
9
+ braidio/project.py,sha256=lMk-X_RJBR5Y8Ls1G38cPtGQuFIQi5NnsiqWcUce9lU,1027
10
+ braidio/provenance.py,sha256=rgHUApOgpluDdhqc2dvsGoobD2pxBSVM3nTIePbIZoo,5324
11
+ braidio/render.py,sha256=HQrO-L161niOCZHSdfqDABviBNRX_RpPfM-7b0CLzWo,8499
12
+ braidio/rights.py,sha256=Ddso4VVzrmQwQ0hnNRWD157DykRWmhzNJxJ2UT0HH8k,7338
13
+ braidio/script.py,sha256=8v3KIjeyZuww0vkWgtGUkTz_k82r-EGOQSuNXcy-ELo,4490
14
+ braidio/sources.py,sha256=BBwwNAvu_B5xlEpBghW4YFZ_52aK88htI-FeOfppnvc,7661
15
+ braidio/tts.py,sha256=acFexN9_F1OMOgP8G1hnOG5Pvb2m1fTccatXqf-D81c,5749
16
+ braidio/weave.py,sha256=2B6boSvrjmkLY-Qq51bVw5cfqGIrzzuUejgl4Ia3PjE,8851
17
+ braidio/weave_config.py,sha256=RPOjI3OPHKK-sb_UJ4uxOJH3tS2uOb8RXBguf_De648,4755
18
+ braidio/bodies/__init__.py,sha256=hlDEnSLs_wUOHnHO9fMkcWxwWmB5_Z6wNu2cKdQDZTo,1218
19
+ braidio/bodies/_domain.py,sha256=lTHG7hN6yv6rXcqWXE9ZjSvc_4lBgVSl0cq640Artj8,4521
20
+ braidio/bodies/_render_nodes.py,sha256=1gYU1m7oqJX7jjWc2CfiIbezxRwqc29WoYdjf24EkiY,4100
21
+ braidio/bodies/_tiers.py,sha256=rklo0BG4l7hdC_Kf5cdZRhJ76bdG1V29P9HArmJdlIY,1226
22
+ braidio-0.0.2.dist-info/METADATA,sha256=jvtEeVnplrhXdQZWpHmOJUdBty0_Kb16uwgNwVajngE,7358
23
+ braidio-0.0.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
24
+ braidio-0.0.2.dist-info/licenses/LICENSE,sha256=ekE13yCE9fWWEJfP1NPnUJabZ_Wwrc6coKJV2ZZx27w,1068
25
+ braidio-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thor Whalen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.