dsh-watch-together 0.0.0-stage → 0.0.7
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.
- package/CHANGELOG.md +636 -0
- package/LICENSE +201 -0
- package/NOTICE +52 -0
- package/README.md +519 -3
- package/bin/lines.mjs +202 -0
- package/bin/tts.mjs +232 -0
- package/bin/watch.mjs +1722 -0
- package/cordis.patch.yml +3 -0
- package/docs/BRIDGE.zh.md +436 -0
- package/docs/CONFIG.zh.md +298 -0
- package/docs/VOICE.zh.md +255 -0
- package/dsh.plugin.json +12 -0
- package/examples/floating-chat/aec.py +135 -0
- package/examples/floating-chat/launch.cmd +5 -0
- package/examples/floating-chat/mic.py +398 -0
- package/examples/floating-chat/window.py +320 -0
- package/examples/voice-edge-tts/index.mjs +185 -0
- package/extension/background.js +96 -0
- package/extension/content.js +74 -0
- package/extension/icons/icon128.png +0 -0
- package/extension/icons/icon16.png +0 -0
- package/extension/icons/icon48.png +0 -0
- package/extension/manifest.json +34 -0
- package/extension/popup.html +38 -0
- package/extension/popup.js +57 -0
- package/extension/welcome.html +66 -0
- package/package.json +87 -4
- package/scripts/bridge.cmd +16 -0
- package/scripts/check-syntax.mjs +56 -0
- package/scripts/install-dev.mjs +149 -0
- package/scripts/install-extension.cmd +29 -0
- package/scripts/start-edge-debug.cmd +41 -0
- package/scripts/sync-dep.mjs +68 -0
- package/scripts/watch-e2e.mjs +128 -0
- package/scripts/watch-sim.mjs +92 -0
- package/src/batches.js +126 -0
- package/src/chat-server.js +198 -0
- package/src/chat-store.js +318 -0
- package/src/chat-view.js +70 -0
- package/src/chat.js +35 -0
- package/src/floating-window.js +162 -0
- package/src/handler.js +175 -0
- package/src/index.js +115 -0
- package/src/input-surface.js +153 -0
- package/src/interrupt.js +154 -0
- package/src/latency.js +76 -0
- package/src/lines-util.js +366 -0
- package/src/position-bridge.js +178 -0
- package/src/position.js +160 -0
- package/src/register.js +34 -0
- package/src/speech-bus.js +192 -0
- package/src/speech.js +104 -0
- package/src/time.js +16 -0
- package/src/timer.js +119 -0
- package/src/tool-spec.js +445 -0
- package/src/voice-adapter.js +122 -0
- package/src/voice.js +33 -0
- package/src/watch-actions.js +127 -0
- package/src/watch-browser.js +83 -0
- package/src/watch-lines.js +395 -0
- package/src/watch-loop.js +690 -0
- package/src/watch-material.js +104 -0
- package/src/watch-modes.js +167 -0
- package/src/watch-run.js +746 -0
- package/src/watch-source.js +144 -0
- package/src/watch-state.js +178 -0
- package/src/watch.js +43 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to **dsh-watch-together** are documented here.
|
|
4
|
+
This package starts its own version line at `0.0.7` — it is not a continuation of `dsh-video-storyboard`.
|
|
5
|
+
|
|
6
|
+
## [0.0.7] — 2026-10-31 (first release)
|
|
7
|
+
|
|
8
|
+
The first published version. One tool, `watch_together`: it follows the user's real playback
|
|
9
|
+
position, hands the model one storyboard + transcript per segment just before that segment ends,
|
|
10
|
+
and speaks the scripted lines at the second they belong to.
|
|
11
|
+
|
|
12
|
+
**Licence: Apache-2.0** (the package was developed under MIT and switched before the first
|
|
13
|
+
public release, to match `dsh-video-storyboard`). `LICENSE` is the full text, `NOTICE` states
|
|
14
|
+
what the project deliberately does **not** do — no hosted video, no uploaded position, no DRM or
|
|
15
|
+
paywall bypass, no bundled TTS engine.
|
|
16
|
+
|
|
17
|
+
### Repo hygiene — the extension's manifest and icons were never committed
|
|
18
|
+
|
|
19
|
+
`.gitignore` carried `manifest*.json` and `*.png` (meant for CLI artifacts). Those two rules also
|
|
20
|
+
swallowed `extension/manifest.json` and `extension/icons/*.png`, so a clone would have shipped an
|
|
21
|
+
extension **with no manifest** — completely broken, and nothing would have failed until someone tried
|
|
22
|
+
to load it. Both are now force-added, and the ignore rules are anchored (`/*.png`, `/*.meta.json`) so
|
|
23
|
+
they can only ever catch files at the repo root. Also: `* cookies*.txt` (a pattern with a space, which
|
|
24
|
+
never matched anything) is gone, `__pycache__` is out of the npm tarball via a new `.npmignore`, and
|
|
25
|
+
`npm test` no longer requires the sibling `dsh-video-storyboard` checkout — it falls back to the
|
|
26
|
+
installed copy, so a clone can run the suite.
|
|
27
|
+
|
|
28
|
+
### Docs — one page per service, and the stale one is gone
|
|
29
|
+
|
|
30
|
+
`docs/WATCH.zh.md` still explained how to configure things around the **OS media session (SMTC)**,
|
|
31
|
+
which was deleted a while ago: wrong rationale, wrong `confidence` values, wrong defaults. Deleted.
|
|
32
|
+
Replaced by [`docs/CONFIG.zh.md`](docs/CONFIG.zh.md): ffmpeg → yt-dlp + cookies → subtitles/ASR →
|
|
33
|
+
browser extension (9377) → debug port (9333) → voice (`voice.json` + `tts.json`) → floating window →
|
|
34
|
+
cache locations → a one-page troubleshooting table. Every entry says **what breaks if you skip it**.
|
|
35
|
+
|
|
36
|
+
`README.md` got a 30-second start, a "what to configure" table, a corrected parameter table
|
|
37
|
+
(`depth` is auto-by-time now, `lookahead` was missing), a CLI table that matches the 15 real
|
|
38
|
+
subcommands, a privacy note for the extension, and a dev section. `docs/VOICE.zh.md` gained
|
|
39
|
+
`state: 'skipped'` and a correction: `at` is a **playback second**, not a wall-clock timestamp.
|
|
40
|
+
|
|
41
|
+
### `doctor` — three levels, because "not configured" is not "broken"
|
|
42
|
+
|
|
43
|
+
`FAIL` used to be printed for things that are merely "not set up yet": a missing cookie file (only
|
|
44
|
+
needed for Bilibili), a closed debug port (the extension is the recommended channel), an extension
|
|
45
|
+
that is loaded but has no video playing. First-run users read that as "something is broken" and went
|
|
46
|
+
to reinstall the extension. Now: **OK / WAIT / FAIL**, only `plugin` and `ffmpeg` are fatal, and when
|
|
47
|
+
the extension has checked in but nothing is playing, `doctor` says `READY — 播个视频就能读到位置`
|
|
48
|
+
instead of "both position channels are down".
|
|
49
|
+
|
|
50
|
+
### Performance — the chat watcher no longer re-reads the whole log every 150 ms
|
|
51
|
+
|
|
52
|
+
The blocking-wait loop polls `chat.jsonl` every 150 ms. Each poll re-read `readChat()` and parsed
|
|
53
|
+
every line, so a two-hour session (thousands of entries) was decoding hundreds of KB several times a
|
|
54
|
+
second, and getting slower the longer the session ran. `makeChatWatcher()` now keeps a byte offset
|
|
55
|
+
and reads **only what was appended since last time** (falling back to a full re-read if the file
|
|
56
|
+
shrank, i.e. it was cleared). Measured on a 5000-line log: **0.061 ms per poll, independent of file
|
|
57
|
+
size**. `appendChat()` also stopped parsing the whole log to keep `at` monotonic — it reads the last
|
|
58
|
+
4 KB instead.
|
|
59
|
+
|
|
60
|
+
### Tool description — pacing is now a rule the model can follow
|
|
61
|
+
|
|
62
|
+
`watch_together`'s description tells the model to keep lines **≥ 6 s apart** and why: speech is
|
|
63
|
+
serialized, so a denser draft is thinned at runtime (engine busy → next line held; past the late
|
|
64
|
+
grace → dropped). The three previous rounds of "台词太早 / 太密" all came from the model not knowing
|
|
65
|
+
this budget.
|
|
66
|
+
|
|
67
|
+
### Fixed — speech piled up in the engine queue, and an interjection could no longer break a blocked wait
|
|
68
|
+
|
|
69
|
+
Two reports in one message: "吐字太快,台词会挤到一起,只有上一句念完才到下一句,话太密会导致语音越来越
|
|
70
|
+
滞后" and "悬浮窗插话不能让他从等待中出来 —— 这个功能之前是好的".
|
|
71
|
+
|
|
72
|
+
**The voice queue.** `examples/voice-edge-tts` chains every `due` event onto an unbounded serial promise
|
|
73
|
+
("two lines never overlap"). Lines are now scheduled at the right second, so when they arrive faster
|
|
74
|
+
than the engine can speak them the chain simply grows: speech drifts further from the picture with
|
|
75
|
+
every line, and the caption (written on `spoken`) drifts with it.
|
|
76
|
+
|
|
77
|
+
- `src/watch-loop.js` — the clock now keeps a **voice budget**: after handing out a line it records
|
|
78
|
+
`voiceBusyUntil = now + speechSeconds(len)` and will not hand out the next one while the engine is
|
|
79
|
+
still talking. A line that misses its window by more than the late grace is dropped by `dueLine`
|
|
80
|
+
as usual: **speak one line less rather than one line later**.
|
|
81
|
+
- `src/speech.js` — `speechSeconds(chars)`: full spoken duration (`0.35 + chars/5`, 0.8–30 s).
|
|
82
|
+
`speechLag()` stays as it was — that one answers "when may I start talking", this one answers
|
|
83
|
+
"how long is the engine busy".
|
|
84
|
+
- `examples/voice-edge-tts` — safety net: if a queued line has been waiting more than 3.5 s it is
|
|
85
|
+
**abandoned** (logged) instead of spoken, and the queue empties immediately.
|
|
86
|
+
- `src/speech-bus.js` / `src/chat-store.js` — a fourth state, `skipped`: the adapter reports that it
|
|
87
|
+
gave up on a line, and `attachSpeechToChat` cancels the pending fallback timer for it. Without this
|
|
88
|
+
the 2.5 s fallback would paint a caption for a line that was never spoken.
|
|
89
|
+
|
|
90
|
+
**The interjection.** `chat.jsonl` is a **consuming** channel: `poll()` marks a message read. The
|
|
91
|
+
blocking wait and the watch loop share one watcher, and the loop's handler is `followup()` — which
|
|
92
|
+
cannot interrupt a session that is sitting inside a tool call (the message is only processed when
|
|
93
|
+
the turn ends). So whichever polled first decided the outcome, and the loop (every 2 s) sometimes
|
|
94
|
+
won: the interjection was swallowed, the wait's `poll()` never saw it, and the user's "stop, I have a
|
|
95
|
+
question" did nothing until the segment ended.
|
|
96
|
+
|
|
97
|
+
- `src/interrupt.js` — `enterChatWait()` / `chatWaiterCount()`: whoever is blocking on purpose
|
|
98
|
+
**owns** the channel. `raceChat()` (storyboard build, prefetch) registers too.
|
|
99
|
+
- `src/watch-loop.js` — `wakeOnChat` is skipped entirely while `chatWaiterCount() > 0`. The wake path
|
|
100
|
+
still works when the model is idle (no waiter), which is its whole purpose.
|
|
101
|
+
- `src/watch-run.js` (the `wait: true` loop), `src/watch-modes.js` (`waitUntil` / `waitForRefill` /
|
|
102
|
+
`nextLine`), `src/watch-source.js` (`waitForVideo`) — all register as waiters for the duration of
|
|
103
|
+
their loop.
|
|
104
|
+
|
|
105
|
+
Tests: `test/lines-timing.test.mjs` (engine busy → next line is not handed out; the overdue one is
|
|
106
|
+
dropped), `test/chat.test.mjs` (`skipped` writes nothing, not even the fallback),
|
|
107
|
+
`test/interject-anywhere.test.mjs` (the loop must not consume while a waiter is active; counter
|
|
108
|
+
cannot go negative).
|
|
109
|
+
|
|
110
|
+
### Fixed — scripted lines came out like a machine gun, and minutes before the picture
|
|
111
|
+
|
|
112
|
+
Reported as: "台词出现时间早了很多,而且和机关枪一样突突突一下出来一大堆,时间点都比视频早了".
|
|
113
|
+
|
|
114
|
+
The line queue is ordered by `at` (the second of the video this line is *for*) and fired by playback
|
|
115
|
+
position, so the pacing is only as good as the `at` values. When a line was written **without** `at`
|
|
116
|
+
(the model wrote prose only), `pinTimes()` decided when it would be said — and it took *the first N
|
|
117
|
+
subtitle sentence starts of the segment*. Sixteen lines written for a 3-minute segment were therefore
|
|
118
|
+
all packed into its first 62 seconds (181.6 → 244.2, measured on the live queue), i.e. one every
|
|
119
|
+
2–3 seconds: the clock ticks every 2 s and hands out at most one line per tick, which is exactly the
|
|
120
|
+
"machine gun". The last 14 of them ran one to two minutes ahead of the picture they describe.
|
|
121
|
+
|
|
122
|
+
- `src/watch-lines.js` `pinTimes()` — each line now aims at its **even share of the segment**
|
|
123
|
+
(`from + i*size/n`) and snaps to the nearest subtitle start within half a slot, so the queue is
|
|
124
|
+
spread over the whole segment instead of stacked at its head. Falls back to the even share when no
|
|
125
|
+
start is close enough, and **never goes backwards** (the old tail fallback could emit 152.8 → 150).
|
|
126
|
+
- `src/watch-lines.js` `dueLine()` — pinning uses **the segment that line belongs to** (`sizeOf`),
|
|
127
|
+
not the segment the user happens to be in. With the 1/2/3/4/5-minute ramp, a 60-second slot pinned
|
|
128
|
+
with a 300-second size put its last lines outside the segment entirely.
|
|
129
|
+
- `src/watch-lines.js` `saveLines()` — `at` given as **subtitle text** was resolved only against
|
|
130
|
+
`recallSegments()`, which is a 4-entry in-process cache (empty in a fresh process, and lines are
|
|
131
|
+
usually written in a different turn). A miss silently became "no `at`", i.e. the head of the
|
|
132
|
+
segment — the other half of "the line is way too early". Now it reads the on-disk
|
|
133
|
+
`subs-<key>.json` cache first, then falls back to memory, then to a fuzzy match (≥60 % of the
|
|
134
|
+
characters), and only then warns.
|
|
135
|
+
- `src/watch-run.js` — the delivery note pruned "past" lines with `Number(l.at)`, and
|
|
136
|
+
`Number(null) === 0`: **every line without `at` was judged as second 0 and deleted** at delivery.
|
|
137
|
+
The note now previews the same pinning the clock will use, so the reported "earliest …" time is the
|
|
138
|
+
real one, and only lines whose *actual* time has passed are dropped (by text).
|
|
139
|
+
- `src/watch-run.js` — the note now lists the landing times it will use (`[lines] 落点:…`) and warns
|
|
140
|
+
when the average gap is under 6 s, instead of leaving the model to guess its own pacing.
|
|
141
|
+
- `src/watch-loop.js` — with the extension as the position source, the anchor is now re-read **every
|
|
142
|
+
tick** (a small local JSON, not CDP). Between the 15-second probes the clock extrapolated blindly,
|
|
143
|
+
so after a pause the lines up to 15 s ahead were spoken **early** — extrapolation is bounded for
|
|
144
|
+
lateness but nothing guarded earliness.
|
|
145
|
+
- `src/latency.js` `aheadSeconds()` — returns 0 instead of `NaN` when `ms` is missing. `NaN` made
|
|
146
|
+
`pos` `NaN`, every comparison false, and `shouldSpeak()` reported "due" for the first unspoken
|
|
147
|
+
segment at every tick.
|
|
148
|
+
|
|
149
|
+
Tests: `test/pin-times.test.mjs` (the 16-line packing regression, monotonic fallback, cues bunched at
|
|
150
|
+
the head), `test/watch-lines.test.mjs` (per-segment size, `at` from the on-disk subtitle cache),
|
|
151
|
+
`test/lines-timing.test.mjs` (a stuck video must not speak the next line early).
|
|
152
|
+
|
|
153
|
+
### Fixed — the caption appeared before the voice, because it waited on `due` instead of "actually speaking"
|
|
154
|
+
|
|
155
|
+
`attachSpeechToChat` wrote a line into `chat.jsonl` the moment `due` fired. But `due` only means
|
|
156
|
+
"it is time to say this": synthesis still has to happen (edge-tts does a network round trip, then a
|
|
157
|
+
fresh `ffplay` process — 0.6–2 s even for a short sentence). The floating window polls that file, so
|
|
158
|
+
the text was already on screen a beat before anything was heard.
|
|
159
|
+
|
|
160
|
+
Delaying the voice instead (`speechLag`) would align the two, but push the voice further from the
|
|
161
|
+
picture, which is the one thing this plugin cannot trade away. So the **caption** moves:
|
|
162
|
+
|
|
163
|
+
- `src/speech-bus.js` — a third state, `spoken`, plus `emitSpoken(event)` for engines to report
|
|
164
|
+
"audio is starting now". The adapter API gains `emitSpoken`.
|
|
165
|
+
- `src/chat-store.js` — writes on `spoken` when a `voice: true` subscriber exists; still writes on
|
|
166
|
+
`due` when nobody will speak (the zero-dependency path must not go mute); falls back after
|
|
167
|
+
`fallbackMs` (2.5 s, `DSH_WATCH_CAPTION_FALLBACK_MS`) for adapters that never report.
|
|
168
|
+
Pairing is by `at|text`, not by `seq` — `spoken` is a **new** event, so `emitSpeech` gives it a
|
|
169
|
+
new sequence number.
|
|
170
|
+
- `examples/voice-edge-tts` — reports `spoken` right before playback starts (i.e. after synthesis).
|
|
171
|
+
- `examples/floating-chat/window.py` — polls every 200 ms instead of 400 ms; the poll interval is
|
|
172
|
+
the residual "text lags the voice" gap.
|
|
173
|
+
|
|
174
|
+
`test/chat.test.mjs` covers both new paths (waits for `spoken`; falls back when nobody reports, and
|
|
175
|
+
does not write twice if `spoken` arrives afterwards).
|
|
176
|
+
|
|
177
|
+
### Fixed — scripted lines never reached the chat window without a voice engine
|
|
178
|
+
|
|
179
|
+
`watch-loop.js` consumed the due line inside `if (speechSubscribers() > 0)`. That helper counts only
|
|
180
|
+
`voice: true` subscribers (real engines), while `attachSpeechToChat` — the one that writes lines into
|
|
181
|
+
`chat.jsonl`, which is exactly what the floating window reads — subscribes with `voice: false`.
|
|
182
|
+
So with no voice adapter, or one that failed to load, a scripted line was **never taken from the
|
|
183
|
+
queue at all**: not spoken, not displayed, and the queue silently accumulated.
|
|
184
|
+
|
|
185
|
+
Display and speaking are two separate things. The line is now handed out at its due moment
|
|
186
|
+
regardless: `emitSpeech` delivers it to every subscriber, and only a real `voice: true` subscriber
|
|
187
|
+
counts as "said" (`if (speechSubscribers() > 0) return;` still stops the wake, so nothing changes
|
|
188
|
+
when a voice engine *is* attached).
|
|
189
|
+
|
|
190
|
+
`test/lines-to-chat.test.mjs` covers both sides. The test was checked against the bug: restoring the
|
|
191
|
+
old condition makes the no-voice case fail while the with-voice case still passes.
|
|
192
|
+
|
|
193
|
+
### Changed — `say` no longer reads as "only to answer an interjection"
|
|
194
|
+
|
|
195
|
+
It always worked at any moment: it writes the sentence into the shared stream and hands it to
|
|
196
|
+
whoever listens for speech, exactly like a scripted line. But the description ended with
|
|
197
|
+
"use it to answer an interjection", which reads as "only after the user speaks". A model follows
|
|
198
|
+
that literally, so the one path for saying something **unprompted** went unused.
|
|
199
|
+
|
|
200
|
+
The description now says any time, and says it explicitly: something in the picture strikes you,
|
|
201
|
+
the user asks something, a thought lands while waiting for the next batch — plus
|
|
202
|
+
"do not wait for the user to speak first". It also states the cost, because that is what makes it
|
|
203
|
+
usable mid-wait: no position read, no frame built, no batch advanced, one round trip.
|
|
204
|
+
|
|
205
|
+
`test/say.test.mjs` pins the wiring — parameter → stream (one `assistant` row with `say: true`) →
|
|
206
|
+
speech event with `origin: 'chat'`, no image, no state advanced. The store layer was already covered
|
|
207
|
+
by `test/chat.test.mjs`; the uncovered part was the parameter entry itself.
|
|
208
|
+
|
|
209
|
+
### Added — an end-to-end test for "talk while the frame is building"
|
|
210
|
+
|
|
211
|
+
The mechanism already existed (`raceChat(buildSegment(...))` in `runWatchPass`), and
|
|
212
|
+
`test/interrupt.test.mjs` covered `raceChat` itself — but the `built.kind === 'interrupted'`
|
|
213
|
+
branch had **no** coverage. If a refactor ever dropped the wrapper, or `chatWatcherShared()` got
|
|
214
|
+
replaced with a fresh watcher per call, every existing test would still pass.
|
|
215
|
+
|
|
216
|
+
`test/interject-build.test.mjs` builds a segment that takes 1.2 s, writes a user message at 0.2 s,
|
|
217
|
+
and asserts all four things at once: the call returns before the build finishes, it carries that
|
|
218
|
+
exact message, it carries no image, and the build still completes into the cache afterwards.
|
|
219
|
+
|
|
220
|
+
### Changed — three implicit couplings now have exactly one source each
|
|
221
|
+
|
|
222
|
+
A pass over the module boundaries. Same behaviour except the `lead` fix at the end, which was a
|
|
223
|
+
real bug: the parameter only worked on one of the three paths that used it.
|
|
224
|
+
|
|
225
|
+
- **`handler.js` stopped preparing UI.** The floating window, the chat service and the "where do I
|
|
226
|
+
type" note moved to `input-surface.js` (`createInputSurface()`). `handler` is a router again —
|
|
227
|
+
three exits: quick action, one pass, start the loop. The `widgetNote` variable no longer travels
|
|
228
|
+
from the top of the function to the bottom.
|
|
229
|
+
- **`watch-run.js` has one return shape.** Eleven exits each used to build their own ten-field
|
|
230
|
+
object; now they all call one `pass()` closure. Adding a field is one edit instead of eleven, and
|
|
231
|
+
a branch can no longer quietly forget one.
|
|
232
|
+
- **One segment length.** `watch-state.js` exported `WATCH_SEGMENT = 120` while `batches.js`
|
|
233
|
+
declared `DEFAULT_SEGMENT = 300`; whichever fallback fired first decided how long a segment was.
|
|
234
|
+
`batches.js` is now the only source, and `WATCH_SEGMENT` is gone.
|
|
235
|
+
- **One lead.** The delivery lead was hardcoded in three places: `batches.from()` produced
|
|
236
|
+
`sayAt = to - 15`, `watch-loop.js` passed `lead: 15` to `shouldSpeak`, and only `watch-run.js`
|
|
237
|
+
actually read `args.lead`. Segments no longer carry `sayAt`; `shouldSpeak` computes `to - lead`,
|
|
238
|
+
and `startWatchLoop` takes `lead` from the caller. `lead: 60` now really moves the trigger point
|
|
239
|
+
(checked against a 300 s segment: at 241 s, `lead=15` stays quiet, `lead=60` fires).
|
|
240
|
+
|
|
241
|
+
### Removed — no more auto-launched browsers, no more browser widget
|
|
242
|
+
|
|
243
|
+
Both were early paths from before the browser extension existed. Neither could produce a position
|
|
244
|
+
for the tab the user is actually watching, so both are gone rather than kept as fallbacks.
|
|
245
|
+
|
|
246
|
+
- **Auto-launching a browser**: `ensureWatchBrowser()` (`launchBrowser` + `waitForPort`), the
|
|
247
|
+
`autoLaunch` flag on `runWatchPass`, the `attachOnly` parameter, and the `launchBrowser: true`
|
|
248
|
+
branch in `~/.dsh/video.json`. The extension already reports `currentTime` every second from the
|
|
249
|
+
page the user is on; opening a second Edge with its own profile never helped that page. When no
|
|
250
|
+
position can be read the tool now asks "how far are you" instead of starting a program.
|
|
251
|
+
- **The browser widget page**: `GET /widget`, `WIDGET_PAGE`, `openWidgetInBrowser()`, `widgetUrl()`,
|
|
252
|
+
and the `documentPictureInPicture` button in the chat page. The input box is the native tkinter
|
|
253
|
+
window (`examples/floating-chat/window.py`); the HTML page stays as a read-only fallback at `/`
|
|
254
|
+
(`chatPageUrl()`), and is never opened automatically.
|
|
255
|
+
- **Dead parameters**: `wakeOnLinesEmpty` (the handler never passed it, so its 30-line branch in
|
|
256
|
+
`watch-loop.js` could never run), `title` (nothing in `src/` or in storyboard read it), and
|
|
257
|
+
`segmentStart()` (every caller uses `plan.segmentAt()`). Parameter count 36 → 34.
|
|
258
|
+
|
|
259
|
+
### Fixed — interjections used to get swallowed (four different ways)
|
|
260
|
+
|
|
261
|
+
The interjection path was the one place where losing user input was silent: nothing crashed, nothing
|
|
262
|
+
logged, the words just never arrived. All four ways of losing them are now closed, and each one has
|
|
263
|
+
a regression test (`test/cli-interrupt.test.mjs` — the CLI had **no** test coverage before this).
|
|
264
|
+
|
|
265
|
+
- **Between two `cue` runs.** Every `cue` is a fresh process, and the watcher took "however many
|
|
266
|
+
lines exist right now" as its baseline — so anything the user typed while the model was thinking,
|
|
267
|
+
building a segment or replying was never read by anyone. The read position now lives in
|
|
268
|
+
`<watch>/chat-cursor.json`: a `cue` starts from where the last one stopped, and delivers what it
|
|
269
|
+
finds the moment it enters the wait. Baseline is persisted as soon as it is established, because a
|
|
270
|
+
`cue` that hears nothing (the common case) otherwise leaves no cursor for the next one.
|
|
271
|
+
- **Two messages arriving in the same poll.** Both watchers (chat box and host session file) marked
|
|
272
|
+
the whole batch as read and reported only the first, so the second was gone. They now consume up
|
|
273
|
+
to the message they hand over and no further — "reply first, then take the next one".
|
|
274
|
+
- **Wrong conversation.** `findActiveSessionFile()` took the most recently modified session jsonl
|
|
275
|
+
across *all* projects, so a chat in another window could interrupt the watch session. It now
|
|
276
|
+
prefers the project matching the current directory and only falls back to global when that one has
|
|
277
|
+
no active session.
|
|
278
|
+
- **The host writing old messages late.** WorkBuddy flushes a user's message into the session file
|
|
279
|
+
*after* the reply to it. The watcher saw new bytes and treated them as a fresh interjection —
|
|
280
|
+
interrupting the current turn with the message that started it. Messages whose `timestamp`
|
|
281
|
+
predates the watcher are now ignored.
|
|
282
|
+
|
|
283
|
+
Also in this path: interjections heard via the host input box are appended to the chat stream too
|
|
284
|
+
(they used to appear only in `cue`'s stdout, so the page showed a stream with a hole in it); the
|
|
285
|
+
chat page puts the words back in the input box when a send fails instead of losing them; and
|
|
286
|
+
`POST /api/say` answers `ok:false` for requests it did not write, which is what makes that recovery
|
|
287
|
+
possible.
|
|
288
|
+
|
|
289
|
+
### Fixed — `cue` and `say`
|
|
290
|
+
|
|
291
|
+
- `cue` no longer waits forever when the video changes underneath it. It compared against the
|
|
292
|
+
segment delivery point of the *old* video, and if the new one was shorter, `deliverAt` was a
|
|
293
|
+
position that would never be reached. It now detects a changed URL or duration and exits with
|
|
294
|
+
`VIDEO-CHANGED` (pending lines are saved under the old source), and exits with `REWIND` when the
|
|
295
|
+
user drags the progress bar back more than a minute — the model should hear about that instead of
|
|
296
|
+
sitting on lines written for a position the user left.
|
|
297
|
+
- Two `cue` processes can no longer run at once: a state file saying `blocking` with a **live** pid
|
|
298
|
+
is refused with `BUSY` (exit 1). A dead pid is taken for what it is — the residue of a killed run —
|
|
299
|
+
and does not block anything. `check` mode is read-only and never takes the lock.
|
|
300
|
+
- `check` mode no longer leaves `cue-state.json` at `blocking`, which used to make the next run
|
|
301
|
+
report "last wait was killed externally" for a run that was never waiting.
|
|
302
|
+
- `say` called edge-tts once by hand and then again inside `speak()` (twice the synthesis, and the
|
|
303
|
+
manual attempt passed the raw configured voice, so a SAPI-style name like `Huihui` never matched
|
|
304
|
+
and silently fell back). It now calls `speak()` once, which does the mapping and the fallback.
|
|
305
|
+
- `voices` was advertised in `help` and crashed with `cmdVoices is not defined` when called. It now
|
|
306
|
+
lists the SAPI voices plus whether edge-tts is present and which voice is configured — the first
|
|
307
|
+
place to look when "why am I still hearing the navigation lady" comes up.
|
|
308
|
+
|
|
309
|
+
### Added — talk instead of type: a microphone button in the floating window
|
|
310
|
+
|
|
311
|
+
`examples/floating-chat/mic.py` is a separate process the window starts from its `麦` button. It
|
|
312
|
+
listens, cuts what you say into utterances with the Silero VAD already sitting in `models-sherpa/`,
|
|
313
|
+
transcribes each one, and writes it into the **same** `chat.jsonl` the typing path uses — so a
|
|
314
|
+
running `cue` picks it up through the interjection cursor and the model answers without anyone
|
|
315
|
+
typing a character. Measured end to end on this machine (i9-12900HX, int8 paraformer):
|
|
316
|
+
|
|
317
|
+
- one model instance ≈ **284 MB** working set, loads in ~2 s
|
|
318
|
+
- a 3 s utterance transcribes in **0.15 s**; a 45 s one in ~1.2–3.3 s (RTF ≈ 0.05, 20× realtime)
|
|
319
|
+
- concurrent transcription barely queues: a 3 s short request takes 0.14 s even while a 45 s
|
|
320
|
+
transcription is running
|
|
321
|
+
|
|
322
|
+
**It runs its own model by default** (`--engine local`), which is the answer to "can ASR run twice":
|
|
323
|
+
yes, and it is cheap. It also means the microphone never waits behind a video transcription. The
|
|
324
|
+
existing service cannot offer that yet — see the note below. `--engine http` shares port 8000
|
|
325
|
+
instead, saving 284 MB at the cost of queuing behind long audio.
|
|
326
|
+
|
|
327
|
+
**It refuses to hear itself.** The agent speaks through speakers; the microphone hears it; without a
|
|
328
|
+
guard that gets transcribed as if the user had said it, and the model answers its own line forever.
|
|
329
|
+
Every utterance is checked against `quiet-until.json` (the same window `say` and `cue` already take
|
|
330
|
+
before speaking) and dropped if the agent is talking.
|
|
331
|
+
|
|
332
|
+
### Added — acoustic echo cancellation, so the microphone hears you and not the computer
|
|
333
|
+
|
|
334
|
+
`examples/floating-chat/aec.py`: the microphone picks up whatever the speakers are playing, which
|
|
335
|
+
means the video's narration gets transcribed as if you had said it. Since neither `speexdsp` nor
|
|
336
|
+
`webrtc-audio-processing` builds on this machine (no C compiler, no wheels), this is a frequency-domain
|
|
337
|
+
adaptive filter (overlap-save FDAF, power-normalised NLMS) in numpy — one FFT per 32 ms frame.
|
|
338
|
+
|
|
339
|
+
It captures the **loopback** channel (what the computer is playing, auto-detected as the
|
|
340
|
+
speaker/loopback device, never "stereo mix" — that one can contain the microphone too) and subtracts
|
|
341
|
+
the estimated echo from the microphone. On top of that, an utterance whose energy drops below
|
|
342
|
+
`--echo-gate` (default 30 %) after cancellation is discarded outright: that is the hard guarantee
|
|
343
|
+
that pure-echo segments are never transcribed, whatever the filter is doing.
|
|
344
|
+
|
|
345
|
+
Two things that mattered more than the filter itself:
|
|
346
|
+
|
|
347
|
+
- **Double-talk detection cannot compare against the echo estimate.** At startup the filter is zero,
|
|
348
|
+
so the estimate is zero, so "mic > 2 × estimate" is always true, so the filter freezes and never
|
|
349
|
+
converges (first version: 498 frames frozen, 0 dB). It now compares against the **reference**
|
|
350
|
+
signal (Geigel-style), which does not depend on the filter's state.
|
|
351
|
+
- **Measured on a synthetic but honest mixture** (real speech as the video, a different real speech
|
|
352
|
+
segment as you, through a 150 ms-delayed reverberant echo path):
|
|
353
|
+
ERLE **13.6 dB** during echo-only passage; the video's words in the transcript went from **25 % →
|
|
354
|
+
0 %**, and an 8 s passage with nothing but video audio produced **no transcription at all**.
|
|
355
|
+
|
|
356
|
+
Tunables: `--dt-ratio` (1.4 — mic peak vs reference peak before the filter freezes), `--taps`
|
|
357
|
+
(8192 ≈ 512 ms of reverb tail), `--echo-gate`, `--no-aec`, `--loopback`.
|
|
358
|
+
|
|
359
|
+
Honest limits: it is a software AEC, not magic. The first second or two of your speech, right as the
|
|
360
|
+
filter re-converges after you start talking, is where the damage shows (a few characters in the test
|
|
361
|
+
above). Speaker loudness and room reverb both make it harder. **Headphones remove the problem
|
|
362
|
+
entirely** — with headphones there is no echo to cancel, and everything above is unnecessary.
|
|
363
|
+
|
|
364
|
+
### Added — a browser extension, so you never open a special window again
|
|
365
|
+
|
|
366
|
+
Position used to require a browser started with `--remote-debugging-port`, and Chromium 136+ refuses
|
|
367
|
+
that flag on the default profile — so users had to keep a second, separate browser window open just
|
|
368
|
+
for watching. That was the whole reason this package felt like it needed a "special browser".
|
|
369
|
+
|
|
370
|
+
`extension/` is an MV3 extension that reads `<video>.currentTime` from the page you are actually
|
|
371
|
+
watching and POSTs it to the plugin's own localhost server (`127.0.0.1:9377/api/position`). After a
|
|
372
|
+
one-time install it works in **your normal browser**, with your bookmarks and your logins.
|
|
373
|
+
|
|
374
|
+
- `src/position-bridge.js` — the receiving end: writes each report to
|
|
375
|
+
`<cache>/position.json` (temp file + atomic rename) and treats anything older than 5 s as absent.
|
|
376
|
+
It goes through a file rather than memory because the CLI is a **different process** and has to
|
|
377
|
+
be able to read it too.
|
|
378
|
+
- `POST /api/position` and `GET /api/position` on the existing chat server, with CORS and a
|
|
379
|
+
Private-Network-Access opt-in (a page on https://bilibili.com talking to 127.0.0.1 needs both).
|
|
380
|
+
- `readPositionOrNull()` now tries the extension report when CDP is not configured or returns
|
|
381
|
+
nothing, so every existing call site gets the new channel for free.
|
|
382
|
+
- `doctor` grew an `extension` row and now treats "either channel works" as ready instead of
|
|
383
|
+
insisting on the debug port.
|
|
384
|
+
- `docs/BRIDGE.zh.md` — step-by-step install guide written for someone who has never heard of a
|
|
385
|
+
manifest file, including the eight failure modes people actually hit.
|
|
386
|
+
- `node watch.mjs install-extension` (and `scripts/install-extension.cmd`) does everything that
|
|
387
|
+
*can* be automated: copies the extension to `%LOCALAPPDATA%\\dsh-watch-together\\extension` so it
|
|
388
|
+
survives moving the repo, puts that path on the clipboard, and opens `edge://extensions`.
|
|
389
|
+
The last three clicks cannot be automated — Chrome 137 removed `--load-extension` from branded
|
|
390
|
+
builds and extension installs are HMAC-protected, deliberately, because silent install is the
|
|
391
|
+
malware channel. The guide says so plainly instead of pretending otherwise.
|
|
392
|
+
- **The extension now says hello on load** (`POST /api/hello`, persisted as `extension.json`).
|
|
393
|
+
Without it, "extension not installed" and "installed but no video playing" look identical from the
|
|
394
|
+
outside — both are silence. `doctor` and `bridge` can now tell them apart.
|
|
395
|
+
- `extension/welcome.html` opens on install/update: the three verification steps, plus what each
|
|
396
|
+
popup state means. Install is the one moment the user has no idea what to expect.
|
|
397
|
+
- `install-extension` no longer just prints and quits: it keeps the window open and **watches until
|
|
398
|
+
the extension proves it is loaded** (`✓ 扩展装上了`), then until a real position arrives
|
|
399
|
+
(`✅ 全部完成`). One double-click now covers install *and* verification, and the window cannot
|
|
400
|
+
vanish mid-instruction because it is still polling.
|
|
401
|
+
- `node watch.mjs install-extension --steps` re-prints just the three clicks without touching any
|
|
402
|
+
file — for when the window scrolled past or was closed.
|
|
403
|
+
- `install-extension` now waits for Enter when it has a TTY, so the instructions cannot vanish
|
|
404
|
+
before being read (running it from an IDE "Run" button has no TTY, which is the common way this
|
|
405
|
+
happened).
|
|
406
|
+
- `ensureWatchBrowser(port, url)` now passes the film through: with `launchBrowser: true`, saying
|
|
407
|
+
"陪我看这个 <link>" opens the dedicated window **at that link** instead of the Bilibili homepage.
|
|
408
|
+
That is the zero-install path — no extension, no port config, at the cost of watching in that
|
|
409
|
+
window. Both paths coexist; neither requires the other.
|
|
410
|
+
- `node watch.mjs bridge` (and `scripts/bridge.cmd`) starts just the position receiver and says
|
|
411
|
+
"✓ 收到上报" on the first report. Without it, a user who installs the extension and immediately
|
|
412
|
+
looks at the popup sees "not connected" — because the server only runs during `watch_together`
|
|
413
|
+
or `watch.mjs chat`, and concludes the install failed.
|
|
414
|
+
|
|
415
|
+
### Added — closing the remaining "no one is listening" dead ends
|
|
416
|
+
|
|
417
|
+
- **Idle stop now wakes the model too.** Video-ended and video-changed already did; idle ("no movement
|
|
418
|
+
for two segments") did not — and since the loop is stopped, nothing polls the chat box afterwards,
|
|
419
|
+
so anything the user said next went nowhere. Now it wakes and says where it stopped.
|
|
420
|
+
- **Waiting is polled, not slept through.** The 500 ms tick in the blocking wait now uses
|
|
421
|
+
`sleepWithChat`, so a message is noticed within ~150 ms instead of up to 500 ms later.
|
|
422
|
+
- **The tool description now tells the model what an interruption is:** a result carrying `chat` means
|
|
423
|
+
"answer them first, then call again with the same arguments — the wait resumes, nothing is lost, and
|
|
424
|
+
the image is already in the cache". Without this the model had no way to know.
|
|
425
|
+
- **`doctor` distinguishes "nobody is receiving" from "extension not connected".** Both look like
|
|
426
|
+
silence, and the old wording told the user to reinstall the extension — but if no server is running
|
|
427
|
+
on 9377 the extension cannot report at all, and reinstalling would have changed nothing.
|
|
428
|
+
- Stale SMTC-era wording removed from the strings the *model* reads (`input`/`cursor`/`title`
|
|
429
|
+
descriptions, and the `browser:` line), which still talked about the OS media session.
|
|
430
|
+
|
|
431
|
+
### Added — you can interrupt almost any wait, and it picks up where it left off
|
|
432
|
+
|
|
433
|
+
Every blocking wait in `watch_together` can now be interrupted by a message in the chat box, and in
|
|
434
|
+
all cases the answer is "reply to them, then call again with the same arguments" — the tool resumes:
|
|
435
|
+
|
|
436
|
+
- **Building a segment** (8–10 s, longer with ASR) and **filling the lookahead buffer** (up to 4
|
|
437
|
+
segments serially, 30 s+) — the most pointless kind of waiting, now interruptible.
|
|
438
|
+
- **Waiting for the video to appear** (`waitForVideo`, up to 2 min).
|
|
439
|
+
- **Waiting for a condition** (`waitUntil`) and **waiting for the next line** (`nextLine`).
|
|
440
|
+
- Waiting to the delivery point and `cue` already listened; they now share one watcher (below).
|
|
441
|
+
|
|
442
|
+
The interrupted work is **not cancelled**: the storyboard keeps building in the background and lands
|
|
443
|
+
in the cache, so the follow-up call returns it immediately instead of rebuilding it.
|
|
444
|
+
|
|
445
|
+
New `src/interrupt.js`:
|
|
446
|
+
- `raceChat(promise)` — polls the chat while a slow promise runs; returns `interrupted` with the
|
|
447
|
+
message, or `done`. Wakes on whichever happens first (the promise settling, or the next poll tick).
|
|
448
|
+
The first version slept a fixed 500 ms per tick, which added half a second to *every* build —
|
|
449
|
+
enough that playback passed the delivery point and the blocking wait returned instantly.
|
|
450
|
+
- `sleepWithChat(ms)` — sleep that can be cut short by a message.
|
|
451
|
+
- `chatWatcherShared()` — **one watcher for the whole process.** `makeChatWatcher()` baselines at
|
|
452
|
+
creation time, so a fresh one per wait silently dropped anything the user said while the model was
|
|
453
|
+
thinking, in the gap between two waits.
|
|
454
|
+
|
|
455
|
+
### Added — it now reacts to what you do mid-video
|
|
456
|
+
|
|
457
|
+
Auditing the whole flow against the user's checklist surfaced three gaps where the plugin behaved
|
|
458
|
+
correctly but **never told the model**, leaving it silent until the user poked it:
|
|
459
|
+
|
|
460
|
+
- **Video ended / video changed now wake the model once.** Previously they only stopped the loop, so
|
|
461
|
+
the model sat blocked on the previous segment with no idea the film was over or had been replaced.
|
|
462
|
+
- **Large seeks (>60 s, forward or backward) wake the model once** with where the user jumped to and
|
|
463
|
+
from, with a 3-minute cooldown. Position tracking was already correct — it was the model that had
|
|
464
|
+
no idea. Rewatching does not re-speak already-spoken segments (no immediate-repeat chatter).
|
|
465
|
+
- **Only the visible tab reports** (`document.visibilityState`), plus a report on `visibilitychange`.
|
|
466
|
+
Every tab with a `<video>` reports once per second; with two such tabs open the server received
|
|
467
|
+
alternating positions and the plugin interpreted it as the user scrubbing wildly.
|
|
468
|
+
- The simulator can now jump the playhead (`seeks: [{at, to}]`), and there are four new scenario
|
|
469
|
+
tests covering: video changed wakes once, video ended wakes once, seek forward wakes once, rewatch
|
|
470
|
+
wakes once and does not re-speak.
|
|
471
|
+
|
|
472
|
+
Note the jump check must run **before** the anchor is refreshed — comparing the new reading against
|
|
473
|
+
the already-updated anchor measures zero. That was the first (failed) version.
|
|
474
|
+
|
|
475
|
+
### Fixed
|
|
476
|
+
|
|
477
|
+
- **`bin/watch.mjs chat` ran its own copy of the chat server** — an inline `http.createServer` plus
|
|
478
|
+
duplicated copies of both HTML templates (92 lines). The copies had drifted: it served `/`,
|
|
479
|
+
`/widget`, `/api/messages`, `/api/say` but **not `/api/position` or `/api/hello`**. So running
|
|
480
|
+
only `watch.mjs chat` (instead of `bridge`) meant extension reports hit 404 and the CLI path could
|
|
481
|
+
never read a position. It also never called `attachSpeechToChat()`, so that chat box showed user
|
|
482
|
+
messages but no script lines. It now uses `startChatServer()` + `attachSpeechToChat()` like the
|
|
483
|
+
plugin and `bridge` do, and the duplicated templates are deleted.
|
|
484
|
+
- **`watch.mjs reply` wrote straight to the stream** with `appendChat('assistant', …)`, so the text
|
|
485
|
+
appeared in the chat box but was never handed to speech subscribers — a TTS adapter stayed silent
|
|
486
|
+
while the page showed the words. It now uses `appendAssistantSay()`, which writes the stream *and*
|
|
487
|
+
emits the speech event, matching what `watch_together({say})` does.
|
|
488
|
+
|
|
489
|
+
### Fixed
|
|
490
|
+
|
|
491
|
+
- **The plugin passed the browser's debug port to `ensureChatSession()`**, so the chat server tried
|
|
492
|
+
to bind 9333 — the port the browser is already using. The bind failed, the error was swallowed,
|
|
493
|
+
and the chat box silently never came up in DSH. It now uses the chat port (9377) as intended.
|
|
494
|
+
This also mattered for the extension: that server is where reports land.
|
|
495
|
+
|
|
496
|
+
### Removed — the OS media session (SMTC) backend is gone
|
|
497
|
+
|
|
498
|
+
Position used to have two sources: the browser's DevTools port, and Windows' system media controls
|
|
499
|
+
(read by a bundled `watch_smtc.py`). **SMTC is deleted**, along with everything that only existed
|
|
500
|
+
because of it:
|
|
501
|
+
|
|
502
|
+
- `src/watch-probe.js` (121 lines) and `src/watch_smtc.py` (62 lines)
|
|
503
|
+
- `src/resolve-playing.js` (153 lines) — it reversed a *title* into a source by searching filenames
|
|
504
|
+
and then Bilibili. With CDP the page URL is the source, so this whole "guess the film" path is
|
|
505
|
+
gone (it was also the thing most likely to pick the wrong video)
|
|
506
|
+
- the `winrt` Python dependency (three packages) and the interpreter search
|
|
507
|
+
- most of the extrapolation policy in `position.js`: the cap drops 180 s → 60 s, `FRESH_MS`
|
|
508
|
+
becomes 5 s, and the safety margin now only applies after a *missed* read
|
|
509
|
+
- `pickSession` / `probePlayback` / `describeStatus` and the `probe` injection point
|
|
510
|
+
|
|
511
|
+
Rationale: SMTC's `Position` only refreshes on player events (measured gaps of 143 s and 216 s), so
|
|
512
|
+
treating it as a live position required extrapolating, and extrapolating over a wrong pause means
|
|
513
|
+
every later segment is built on a wrong cursor. The benefit — "watch in whatever player you like" —
|
|
514
|
+
did not survive contact with how it actually behaved.
|
|
515
|
+
|
|
516
|
+
What you give up: you now watch inside the dedicated browser window
|
|
517
|
+
(`scripts/start-edge-debug.cmd`). Chromium 136+ refuses to open a DevTools port on the default
|
|
518
|
+
profile, so that window necessarily has its own profile and needs a one-time login.
|
|
519
|
+
|
|
520
|
+
### Fixed
|
|
521
|
+
|
|
522
|
+
- **`loop.built` / `loop.dur` / `loop.sourceUrl` leaked across films.** Starting a second watch
|
|
523
|
+
session reused the previous film's duration, so the first read of the new film looked like a
|
|
524
|
+
"video changed" event and stopped the loop immediately; `built` made prefetch skip segments it had
|
|
525
|
+
built for the old film. Both are now reset when the source changes.
|
|
526
|
+
- **`startWatchLoop` used `Date.now()` for the anchor while pricing time off its injected clock**,
|
|
527
|
+
which made every simulated read look minutes old. It now uses the injected clock.
|
|
528
|
+
- **The CLI's `pos()` never read SMTC at all**, so the CLI was browser-only even while the plugin
|
|
529
|
+
had a fallback. Moot now that SMTC is gone, but it is why the tool seemed to demand a special
|
|
530
|
+
browser.
|
|
531
|
+
|
|
532
|
+
### Removed — dead code trimmed so there is one decision path
|
|
533
|
+
|
|
534
|
+
Two functions that duplicated live logic and were never called in production are gone:
|
|
535
|
+
|
|
536
|
+
- `dueDecision` (in `src/timer.js`) — a pure "should I speak now" decision that shadowed
|
|
537
|
+
`position.shouldSpeak`. Nothing in the loop ever called it; only a test exercised the abandoned
|
|
538
|
+
design. The "pause too long → stop" intent it carried is now not implemented (see note below).
|
|
539
|
+
- `depthForBuffer` (in `src/batches.js`) — a count-based lookahead that duplicated `windowFor`,
|
|
540
|
+
which the loop actually uses (position-based, so the invariant holds at every position, not just
|
|
541
|
+
at segment starts). Its tests were redundant guards of that same invariant.
|
|
542
|
+
|
|
543
|
+
Net: 13 tests removed (8 for `dueDecision`, 5 for `depthForBuffer`); `windowFor`'s existing tests
|
|
544
|
+
already cover "lookahead ≥ N seconds at every position", so no coverage was lost.
|
|
545
|
+
|
|
546
|
+
### Changed — idle auto-stop now also covers a paused-and-abandoned video
|
|
547
|
+
|
|
548
|
+
The loop used to only stop itself on "no movement" when the last reading was a *playing* sample
|
|
549
|
+
(`why === 'recent-refresh'`). A paused video reports a frozen position forever — `estimate` returns
|
|
550
|
+
`why: 'paused'`, never stale — so pausing and walking away left the loop polling indefinitely. The
|
|
551
|
+
idle check now also fires on a frozen *paused* position, after the same `2 × segment` grace period,
|
|
552
|
+
and wakes you with "停了一会儿" so you can resume by calling `watch_together` again.
|
|
553
|
+
|
|
554
|
+
### Fixed — voice adapter no longer hard-codes a voice
|
|
555
|
+
|
|
556
|
+
`examples/voice-edge-tts/index.mjs` used to fall back to `zh-CN-XiaoxuanNeural` when
|
|
557
|
+
`~/.dsh/tts.json` had no `voice`. That baked one person's voice into the example, so shipping it
|
|
558
|
+
would have dragged that choice into everyone's install. It now falls back to the neutral
|
|
559
|
+
`zh-CN-YunxiNeural` and prints a one-line hint telling you to set `voice` in `~/.dsh/tts.json`
|
|
560
|
+
(e.g. `"voice": "zh-CN-XiaoxuanNeural"`). Nothing about the voice ships in the package — you mount
|
|
561
|
+
the adapter via `~/.dsh/voice.json` (or `DSH_VOICE_ADAPTER`) and pick the voice yourself.
|
|
562
|
+
|
|
563
|
+
## Earlier — 0.1.0 draft, never published (2026-10-30)
|
|
564
|
+
|
|
565
|
+
The first cut as a standalone plugin. It was not published under this number; the version line now
|
|
566
|
+
starts at 0.0.7, so this section is kept purely as a record of how the feature set got here. The feature existed inside `dsh-video-storyboard` 0.4.x as
|
|
567
|
+
`src/watch/`; it is now its own package with its own entry point, its own version, and a one-way
|
|
568
|
+
dependency on `dsh-video-storyboard`.
|
|
569
|
+
|
|
570
|
+
### Added
|
|
571
|
+
|
|
572
|
+
- **`watch_together`** — watch a video together with a text-only agent. Instead of one whole-film
|
|
573
|
+
storyboard, it follows the user's **real playback position** and hands over one segment at a time,
|
|
574
|
+
`lead` seconds before the segment ends. The next segment is built while the user is still watching
|
|
575
|
+
the current one, so delivery is perceived as instant (4/4 measured deliveries at 0.0 s).
|
|
576
|
+
- **Ramp-up start.** Segment lengths grow `[60, 120, 180, 240]` → `segment`, so the first line lands
|
|
577
|
+
around 45 s instead of after a full 5-minute batch. `ramp: []` disables the ladder.
|
|
578
|
+
- **Double buffering.** `depth: 2` keeps the current batch plus the next one built, and starts the
|
|
579
|
+
one after that while the user watches.
|
|
580
|
+
- **Playback position straight from the page.** It reads `<video>.currentTime` over the DevTools
|
|
581
|
+
protocol, so the value is exact, and the page URL becomes the source (`file:///D:/x.mp4` → local
|
|
582
|
+
path) — no searching, no downloading, no asking. Never released with the OS media session (SMTC)
|
|
583
|
+
backend documented below: SMTC's `Position` only refreshes on events, so using it as a live
|
|
584
|
+
position meant extrapolating, and a wrong position poisons every later segment.
|
|
585
|
+
- **Honest confidence levels.** The plugin reads every 15 s and extrapolates in between, which is
|
|
586
|
+
normal and self-correcting. What it refuses to do is keep extrapolating after it has *missed* a
|
|
587
|
+
read: past 20 s it demands an extra 5 s of margin before speaking, and past 60 s it stops
|
|
588
|
+
guessing and asks for `cursor` instead.
|
|
589
|
+
- **The speech seam, with no engine.** `src/speech-bus.js` exposes `onSpeech(handler, { voice })`,
|
|
590
|
+
`emitSpeech()`, `speechEvents()` and `lastSpeech()`. The plugin ships no engine, no default
|
|
591
|
+
adapter and no voice parameters; `watch_together` results carry `speech: [{ at, text, state }]`
|
|
592
|
+
and the loop emits `state: 'due'` when a line is actually due.
|
|
593
|
+
- **Adapters loaded by path.** `~/.dsh/voice.json` `{ "adapter": "<path or module>" }` (or
|
|
594
|
+
`DSH_VOICE_ADAPTER`) is `import()`ed once at startup; the module exports `attach(api)` and returns
|
|
595
|
+
a detach. Nothing is bundled, and a failure only logs a warning.
|
|
596
|
+
- **`examples/voice-edge-tts/`** — a working adapter (edge-tts → `ffplay` → system-voice fallback).
|
|
597
|
+
It prints `[voice 03:11.4] <line>` to stderr for every line that comes due; that log, not the
|
|
598
|
+
audio, is what you want when checking *when* text fires.
|
|
599
|
+
- **One text stream for the chat box.** `chat.jsonl` carries `line` (scripted), `assistant`
|
|
600
|
+
(interjection) and `user`, with `say: true` marking the speakable ones.
|
|
601
|
+
`watch_together({ say: "…" })` is how the model gets its interjection in — the plugin cannot read a
|
|
602
|
+
normal reply. `attachSpeechToChat()` subscribes with `voice: false`, so a display-only consumer can
|
|
603
|
+
never silence the loop.
|
|
604
|
+
- **A localhost chat page** (`/` full view, `/widget` capsule) with an `/api/messages` long-poll and
|
|
605
|
+
an `/api/say` callback. This is the only channel that actually reaches a blocked `watch_together`
|
|
606
|
+
call — messages typed into the host's own input box are appended to the session log *after* the
|
|
607
|
+
blocking call returns (measured: 42 s of polling, 0 bytes written).
|
|
608
|
+
- **`examples/floating-chat/window.py`** — a real floating window without a browser: frameless,
|
|
609
|
+
always-on-top, translucent, stdlib tkinter only. Reads the same `chat.jsonl`.
|
|
610
|
+
- **`bin/watch.mjs`** — a CLI shell for sessions that have no `watch_together` tool. It imports the
|
|
611
|
+
same `src/`, so behaviour cannot drift from the plugin.
|
|
612
|
+
|
|
613
|
+
### Fixed
|
|
614
|
+
|
|
615
|
+
- **The CLI imported pre-refactor paths** (`src/browser-time.js`, `src/pipeline.js`, …) that no
|
|
616
|
+
longer exist, so `bin/watch.mjs` could not even start. All imports now resolve through the
|
|
617
|
+
`dsh-video-storyboard` package name.
|
|
618
|
+
|
|
619
|
+
### Changed
|
|
620
|
+
|
|
621
|
+
- `detachAdapters()` no longer reaches into the bus's private subscriber map; it calls
|
|
622
|
+
`__resetSpeech()` from `speech-bus.js`.
|
|
623
|
+
- `watch-run.js` imported `./watch.js` twice; merged into one import.
|
|
624
|
+
|
|
625
|
+
### Known limits
|
|
626
|
+
|
|
627
|
+
- **Speaker separation is not attempted.** Measured on the reference machine: per-sentence cam++
|
|
628
|
+
embeddings split single-speaker material into 6 speakers; demucs pre-separation made no difference
|
|
629
|
+
(median similarity 0.62 → 0.61); FunASR's `ClusterBackend` returns "one speaker" outright below 20
|
|
630
|
+
speech segments — short clips are outside its operating range by design.
|
|
631
|
+
- **Interjection audio can collide with a line already being spoken.** Windows mixes both SAPI
|
|
632
|
+
instances, so `say` occupies `quiet-until.json` before speaking and `cue` skips lines inside that
|
|
633
|
+
window (it skips rather than defers — deferring desynchronises from the picture). The remaining
|
|
634
|
+
gap is the 3–8 s while a line is mid-speech, which cannot be cut short.
|
|
635
|
+
- **CRLF-less assumption.** The chat page replaces `__PORT__` in the templates per start; changing
|
|
636
|
+
the port while a browser tab is already open requires a reload.
|