foley.eval.taste#
The “tasteful weave” eval: does a sound designer produce a restrained, clean, well-placed result?
Runs a designer (passage -> ScoreResult) over a fixed passage set and REPORTS, per
passage and aggregated, the four things #45 asks of a tasteful design (report, never a gate):
restraint: sounds per sentence, under the ceiling of
SOUNDS_PER_SENTENCE_BANDper passage and inside the band over the whole set;licence cleanliness: the share of placed sounds
foley.keep()accepts under the intended use (targetLICENCE_CLEAN_TARGET, i.e. 100%); a sound with no library record is unclean (fail-closed, the same lookup the weave’s rights gate uses);placement sanity: each placed sound starts within
PLACEMENT_TOLERANCE_Sof where its cue says (its trigger word, less its pre-roll, clamped at 0 as the render does). The trigger is read from SELECT’s symbolic anchor ("on 'door'"), which edits never erase, and resolved against the timeline’s word anchors (word_timeline). What it can and cannot catch: it resolves the cue with the same resolver (resolve_placement()) and the same word timings the weave used, so an unedited cue passes by construction and inherits that resolver’s false matches (#257). So each row also says how its cue matched (match:exact/stem/fuzzy/fallback/absolute, #263) and the summary counts them: afuzzycue may sit on the wrong word, afallbackone on none. What it catches is everything else: a nudged or absolute-pinned sound, a cue word that is never spoken, a spot effect with no cue. Word timings from the fake aligner (evenly spaced estimates, the default withoutfoley[align]) are flaggedaligned=False;loudness: the woven mix’s integrated LUFS, re-measured, vs the master target, within
LOUDNESS_TOLERANCE_LU(only for passages that carry narration audio).
The designer seam: the default, score_designer(), is foley.score over the Ring-0
wav fixture with the deterministic fake LLM and generation off, so the eval runs offline in
CI. The point of the harness, though, is the agent-driven designer: a fresh agent with
only foley and the shipped foley-sound-design skill (foley.install_agent_kit(dest))
given one passage and asked for a sound design. Plug it in as any callable that returns a
ScoreResult; the metrics read only .timeline and .weave, so an
agent that hands back timeline JSON is wrapped as
ScoreResult(timeline=SoundDesignTimeline.from_dict(d), events=[]). Pass the library
that agent drew from, so the licence check judges the same records. It is never run in tests.
Fit (“is this the right sound?”) is not re-judged here: that is run_fit_eval().
Module Attributes
more sounds than sentences is "sound soup". |
|
Share of placed sounds the licence gate must keep. |
|
How far (s) a sound may land from its trigger word. |
|
How far (LU) the woven mix may sit from the master target (EBU R128's ±1 LU). |
|
Words whose trailing period does not end a sentence (lower case, no period). |
|
What the placement metric can see (echoed in the report so a reader does not over-read it). |
|
the seam this eval measures. |
Functions
|
Sentences in |
The offline default library: the Ring-0 wav fixture (6 CC0 clips, wav-backed, so it weaves). |
|
|
One |
|
Load a passage set: a JSON list of |
|
The woven mix's integrated LUFS (re-measured) vs its master target; |
|
Measure one designer result for |
|
Sentences in a passage: counted per segment, each non-empty segment at least one. |
|
One row per enabled item of a hydrated timeline: expected vs actual onset. |
|
Sounds per sentence and whether it stays under |
|
Run |
|
A designer that is |
Classes
|
One narration passage: its segments (what |
|
The four measurements for one passage (JSON-safe via |
|
The tasteful-weave eval over a passage set: per passage + aggregated, plus thresholds. |
|
The eval's thresholds in one place (defaults: the module constants). |
- foley.eval.taste.Designer#
the seam this eval measures.
- Type:
passage -> ScoreResult
alias of
Callable[[Passage],ScoreResult]
- foley.eval.taste.LICENCE_CLEAN_TARGET: float = 1.0#
Share of placed sounds the licence gate must keep. Anything under it is a defect.
- foley.eval.taste.LOUDNESS_TOLERANCE_LU: float = 1.0#
How far (LU) the woven mix may sit from the master target (EBU R128’s ±1 LU).
- foley.eval.taste.PLACEMENT_CAVEAT = 'catches nudged/pinned sounds and unspoken or missing cues; an unedited cue passes by construction (same resolver and word timings as the weave), so fuzzy and fallback cue matches are counted separately'#
What the placement metric can see (echoed in the report so a reader does not over-read it).
- foley.eval.taste.PLACEMENT_TOLERANCE_S: float = 0.25#
How far (s) a sound may land from its trigger word. Word aligners are ~±50 ms and a pre-roll is folded back in, so this only flags misplacements, not alignment jitter.
- class foley.eval.taste.Passage(id, segments, audio=None)[source]#
Bases:
objectOne narration passage: its segments (what
foley.scoretakes) and optional audio.audio(a path, bytes, or a 48 kHz ndarray) makes the default designer weave, which is what the loudness metric needs.
- class foley.eval.taste.PassageTaste(passage_id, restraint=dict(), licence=list(), placement=list(), alignment=None, loudness=None, error=None)[source]#
Bases:
objectThe four measurements for one passage (JSON-safe via
to_dict()).- property aligned: bool#
Whether the word timings came from a real alignment (not the fake’s estimates).
"cached"timings (carried on the timeline from an earlier weave) count as aligned: the eval cannot tell what produced them, so a cache of estimates passes.
Share of placed sounds the licence gate keeps (
Nonewhen nothing was placed).
Share of placed sounds within the placement tolerance.
- foley.eval.taste.SENTENCE_ABBREVIATIONS: tuple[str, ...] = ('mr', 'mrs', 'ms', 'dr', 'prof', 'st', 'sr', 'jr', 'vs', 'mt', 'lt', 'col', 'gen', 'capt', 'sgt', 'rev', 'fr', 'approx')#
Words whose trailing period does not end a sentence (lower case, no period). Single letters (initials,
e.g.,U.S.) are skipped as well.
- foley.eval.taste.SOUNDS_PER_SENTENCE_BAND: tuple[float, float] = (0.1, 1.0)#
more sounds than sentences is “sound soup”. The floor holds over the whole set only, since a quiet passage left quiet is taste, while a designer that scores nothing anywhere is mute.
- Type:
Sane density band (sounds per sentence, inclusive). The ceiling holds per passage
- class foley.eval.taste.TasteReport(designer, passages, thresholds=TasteThresholds())[source]#
Bases:
objectThe tasteful-weave eval over a passage set: per passage + aggregated, plus thresholds.
- summary()[source]#
The aggregate numbers (pooled over sounds, or over passages for the band/loudness).
- Return type:
- class foley.eval.taste.TasteThresholds(sounds_per_sentence=(0.1, 1.0), licence_clean_target=1.0, placement_tolerance_s=0.25, loudness_tolerance_lu=1.0)[source]#
Bases:
objectThe eval’s thresholds in one place (defaults: the module constants).
- foley.eval.taste.count_sentences(text, *, abbreviations=('mr', 'mrs', 'ms', 'dr', 'prof', 'st', 'sr', 'jr', 'vs', 'mt', 'lt', 'col', 'gen', 'capt', 'sgt', 'rev', 'fr', 'approx'))[source]#
Sentences in
text: terminators (.!?, closing quotes allowed) plus an open tail.An ellipsis does not end a sentence, nor does the period of an abbreviation (
abbreviations) or of a single letter (initials,e.g.,U.S.).- Return type:
- foley.eval.taste.eval_library()[source]#
The offline default library: the Ring-0 wav fixture (6 CC0 clips, wav-backed, so it weaves).
- foley.eval.taste.licence_rows(items, library, intended_use)[source]#
One
{clip_ref, clean, reason}row per placed sound, judged by its library record.The weave’s own rights re-check (
foley.licensing.refusals()overplaced_record()), so the rule and its wording are the same: fail-closed, a sound with no readable record is refused.
- foley.eval.taste.load_passages(path=PosixPath('/home/runner/work/foley/foley/foley/data/taste/passages.json'))[source]#
Load a passage set: a JSON list of
{id, segments, audio?}.A relative
audiopath resolves against the JSON file’s folder.
- foley.eval.taste.loudness_row(weave, *, tolerance_lu=1.0)[source]#
The woven mix’s integrated LUFS (re-measured) vs its master target;
Noneunwoven.
- foley.eval.taste.measure_passage(passage, result, *, library, intended_use, thresholds=TasteThresholds(sounds_per_sentence=(0.1, 1.0), licence_clean_target=1.0, placement_tolerance_s=0.25, loudness_tolerance_lu=1.0))[source]#
Measure one designer result for
passage(reads only.timelineand.weave).- Return type:
- foley.eval.taste.passage_sentences(passage)[source]#
Sentences in a passage: counted per segment, each non-empty segment at least one.
- Return type:
- foley.eval.taste.placement_rows(timeline, *, tolerance_s=0.25)[source]#
One row per enabled item of a hydrated timeline: expected vs actual onset.
The expected onset is the trigger less the item’s pre-roll, clamped at 0 exactly as the render clamps it (so a sound cued on the first word is not read as pre-roll late). An item with no trigger is
ok=False(trigger_s=None): a spot effect must hang on a word. SeePLACEMENT_CAVEATfor what this can and cannot catch.
- foley.eval.taste.restraint(n_sounds, n_sentences, *, band=(0.1, 1.0))[source]#
Sounds per sentence and whether it stays under
band’s ceiling (one passage).- Return type:
- foley.eval.taste.run_taste_eval(passages=None, *, designer=None, library=None, intended_use=None, thresholds=TasteThresholds(sounds_per_sentence=(0.1, 1.0), licence_clean_target=1.0, placement_tolerance_s=0.25, loudness_tolerance_lu=1.0))[source]#
Run
designeroverpassagesand report restraint / licence / placement / loudness.Report-only: nothing here fails a build. A passage whose designer raises is recorded with its error and left out of the aggregates; a malformed passage set is refused up front (
ValueErrornaming every bad passage), and a metric bug raises.- Parameters:
passages (
Union[None,str,Path,Iterable]) – The passage set:None(the shipped set), a JSON path, or an iterable ofPassage/{id, segments, audio?}dicts.designer (
Optional[Callable[[Passage],ScoreResult]]) –passage -> ScoreResult(default:score_designer()overlibrary).library – The library the designer draws from, used for the licence check. Default:
eval_library()with the default designer, elsefoley’s default library.intended_use – The rights intent (default: commercial publishing, as
foley.score).thresholds (
TasteThresholds) – ATasteThresholds(default: the module constants); echoed in the report.
- Return type:
- Returns:
A
TasteReport(to_dict()for JSON,to_markdown()for people).
- foley.eval.taste.score_designer(*, library=None, intended_use=None, llm='fake', generate=False, aligner=None, **score_kwargs)[source]#
A designer that is
foley.scoreon a passage’s segments (and audio, when it has some).Defaults are the offline, deterministic ones: the fake LLM, no generation fallback (
Budget(allow_generate=False, max_usd=0)) and the fake aligner (even withfoley[align]installed), so nothing is fetched, generated or paid and runs repeat.generate=True,llm=None($FOLEY_LLM) and a realalignergive the production behaviour.- Return type: