diff --git a/README.md b/README.md index 5e1f21d..68198c9 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Measured again on release 0.1.0: the cut finder still found 24 of the 25 hard cu ## What it cannot do -- **Hear, by itself.** The tool measures loudness, word times, and where sound events fall on the shot changes, flashes and caption appearances, but not what a sound is. Most agents cannot hear either, and then music, tone of voice and sound effects are marked as not judged. An agent whose model takes sound as input can, after it passes the tool's hearing check (a voice saying six random digits, marked by the tool); it then says what the sound is, marked heard by the agent. We verified this path with a hearing model driven by a script, not yet with a full coding agent that can hear. Speech recognition can return words where nobody speaks: the tool flags those the recognizer itself rates as possibly not speech, and the agent checks the mouth and sets them aside (the red-carpet example). Words without the flag can still be music. Without speech recognition there are no spoken lines at all. +- **Hear, by itself.** The tool measures loudness, word times, and where sound events fall on the shot changes, flashes and caption appearances, but not what a sound is. Most agents cannot hear either, and then music, tone of voice and sound effects are marked as not judged. An agent whose model takes sound as input can, after it passes the tool's hearing check (a voice saying six random digits, marked by the tool); it then says what the sound is, marked heard by the agent. This path has been verified with a hearing model driven by a script and end to end with a coding agent whose model takes audio (opening the WAV files with its file-reading tool, passing the hearing check on the first try, and describing the music, sung lyrics, camera shutter clicks and crowd sound on the red-carpet video); how accurate heard descriptions are across videos has not been scored. Speech recognition can return words where nobody speaks: the tool flags those the recognizer itself rates as possibly not speech, and the agent checks the mouth and sets them aside (the red-carpet example). Words without the flag can still be music. Without speech recognition there are no spoken lines at all. - **Read text by itself.** The tool finds captions and when they change; the agent reads the words from the pictures. Over a picture that holds still, the tool often cannot tell a caption from the picture behind it: it then says which seconds its search for captions that stay up did not cover and why it could not measure a caption's style, and the agent gives its own reading and says so. - **Catch every edit.** A jump cut inside one framing is found when a tenth of the picture or more changes in one frame and keeps its colors: 7 of 9 on a 45-second talking video (measured on 0.1.0). Smaller jumps are flagged for the agent or not found, and so is a jump hidden under a flash; a different outfit, person or object faded in over the same background is not detected; a slow dissolve can be missed. A flash is told apart from a change of picture only when the whole change takes two or three frames; a longer one counts as a shot change. [`references/TOOL.md`](skills/riffsheet/references/TOOL.md) lists every known limit. - **Handle long videos well.** It is made for clips up to about a minute and was tested on clips of 8 to 45 seconds. A longer video runs with its overview pictures spaced further apart, and past three minutes the tool warns what will be slow. diff --git a/README.zh-CN.md b/README.zh-CN.md index e851ada..32a810a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -127,7 +127,7 @@ agent 遵循的流程见 [`references/METHOD.md`](skills/riffsheet/references/ME ## 它做不到什么 -- **自己听。** 工具测量响度、词的时间,以及声音事件落在镜头切换、闪白和字幕出现处的情况,但说不出那是什么声音。大多数 agent 也听不了,这时音乐、语气和音效都标为未判断。模型能接收声音的 agent 可以听:先通过工具的听力检查(一个声音念出六个随机数字,由工具判对错),之后它说出那是什么声音,并标为 agent 听到。这条路我们用一个由脚本驱动、能听的模型验证过,还没有用一个能听的完整编程 agent 验证过。没人说话时语音识别也可能返回文字:识别器自己估计可能不是说话的文字,工具会标出来,agent 检查嘴型后把它们放到一边(见 red-carpet 示例)。没被标出的文字也可能是音乐。没有语音识别时,就完全没有台词。 +- **自己听。** 工具测量响度、词的时间,以及声音事件落在镜头切换、闪白和字幕出现处的情况,但说不出那是什么声音。大多数 agent 也听不了,这时音乐、语气和音效都标为未判断。模型能接收声音的 agent 可以听:先通过工具的听力检查(一个声音念出六个随机数字,由工具判对错),之后它说出那是什么声音,并标为 agent 听到。这条路已经用一个由脚本驱动、能听的模型验证过,也用模型支持音频输入的编程 agent 端到端验证过(用读文件工具打开 WAV 文件、首次通过听力检查,并在 red-carpet 视频上描述了音乐、唱词、相机快门声和人群欢呼声);听到的描述在多条视频上的准确度还没有打分。没人说话时语音识别也可能返回文字:识别器自己估计可能不是说话的文字,工具会标出来,agent 检查嘴型后把它们放到一边(见 red-carpet 示例)。没被标出的文字也可能是音乐。没有语音识别时,就完全没有台词。 - **自己读文字。** 工具找出字幕以及字幕何时变化;文字由 agent 从图片上读出。画面基本不动时,工具常常分不清字幕和它后面的画面:这时它会说明找常驻字幕的检测没有覆盖哪几秒、字幕样式为什么测不出来,agent 给出自己的判断并注明。 - **抓到每一处剪辑。** 同一机位内的跳切,要在一帧之内有十分之一以上的画面变化、且颜色保持一致才会被找到:在一条 45 秒的口播视频上找到 9 处中的 7 处(在 0.1.0 上测得)。更小的跳切会提示 agent 判断,或者找不到,藏在闪白下面的跳切也是这样;在同一背景上淡入另一套衣服、另一个人或另一个物体检测不到;缓慢的叠化可能漏掉。闪白只有在整个变化持续两到三帧时,才能和换画面区分开;更长的会算作镜头切换。全部已知局限见 [`references/TOOL.md`](skills/riffsheet/references/TOOL.md)。 - **处理好长视频。** 它为一分钟以内的片段设计,在 8 到 45 秒的片段上测试过。更长的视频照样能跑,但总览图的间隔会拉大;超过三分钟时,工具会提示哪些步骤会慢。 diff --git a/skills/riffsheet/references/METHOD.md b/skills/riffsheet/references/METHOD.md index de8c7ee..22c09e9 100644 --- a/skills/riffsheet/references/METHOD.md +++ b/skills/riffsheet/references/METHOD.md @@ -102,7 +102,7 @@ Markers. People and `source_image` entities appear only as `[image:id]`, whereve Delivery around each `[voice:X]`: who, on or off camera, the pace word, the expression or gesture while speaking, and loudness only relative to the other lines (from the RMS series). Pitch, stress, accent, vocal age, register and energy go under that segment's `cannot_judge`. Quote every loudness fact (level range, a quietest stretch, a drop, sound without words) from the LOUDNESS FACTS lines of `summary.txt`, with its numbers. Write a comparison (quietest, loudest, the first, so far, rises, falls back) only when that line states it for that stretch; otherwise give the stretch's own level and compare nothing. -Hearing. The tool cannot hear, and most agents cannot either; whether you can is settled by the tool's test, never by what you believe of yourself. `rs hear-check DIR` writes `DIR/hearing/check_N.wav`, a voice saying six random digits. Open it the way you open the pictures, with the tool that reads a file into your input; if your model takes sound as input, it reaches you as sound: listen, and answer with the six digits you heard, in order, and nothing else (`rs hear-check DIR --answer DIGITS`). Answer `rs hear-check DIR --cannot-hear` only after trying, when opening the file gives you nothing to listen to (an error that the file type is not supported, raw bytes, or a description of the file in place of its sound); not knowing whether you can hear is no reason to answer it. Never work the digits out by measuring the file (decoding it, a recognizer, a script, a waveform): that would pass a check you did not hear and make every later statement about the sound an invention. A failed check may be retaken only when you heard the file and mistyped. After a pass, `rs listen DIR` writes sound files to `DIR/listen/`: `whole.wav` for a video of 60 s or less, and `sound_A_B.wav` around each measured sound event (from 1 s before its onset to 2 s after, touching windows merged, and left out when they cover half the track and the whole is cut; `--from S --to E` cuts any other window). Open them as sound and state what you hear under `heard` in the judgment file, one sound per entry: `about` is `music` (music or not, and what kind: instruments, tempo, energy, sung or not), `voice` (tone of voice, laughter, a sung line), `effect` (what a sound effect is), `ambience` (the room, the street) or `other`; `clip` is the file it was heard in, and `time` the stretch inside it (default: the whole clip). `riffsheet.md` tells each statement in the beat its `time` overlaps most, so give the stretch you mean: one on `whole.wav` without a `time` goes into the longest beat. State only what you heard; times and loudness stay the tool's measurements, and when the loudness and what you heard seem to disagree, say so under `uncertain`. Each statement goes out marked heard by the agent. Without a pass, `build` refuses `heard` and what the sound is stays under `cannot_judge`. +Hearing. The tool cannot hear, and most agents cannot either; whether you can is settled by the tool's test, never by what you believe of yourself. `rs hear-check DIR` writes `DIR/hearing/check_N.wav`, a voice saying six random digits. Open it the way you open the pictures, with the tool that reads a file into your input; if your model takes sound as input, it reaches you as sound: listen, and answer with the six digits you heard, in order, and nothing else (`rs hear-check DIR --answer DIGITS`). Answer `rs hear-check DIR --cannot-hear` only after trying, when opening the file gives you nothing to listen to (an error that the file type is not supported, raw bytes, or a description of the file in place of its sound); not knowing whether you can hear is no reason to answer it. Never work the digits out by measuring the file (decoding it, a recognizer, a script, a waveform): that would pass a check you did not hear and make every later statement about the sound an invention. A failed check may be retaken only when you heard the file and mistyped. After a pass, `rs listen DIR` writes sound files to `DIR/listen/`: `whole.wav` for a video of 60 s or less, and `sound_A_B.wav` around each measured sound event (from 1 s before its onset to 2 s after, touching windows merged, and left out when they cover half the track and the whole is cut; `--from S --to E` cuts any other window). Open them as sound and state what you hear under `heard` in the judgment file, one sound per entry: `about` is `music` (music or not, and what kind: instruments, tempo, energy, sung or not), `voice` (tone of voice, laughter, a sung line), `effect` (what a sound effect is), `ambience` (the room, the street) or `other`; `clip` is the file it was heard in (with or without `.wav`, as `whole` or `whole.wav`), and `time` the stretch inside it (default: the whole clip). `riffsheet.md` tells each statement in the beat its `time` overlaps most, so give the stretch you mean: one on `whole.wav` without a `time` goes into the longest beat. State only what you heard; times and loudness stay the tool's measurements, and when the loudness and what you heard seem to disagree, say so under `uncertain`. Passing the hearing check does not replace speech recognition: without a transcript, spoken lines stay absent and prose and report still must not state that nobody speaks (record what you heard in the track under `heard` instead). Each statement goes out marked heard by the agent. Without a pass, `build` refuses `heard` and what the sound is stays under `cannot_judge`. Sound under the voice. Loudness comes from the mixed track: it separates no voice from music and names no sound. The UNDER THE VOICE line of `summary.txt` settles what it can: NO CONTINUOUS BED, write that the pauses between words fall to near silence, as measured; SOMETHING CONTINUES, write that a continuous sound sits under the voice at the stated level, and put whether it is music or ambience under `cannot_judge`; UNCLEAR or NOT MEASURABLE, put whether music is present under `cannot_judge`. Music, a beat, a drop or a rise in music is never named from loudness alone: only as heard, under `heard`, after a passed hearing check (Hearing, above). Without a pass, `build` lists as a problem any sentence of the judgment that says what the sound is (music, a song, a sound effect, a tone of voice; the words are in `references/TOOL.md`, Sound words), wherever it stands, outside `cannot_judge`. diff --git a/skills/riffsheet/references/TOOL.md b/skills/riffsheet/references/TOOL.md index c9466bd..306fc9c 100644 --- a/skills/riffsheet/references/TOOL.md +++ b/skills/riffsheet/references/TOOL.md @@ -120,7 +120,7 @@ Color warnings. For each confirmed mark, `build` takes the color words in it (wh - Drawn elements are offered by `scan` only from clear evidence; most cards, icons and logos over a locked picture are measured only on request (`element`). An element on a perfectly still background gets no box from `element` either: with nothing behind it changing, nothing separates it from the background, so give its box by eye (`box` and `time` with a `why`). A thin element on a moving picture of similar color can come out a few pixels short at thin tips. - Text states on a moving picture: until a drawn layer has held for two frames, nothing separates layer from picture, so a sharp change of the picture can still split a state (extra states, same words), and a change of an animated caption (sliding, zooming) can be missed: those states are marked `?` and shown by first and last frame. Text so thin that its strokes blend with the picture behind never holds exactly and is treated the same way. Drawn content other than the caption inside the box (a screen recording that scrolls) splits states too. Word-by-word highlight captions give one state per highlight move. - Caption style needs evidence that separates it from the picture: pixels that held while the picture moved, or that changed at both of the state's edges. A caption that changes on the same frames as cuts over a still picture has neither and is left unmeasured (`build` takes the values from a measured caption of the same region, tagged inferred). Over a picture that holds still apart from small movement (a person standing in a room), the picture moves too little for holding through motion to tell the caption from it, and at the edges of a thin caption the picture moving around its letters changes too, so a region can keep no measured style at all; `text` then says so (NO STYLE MEASURED) and the style is your reading. Two text lines close together can merge into one measured row; such a row height is withdrawn when it disagrees with the region's. Outline vs shadow is decided by whether the second color hugs the fill on all four sides; a soft semi-transparent shadow is not reported. -- The tool cannot hear. Loudness comes from the mixed track, so it cannot tell a voice from music, or music from room sound or ambience under the voice. What a sound is comes only from an agent that passed the hearing check, marked heard by the agent; the check was verified with a hearing model driven by a script, not yet with a coding agent that can hear. +- The tool cannot hear. Loudness comes from the mixed track, so it cannot tell a voice from music, or music from room sound or ambience under the voice. What a sound is comes only from an agent that passed the hearing check, marked heard by the agent; this path has been verified with a hearing model driven by a script and end to end with a coding agent whose model takes audio (opening the WAV files with its file-reading tool, passing the check on the first try, and describing the sound on the red-carpet video), though heard descriptions have not been scored across videos. - SOUND AT THE CUTS and SOUND AT CAPTION APPEARANCES measure times only: whether a loudness event falls on a picture change or a caption's first frame, not what the sound is, and not a beat too soft to make a peak. - Speech recognition can return words where nobody speaks (music, a sung line, noise): on a 12-second video edited to music it returned a short Korean phrase, which its own no-speech probability (0.41) flags POSSIBLY NOT SPEECH. The flag is the recognizer's estimate for a whole stretch of up to 30 s (section 1): words over music in a stretch that also holds speech are not flagged, other words it does not flag can be music too, and flagged words can be speech. Check the mouth with `mouth` and give words that are not speech as `music_words` with the reason. - A caption measured on one state alone has no other state to agree with. Its style is withdrawn when its layer reaches an edge of the box, where a still part of the picture can run in (a still stretch of sky beside a caption over a moving picture); this also withdraws a right style whose box cuts the text or touches a still part of the picture. A still part of the picture lying wholly inside the box can still be taken for the caption. Agreement between states separates the caption only where the pictures behind them differ: states over one still picture whose layers take in the same still part of it (reaching one edge of the box, or lying inside it) agree on that part's color. Compare the measured style with the image and give your reading with a `why`. diff --git a/skills/riffsheet/scripts/riffsheet_lib/build.py b/skills/riffsheet/scripts/riffsheet_lib/build.py index c5effda..8c900b1 100644 --- a/skills/riffsheet/scripts/riffsheet_lib/build.py +++ b/skills/riffsheet/scripts/riffsheet_lib/build.py @@ -30,7 +30,7 @@ view_name, written_colors, ) -from .hearing import HEARD_ABOUT, hearing_state, listen_clips +from .hearing import HEARD_ABOUT, clip_name, hearing_state, listen_clips from .layers import _near, withdrawn from .picture import FLASHES from .report import fix_articles, report_md @@ -991,11 +991,12 @@ def build_heard(s): if not (isinstance(x, dict) and isinstance(x.get("text"), str) and x["text"].strip()): s.problems.append(f'heard[{k}]: give each as {{"clip": NAME, "about": ..., "text": "..."}}') continue - clip = x.get("clip") - span = clips.get(clip) if isinstance(clip, str) else None + raw_clip = x.get("clip") + clip = clip_name(raw_clip) if isinstance(raw_clip, str) else None + span = clips.get(clip) if clip else None if not span: s.problems.append( - f"heard[{k}]: clip {json.dumps(clip, ensure_ascii=False)} is not a sound file `listen` cut in this " + f"heard[{k}]: clip {json.dumps(raw_clip, ensure_ascii=False)} is not a sound file `listen` cut in this " f"scan folder ({', '.join(sorted(clips)) or 'none yet: run listen'})" ) continue diff --git a/skills/riffsheet/scripts/riffsheet_lib/hearing.py b/skills/riffsheet/scripts/riffsheet_lib/hearing.py index ddaaa22..a9538b1 100644 --- a/skills/riffsheet/scripts/riffsheet_lib/hearing.py +++ b/skills/riffsheet/scripts/riffsheet_lib/hearing.py @@ -290,11 +290,12 @@ def listen_windows(idx): out = [] if dur <= LISTEN_WHOLE_MAX_S: out.append(("whole", 0.0, dur)) + # events are sorted by e["t"], while refine_onsets can place a later event's onset_t earlier + times = sorted( + e["t"] if e.get("onset_t") is None else e["onset_t"] for e in (idx.get("audio") or {}).get("events", []) + ) spans = [] - for e in (idx.get("audio") or {}).get("events", []): - t = e.get("onset_t") - if t is None: # no onset found on the 10 ms levels (refine_onsets wrote None): the event's own time - t = e["t"] + for t in times: a_, b_ = max(0.0, t - LISTEN_BEFORE_S), min(dur, t + LISTEN_AFTER_S) if spans and a_ <= spans[-1][1]: spans[-1][1] = max(spans[-1][1], b_) @@ -307,6 +308,12 @@ def listen_windows(idx): return out +def clip_name(path): + """A `listen` clip's name: its file name without a trailing `.wav` (as view_name does for `.jpg`).""" + name = os.path.basename(path.strip()) + return name[:-4] if name.lower().endswith(".wav") else name + + def listen_path(d): return os.path.join(listen_dir(d), "listen.json") diff --git a/skills/riffsheet/scripts/riffsheet_lib/report.py b/skills/riffsheet/scripts/riffsheet_lib/report.py index 003dd82..b862c55 100644 --- a/skills/riffsheet/scripts/riffsheet_lib/report.py +++ b/skills/riffsheet/scripts/riffsheet_lib/report.py @@ -270,9 +270,13 @@ def report_md(idx, A, J): + [x for p in segs for x in p.get("claims", {}).get("cannot_judge_locally", [])] ) if cj: - L += ["", "## Not judged (needs hearing, or motion the still pictures do not settle)", ""] + [ - f"- {x}" for x in cj - ] + heard_or_silent = (hearing or {}).get("state") in ("passed", "no_audio_track") + heading = ( + "## Not judged (what the pictures and measurements do not settle)" + if heard_or_silent + else "## Not judged (needs hearing, or motion the still pictures do not settle)" + ) + L += ["", heading, ""] + [f"- {x}" for x in cj] unc = [] for e in ents: if e["kind"] == "person" and e.get("_notes"): diff --git a/tests/test_hearing.py b/tests/test_hearing.py index f67a2a7..e8a96c9 100644 --- a/tests/test_hearing.py +++ b/tests/test_hearing.py @@ -117,6 +117,27 @@ def windows(dur, onsets): # an event with no onset found (onset_t None) gets its window around its own time idx = {"facts": {"duration_video_s": 20.0}, "audio": {"events": [{"t": 10.0, "onset_t": None}]}} self.assertEqual(hearing.listen_windows(idx), [("whole", 0.0, 20.0), ("sound_09.00_12.00", 9.0, 12.0)]) + # events are sorted by e["t"], while refine_onsets can place a later event's onset_t earlier + out_of_order = { + "facts": {"duration_video_s": 20.0}, + "audio": { + "events": [ + {"t": 10.0, "onset_t": 10.5}, + {"t": 10.2, "onset_t": 9.8}, + {"t": 15.0, "onset_t": 15.0}, + {"t": 15.1, "onset_t": 5.0}, + ] + }, + } + self.assertEqual( + hearing.listen_windows(out_of_order), + [ + ("whole", 0.0, 20.0), + ("sound_04.00_07.00", 4.0, 7.0), + ("sound_08.80_12.50", 8.8, 12.5), + ("sound_14.00_17.00", 14.0, 17.0), + ], + ) def test_any_decimal_digits_count(self): """An agent replying in Chinese types full-width digits; the answer is marked, not a traceback.""" @@ -395,11 +416,41 @@ def test_without_a_pass_nothing_may_say_what_the_sound_is(self): ok(self, r) self.assertIn("CHECKS: all passed", r.stdout) + def test_clip_name_accepts_wav_extension_and_path(self): + """`listen` prints file names with `.wav`; `build` accepts `whole.wav` or `listen/whole.wav` as `whole`.""" + d = self.passed_copy("clip name") + heard = [ + {"clip": "whole.wav", "time": [0, 3], "about": "effect", "text": "a steady electronic tone"}, + {"clip": "listen/whole.wav", "time": [3, "end"], "about": "effect", "text": "the same steady tone"}, + ] + r, out = self.heard_build(d, "heard wav name", heard) + ok(self, r) + self.assertIn("CHECKS: all passed", r.stdout) + A = json.loads(read(os.path.join(out, "riffsheet.json"))) + self.assertEqual([h["clip"] for h in A["audio"]["heard"]], ["whole", "whole"]) + r, _ = self.heard_build(d, "heard bad wav", [{"clip": "sound_99.wav", "about": "effect", "text": "a click"}]) + self.assertIn('clip "sound_99.wav" is not a sound file `listen` cut', r.stdout) + def test_not_judged_says_why(self): - r, out = clips.build_judgment(self.d, self.ids, "no check") + r, out = clips.build_judgment( + self.d, self.ids, "no check", edit=lambda j: j.update(cannot_judge=["lighting-independent fabric shade"]) + ) ok(self, r) md = read(os.path.join(out, "riffsheet.md")) self.assertIn("**Sound.** Not judged: no hearing check was taken for this analysis", md) + self.assertIn("## Not judged (needs hearing, or motion the still pictures do not settle)", md) + # once the agent passed the hearing check, the heading no longer says "needs hearing" + d = self.passed_copy("not judged heading") + r, out = clips.build_judgment( + d, + self.ids, + "passed not judged", + edit=lambda j: j.update(cannot_judge=["lighting-independent fabric shade"]), + ) + ok(self, r) + md = read(os.path.join(out, "riffsheet.md")) + self.assertIn("## Not judged (what the pictures and measurements do not settle)", md) + self.assertNotIn("needs hearing", md) class RealVoice(unittest.TestCase):