braidio 0.0.87__tar.gz → 0.0.89__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.87 → braidio-0.0.89}/PKG-INFO +2 -2
- {braidio-0.0.87 → braidio-0.0.89}/braidio/cost.py +16 -6
- {braidio-0.0.87 → braidio-0.0.89}/braidio/weave.py +52 -25
- {braidio-0.0.87 → braidio-0.0.89}/pyproject.toml +4 -2
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_cost.py +26 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_transforms_rights.py +3 -4
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_transforms_structure.py +2 -2
- braidio-0.0.89/tests/test_weave_master.py +68 -0
- {braidio-0.0.87 → braidio-0.0.89}/.editorconfig +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/.gitattributes +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/.gitignore +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/LICENSE +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/README.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/__init__.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/_paths.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/bodies/__init__.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/bodies/_domain.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/bodies/_render_nodes.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/bodies/_tiers.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/bodies/_video.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/captions.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/compose.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/conversation.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/data/skills/braidio/SKILL.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/data/skills/braidio-commentary-video/SKILL.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/defaults.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/delivery.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/downloads.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/formats.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/genre.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/importing/__init__.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/importing/__main__.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/importing/_catalog.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/importing/_manifest.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/importing/_writer.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/kinds.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/leveling.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/markdown_script.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/__init__.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/_docs.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/_guide.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/_helpers.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/_media.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/credentials.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/metering.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/tools.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/mcp/workspace.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/multivoice.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/music.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/pacing.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/project.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/provenance.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/relevance.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/render.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/rights.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/script.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/sources.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/structure.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/style.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/textprep.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/timeline.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/__init__.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_asset_refs.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_common.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_dialogue.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_episode.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_ingest.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_narration.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_segment.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_video_cut.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_video_panels.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/transforms/_voice.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/tts.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/video.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/voice_library.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/braidio/weave_config.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/conftest.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/Extraction and nw-App Design.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/research/commentary-formats-and-styles.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/research/conversational-vs-narration-tts.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/research/notebooklm-and-conversational-pacing.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/README.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/anti-platitude-checklist.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/commentary-voice-guide.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/_style-groups.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/amanda-dobbins.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/david-sims.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/griffin-newman.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/helen-molesworth.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/hrishikesh-hirway.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/jason-mantzoukas.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/john-mcwhorter.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/jon-caramanica.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/june-diane-raphael.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/karina-longworth.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/katy-hessel.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/louis-theroux.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/mallory-rubin.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/melvyn-bragg.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/michael-barbaro.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/nate-sloan-charlie-harding.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/paul-scheer.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/sean-fennessey.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/talk-art.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/style/voices/yasi-salek.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/misc/docs/youtube_ingest_credentials.md +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/_audio.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_body_schema_stability.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_conversation.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_credits_card.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_defaults.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_delivery.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_downloads.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_expressiveness.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_formats.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_genre_placement.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_graph_speak.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_importing.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_leveling.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_markdown_script.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_mcp.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_mcp_caller_key.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_media_auth.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_multivoice.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_music.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_namespaced_source.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_nw_app.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_pacing.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_packaging.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_render_settings.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_script.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_sources.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_speak_seam.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_structure.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_textprep_style.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_timeline.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_transforms.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_transforms_dialogue.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_transforms_episode_members.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_transforms_secrets.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_tts_api_key.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_turn_overlap.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_video.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_video_bodies.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_video_footage.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_video_transforms.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_voice_library.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_weave.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/tests/test_weave_config.py +0 -0
- {braidio-0.0.87 → braidio-0.0.89}/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.89
|
|
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
|
|
@@ -26,7 +26,7 @@ Classifier: Topic :: Multimedia :: Video
|
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
27
|
Requires-Python: >=3.10
|
|
28
28
|
Requires-Dist: elevenlabs
|
|
29
|
-
Requires-Dist: mixing[media]>=0.0.
|
|
29
|
+
Requires-Dist: mixing[media]>=0.0.85
|
|
30
30
|
Provides-Extra: dev
|
|
31
31
|
Requires-Dist: build; extra == 'dev'
|
|
32
32
|
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
@@ -180,9 +180,12 @@ class CostRollup:
|
|
|
180
180
|
return f"{self.characters:,} chars → {dollars}{tail}"
|
|
181
181
|
|
|
182
182
|
|
|
183
|
-
def _script_lines(script: Script) -> list[CostLine]:
|
|
183
|
+
def _script_lines(script: Script, *, model_id: str) -> list[CostLine]:
|
|
184
184
|
"""Billable lines of ``script``: narration + dialogue beats (segments are free).
|
|
185
185
|
|
|
186
|
+
Narration is priced at ``model_id``. A dialogue beat is always
|
|
187
|
+
:data:`~braidio.tts.DIALOGUE_MODEL_ID`, the one model Text-to-Dialogue runs on.
|
|
188
|
+
|
|
186
189
|
Estimates the *default* (personal) cut. Published-cut costing (rights-safe
|
|
187
190
|
rewrites + synthesized clip substitutes) must reuse :func:`braidio.plan_production`
|
|
188
191
|
rather than re-deriving the rights rules here — a follow-up.
|
|
@@ -195,8 +198,8 @@ def _script_lines(script: Script) -> list[CostLine]:
|
|
|
195
198
|
label=f"beat[{i}] narration",
|
|
196
199
|
kind="narration",
|
|
197
200
|
characters=billable_chars(beat.text),
|
|
198
|
-
usd=tts_cost_usd(beat.text, model_id=
|
|
199
|
-
model_id=
|
|
201
|
+
usd=tts_cost_usd(beat.text, model_id=model_id),
|
|
202
|
+
model_id=model_id,
|
|
200
203
|
)
|
|
201
204
|
)
|
|
202
205
|
elif isinstance(beat, Dialogue):
|
|
@@ -227,24 +230,31 @@ def estimate_cost(
|
|
|
227
230
|
:class:`CostRollup` reports exact characters and an honest dollar sum (a lower
|
|
228
231
|
bound when some text is unpriced; see :func:`usd_per_1k_chars`).
|
|
229
232
|
|
|
233
|
+
``model_id`` is the model the narration will be voiced with (default
|
|
234
|
+
:data:`~braidio.tts.DEFAULT_MODEL_ID`); its rate resolves like any other
|
|
235
|
+
(:func:`usd_per_1k_chars`), so a model with no confirmed rate of its own
|
|
236
|
+
gets the general rate, never another model's. Dialogue beats are priced
|
|
237
|
+
at :data:`~braidio.tts.DIALOGUE_MODEL_ID` whatever ``model_id`` says.
|
|
238
|
+
|
|
230
239
|
>>> from braidio import Script, Narration, SegmentBeat
|
|
231
240
|
>>> s = Script(title="x", id_slug="01", beats=[
|
|
232
241
|
... Narration(text="a" * 500), SegmentBeat(reference="clip:1")])
|
|
233
242
|
>>> estimate_cost(s).characters # only the narration counts; the clip is free
|
|
234
243
|
500
|
|
235
244
|
"""
|
|
245
|
+
model_id = model_id or DEFAULT_MODEL_ID
|
|
236
246
|
if isinstance(source, str):
|
|
237
247
|
lines = [
|
|
238
248
|
CostLine(
|
|
239
249
|
label="text",
|
|
240
250
|
kind="narration",
|
|
241
251
|
characters=billable_chars(source),
|
|
242
|
-
usd=tts_cost_usd(source, model_id=model_id
|
|
243
|
-
model_id=model_id
|
|
252
|
+
usd=tts_cost_usd(source, model_id=model_id),
|
|
253
|
+
model_id=model_id,
|
|
244
254
|
)
|
|
245
255
|
]
|
|
246
256
|
else:
|
|
247
|
-
lines = _script_lines(source)
|
|
257
|
+
lines = _script_lines(source, model_id=model_id)
|
|
248
258
|
|
|
249
259
|
characters = sum(ln.characters for ln in lines)
|
|
250
260
|
priced = [ln.usd for ln in lines if ln.usd is not None]
|
|
@@ -9,7 +9,8 @@ Two generic, Hamilton-agnostic primitives:
|
|
|
9
9
|
- :func:`weave_timeline` — place ordered narration/clip parts on a timeline
|
|
10
10
|
where each clip **overlaps its neighbours** by ``clip_edge_overlap_s`` and its
|
|
11
11
|
faded padded edges duck under the speech, so **speech stays dominant**, then
|
|
12
|
-
mix (``amix`` sum) and
|
|
12
|
+
mix (``amix`` sum) and master it with one measured gain and a true-peak
|
|
13
|
+
limit (:func:`mixing.loudness.level_file`), so the mix keeps its dynamics.
|
|
13
14
|
|
|
14
15
|
This is the audio counterpart of a video timeline; it consumes plain file paths
|
|
15
16
|
+ numbers, no Genius/lyrics knowledge (that resolution lives in
|
|
@@ -24,10 +25,14 @@ import json
|
|
|
24
25
|
import random
|
|
25
26
|
import shutil
|
|
26
27
|
import subprocess
|
|
28
|
+
import tempfile
|
|
27
29
|
from dataclasses import dataclass
|
|
28
30
|
from pathlib import Path
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
#: Encoder options of the mastered file (ignored by a lossless format).
|
|
33
|
+
_MASTER_ENCODE_ARGS = ("-b:a", "192k")
|
|
34
|
+
#: The unmastered mix is float, so a sum above full scale survives to the limiter.
|
|
35
|
+
_UNMASTERED_CODEC = "pcm_f32le"
|
|
31
36
|
|
|
32
37
|
#: Upper bound of the intelligible range for a speaker interruption: past it two
|
|
33
38
|
#: voices talking over each other stop being understood (Hamilton#22).
|
|
@@ -377,6 +382,10 @@ def weave_timeline(
|
|
|
377
382
|
``overlap`` (a :class:`TurnOverlap`, e.g. ``WeaveConfig.turn_overlap()``)
|
|
378
383
|
lays a change of speaker as an interruption and, with ``duck_db``, lowers
|
|
379
384
|
the outgoing voice's talked-over tail (see :func:`layout_placed`).
|
|
385
|
+
|
|
386
|
+
The mix is mastered with one measured gain to ``target_lufs`` (LUFS) and a
|
|
387
|
+
true-peak limit at ``true_peak`` (dBTP), so it keeps its own dynamics: a
|
|
388
|
+
quiet passage stays quiet relative to its loud neighbours.
|
|
380
389
|
"""
|
|
381
390
|
_require_ffmpeg()
|
|
382
391
|
if not items:
|
|
@@ -467,27 +476,45 @@ def weave_timeline(
|
|
|
467
476
|
mix = (
|
|
468
477
|
"".join(labels) + f"amix=inputs={n_inputs}:normalize=0:dropout_transition=0[m]"
|
|
469
478
|
)
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
479
|
+
filtergraph = ";".join(filters + [mix])
|
|
480
|
+
|
|
481
|
+
# Mix, then master: one measured gain to ``target_lufs`` and a true-peak limit
|
|
482
|
+
# at ``true_peak``. One-pass ``loudnorm`` would ride the gain through the mix
|
|
483
|
+
# and pull a quiet passage between two loud ones up (braidio#130). The
|
|
484
|
+
# intermediate is float on disk and ``level_file`` streams it, so memory does
|
|
485
|
+
# not grow with the episode. Imported here: the mix engine stays free of the
|
|
486
|
+
# mixing/TTS layers at import (tests/test_turn_overlap.py guards that).
|
|
487
|
+
from mixing.loudness import level_file
|
|
488
|
+
|
|
489
|
+
with tempfile.TemporaryDirectory(prefix="braidio-mix-") as work:
|
|
490
|
+
# named after ``out``: a GainCappedWarning names this file
|
|
491
|
+
unmastered = Path(work) / f"{out.stem}.wav"
|
|
492
|
+
subprocess.run(
|
|
493
|
+
[
|
|
494
|
+
"ffmpeg",
|
|
495
|
+
"-y",
|
|
496
|
+
*inputs,
|
|
497
|
+
"-filter_complex",
|
|
498
|
+
filtergraph,
|
|
499
|
+
"-map",
|
|
500
|
+
"[m]",
|
|
501
|
+
"-ar",
|
|
502
|
+
str(sample_rate),
|
|
503
|
+
"-ac",
|
|
504
|
+
"2",
|
|
505
|
+
"-c:a",
|
|
506
|
+
_UNMASTERED_CODEC,
|
|
507
|
+
str(unmastered),
|
|
508
|
+
],
|
|
509
|
+
check=True,
|
|
510
|
+
capture_output=True,
|
|
511
|
+
)
|
|
512
|
+
level_file(
|
|
513
|
+
unmastered,
|
|
514
|
+
out,
|
|
515
|
+
target_lufs=target_lufs,
|
|
516
|
+
ceiling_db=true_peak,
|
|
517
|
+
sample_rate=sample_rate,
|
|
518
|
+
encode_args=_MASTER_ENCODE_ARGS,
|
|
519
|
+
)
|
|
493
520
|
return out
|
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "braidio"
|
|
9
|
-
version = "0.0.
|
|
9
|
+
version = "0.0.89"
|
|
10
10
|
description = "Weave narration with extracted media segments into audiovisual productions"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.10"
|
|
@@ -47,8 +47,10 @@ authors = [
|
|
|
47
47
|
# Functional core deps. Also requires `ffmpeg`/`ffprobe` on PATH (system dep).
|
|
48
48
|
# mixing>=0.0.28: narrate() calls text_to_speech(return_cache_status=...) (added
|
|
49
49
|
# there) so a mixing-cache hit reports cost_usd_actual=$0 (braidio#8).
|
|
50
|
+
# mixing>=0.0.85: weave_timeline masters with mixing.loudness.level_file (one
|
|
51
|
+
# measured gain + true-peak limit, streaming; mixing#130, braidio#130).
|
|
50
52
|
dependencies = [
|
|
51
|
-
"mixing[media]>=0.0.
|
|
53
|
+
"mixing[media]>=0.0.85",
|
|
52
54
|
"elevenlabs",
|
|
53
55
|
]
|
|
54
56
|
|
|
@@ -142,6 +142,32 @@ def test_estimate_dialogue_uses_dialogue_model_rate(monkeypatch):
|
|
|
142
142
|
assert est.usd == pytest.approx(DEFAULT_USD_PER_1K_CHARS + 0.9)
|
|
143
143
|
|
|
144
144
|
|
|
145
|
+
def test_estimate_prices_the_script_at_the_named_model(monkeypatch):
|
|
146
|
+
# braidio#143: a Script used to be priced at DEFAULT_MODEL_ID whatever
|
|
147
|
+
# model_id said. Distinct confirmed rates make the model visible in the sum.
|
|
148
|
+
monkeypatch.setattr(cost_module, "DIALOGUE_MODEL_ID", "test-dialogue-model")
|
|
149
|
+
monkeypatch.setitem(MODEL_USD_PER_1K_CHARS, DEFAULT_MODEL_ID, 0.1)
|
|
150
|
+
monkeypatch.setitem(MODEL_USD_PER_1K_CHARS, "test-narration-model", 0.5)
|
|
151
|
+
monkeypatch.setitem(MODEL_USD_PER_1K_CHARS, "test-dialogue-model", 0.9)
|
|
152
|
+
script = Script(
|
|
153
|
+
title="t",
|
|
154
|
+
id_slug="01",
|
|
155
|
+
beats=[Narration(text="n" * 1000), Dialogue(turns=(("A", "d" * 1000),))],
|
|
156
|
+
)
|
|
157
|
+
est = estimate_cost(script, model_id="test-narration-model")
|
|
158
|
+
# the narration at the named model; dialogue stays on its own model
|
|
159
|
+
assert est.usd == pytest.approx(0.5 + 0.9)
|
|
160
|
+
assert [ln.model_id for ln in est.lines] == [
|
|
161
|
+
"test-narration-model",
|
|
162
|
+
"test-dialogue-model",
|
|
163
|
+
]
|
|
164
|
+
# no confirmed rate of its own: the general rate, never the default model's
|
|
165
|
+
unknown = estimate_cost(script, model_id="test-unrated-model")
|
|
166
|
+
assert unknown.usd == pytest.approx(DEFAULT_USD_PER_1K_CHARS + 0.9)
|
|
167
|
+
# no model named: the default model, as before
|
|
168
|
+
assert estimate_cost(script).usd == pytest.approx(0.1 + 0.9)
|
|
169
|
+
|
|
170
|
+
|
|
145
171
|
def test_estimate_all_segments_is_free():
|
|
146
172
|
script = Script(
|
|
147
173
|
title="t",
|
|
@@ -61,10 +61,9 @@ PRE_CHANGE_DEFAULTS = {
|
|
|
61
61
|
def tone_narration(monkeypatch):
|
|
62
62
|
"""narrate() → a fixed length of *tone*. No TTS call, no spend.
|
|
63
63
|
|
|
64
|
-
Audible rather than silent
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
keeps a tone fixture).
|
|
64
|
+
Audible rather than silent so the render's assertions have talk to find
|
|
65
|
+
(a published cut that drops its only clip is otherwise all silence); same
|
|
66
|
+
as the tone fixture in ``tests/test_transforms_structure.py``.
|
|
68
67
|
"""
|
|
69
68
|
|
|
70
69
|
def fake_narrate(text, out, *, return_cache_status=False, **kw):
|
|
@@ -81,8 +81,8 @@ def silent_narration(monkeypatch):
|
|
|
81
81
|
def tone_narration(monkeypatch):
|
|
82
82
|
"""narrate() → a fixed length of *tone*.
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
Audible talk on either side of a pause, so a render whose only other part
|
|
85
|
+
is that pause still has something to measure.
|
|
86
86
|
"""
|
|
87
87
|
|
|
88
88
|
def fake_narrate(text, out, *, return_cache_status=False, **kw):
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""The woven master keeps the mix's dynamics (braidio#130).
|
|
2
|
+
|
|
3
|
+
``weave_timeline`` used to master with one-pass ``loudnorm``, which rides the
|
|
4
|
+
gain through the mix: a quiet passage between two loud ones is pulled up, undoing
|
|
5
|
+
the per-part levelling of braidio#124. It now masters with one measured gain and
|
|
6
|
+
a true-peak limit (:func:`mixing.loudness.level_file`). These tests measure the
|
|
7
|
+
decoded output, so they fail on the old master, not merely on its arguments.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from math import log10
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from braidio.weave import TimelineItem, weave_timeline
|
|
16
|
+
|
|
17
|
+
from _audio import RATE, decode, lavfi, needs_ffmpeg, rms, tone
|
|
18
|
+
|
|
19
|
+
LOUD_S, QUIET_S = 4.0, 8.0
|
|
20
|
+
QUIET_DB = -20.0 # how far under the loud parts the middle one sits
|
|
21
|
+
EDGE_S = 0.5 # stay clear of each part's edges when measuring it
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _quiet_tone(path: Path, duration_s: float) -> Path:
|
|
25
|
+
src = f"sine=frequency=440:sample_rate={RATE},volume={QUIET_DB}dB"
|
|
26
|
+
return lavfi(path, src, duration_s)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _render(
|
|
30
|
+
tmp_path: Path, *, target_lufs: float = -16.0, true_peak: float = -1.0
|
|
31
|
+
) -> Path:
|
|
32
|
+
items = [
|
|
33
|
+
TimelineItem("narration", str(tone(tmp_path / "a.wav", 440, LOUD_S))),
|
|
34
|
+
TimelineItem("narration", str(_quiet_tone(tmp_path / "q.wav", QUIET_S))),
|
|
35
|
+
TimelineItem("narration", str(tone(tmp_path / "b.wav", 440, LOUD_S))),
|
|
36
|
+
]
|
|
37
|
+
return weave_timeline(
|
|
38
|
+
items,
|
|
39
|
+
tmp_path / "out.wav",
|
|
40
|
+
narration_crossfade_s=0.0,
|
|
41
|
+
target_lufs=target_lufs,
|
|
42
|
+
true_peak=true_peak,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@needs_ffmpeg
|
|
47
|
+
def test_a_quiet_passage_between_loud_ones_stays_quiet(tmp_path):
|
|
48
|
+
pcm = decode(_render(tmp_path))
|
|
49
|
+
loud = rms(pcm, EDGE_S, LOUD_S - EDGE_S)
|
|
50
|
+
quiet = rms(pcm, LOUD_S + EDGE_S, LOUD_S + QUIET_S - EDGE_S)
|
|
51
|
+
# one gain for the whole mix: the 20 dB gap survives (loudnorm closed it to
|
|
52
|
+
# within its LRA target, so the middle came out well above -20 dB)
|
|
53
|
+
assert abs(20 * log10(quiet / loud) - QUIET_DB) < 1.0
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@needs_ffmpeg
|
|
57
|
+
def test_the_master_reaches_the_target_under_the_ceiling(tmp_path):
|
|
58
|
+
import numpy as np
|
|
59
|
+
from mixing.decode import decode_float_chunks
|
|
60
|
+
from mixing.loudness import file_loudness, true_peak_db
|
|
61
|
+
|
|
62
|
+
# a sine peaks ~0.7 dB above its loudness, so a -10 LUFS gain would put the
|
|
63
|
+
# peaks near -9.3 dBTP: the -12 dBTP ceiling has to take ~3 dB off them
|
|
64
|
+
out = _render(tmp_path, target_lufs=-10.0, true_peak=-12.0)
|
|
65
|
+
rate, chunks = decode_float_chunks(out)
|
|
66
|
+
assert true_peak_db(np.concatenate(list(chunks)), rate) <= -12.0 + 0.3
|
|
67
|
+
# the limiter took the peaks, not the level: still close to the target
|
|
68
|
+
assert file_loudness(out).integrated_lufs > -14.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{braidio-0.0.87 → braidio-0.0.89}/misc/docs/research/notebooklm-and-conversational-pacing.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|