dsh-watch-together 0.2.11 → 0.2.13
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 +156 -0
- package/README.md +41 -5
- package/docs/VOICE.zh.md +93 -1
- package/dsh.plugin.json +12 -12
- package/examples/floating-chat/glass_capture.py +362 -286
- package/examples/floating-chat/glass_geometry.py +31 -8
- package/examples/floating-chat/glass_gpu.py +1 -1
- package/examples/floating-chat/window.py +1387 -1210
- package/examples/floating-chat/window_widgets.py +28 -5
- package/examples/voice-edge-tts/index.mjs +142 -9
- package/examples/voice-edge-tts/stream/client.mjs +159 -0
- package/examples/voice-edge-tts/stream/daemon.py +524 -0
- package/examples/voice-edge-tts/stream/warm.mp3 +0 -0
- package/package.json +118 -115
- package/scripts/check-multimonitor.py +102 -0
- package/src/companion-api.js +88 -0
- package/src/playhead.js +75 -0
- package/src/public-api.js +7 -0
- package/src/voice-adapter.js +8 -1
- package/src/voice.js +9 -0
- package/src/watch-loop.js +38 -6
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"""
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
|
+
import os
|
|
16
17
|
from dataclasses import dataclass, field, replace
|
|
17
18
|
from typing import Iterable
|
|
18
19
|
|
|
@@ -34,6 +35,13 @@ SLAB_OUT, SLAB_TOP_H, SLAB_BOT_H = 12, 54, 70
|
|
|
34
35
|
SLAB_GAP = 10
|
|
35
36
|
SLAB_RADIUS = 22
|
|
36
37
|
|
|
38
|
+
# 气泡底板:文字底下是实时视频,对比度每秒都在变;给每块气泡铺一层深色,
|
|
39
|
+
# 文字的对比度就只由这层决定,不再跟着画面走。alpha 0.50(128/255)——
|
|
40
|
+
# 白字压在纯白画面上也能到 4.2:1,达到正文可读的下限;再低(0.40)只有 2.9:1。
|
|
41
|
+
# `DSH_GLASS_PLATE=0` 关掉(只用于新旧对比截图,正常别用)。
|
|
42
|
+
PLATE = os.environ.get("DSH_GLASS_PLATE", "1") != "0"
|
|
43
|
+
BUBBLE_PLATE = (7, 17, 29, 128) if PLATE else (0, 0, 0, 0)
|
|
44
|
+
|
|
37
45
|
# 抓屏时向外扩一圈,边缘透镜才有「框外」的像素可采
|
|
38
46
|
PAD = 40
|
|
39
47
|
BAND = 64 # 全分辨率下的透镜带宽度
|
|
@@ -101,15 +109,24 @@ def _rounded_mask(w: int, h: int, boxes: Iterable[Box]) -> Image.Image:
|
|
|
101
109
|
return m.resize((w, h), Image.Resampling.LANCZOS)
|
|
102
110
|
|
|
103
111
|
|
|
104
|
-
def _overlay(w: int, h: int, shapes: tuple[Box, ...]) -> Image.Image:
|
|
105
|
-
"""
|
|
112
|
+
def _overlay(w: int, h: int, shapes: tuple[Box, ...], plate: bool = True) -> Image.Image:
|
|
113
|
+
"""内部框的染色。气泡铺底板(文字靠它稳住对比度),其余仍是极淡的冷色。
|
|
114
|
+
|
|
115
|
+
`plate=False` 用于没有消息的空态:那四个槽位只是占位,铺深色反而像四个空洞。
|
|
116
|
+
"""
|
|
106
117
|
layer = Image.new("RGBA", (w, h), (0, 0, 0, 0))
|
|
107
118
|
d = ImageDraw.Draw(layer)
|
|
108
119
|
tints = ((235, 242, 255, 5), (110, 175, 255, 14), (235, 242, 255, 4),
|
|
109
120
|
(235, 242, 255, 4), (235, 242, 255, 5), (110, 175, 255, 12))
|
|
110
|
-
for (x0, y0, x1, y1, r), fill in zip(shapes, tints):
|
|
121
|
+
for i, ((x0, y0, x1, y1, r), fill) in enumerate(zip(shapes, tints)):
|
|
111
122
|
if x1 > x0 and y1 > y0:
|
|
112
|
-
|
|
123
|
+
if plate and PLATE and i < MESSAGE_SLOTS:
|
|
124
|
+
# 向外 1px:内框边缘有折射带,底板正好压在它上面,否则那圈
|
|
125
|
+
# 折射出来的背景色会变成一条彩色描边(亮背景上特别明显)
|
|
126
|
+
d.rounded_rectangle((x0 - 1, y0 - 1, x1 + 1, y1 + 1), radius=r + 1,
|
|
127
|
+
fill=BUBBLE_PLATE)
|
|
128
|
+
else:
|
|
129
|
+
d.rounded_rectangle((x0, y0, x1, y1), radius=r, fill=fill)
|
|
113
130
|
return layer
|
|
114
131
|
|
|
115
132
|
|
|
@@ -199,6 +216,7 @@ class Geometry:
|
|
|
199
216
|
shapes: tuple[Box, ...] = ()
|
|
200
217
|
overlay: Image.Image | None = None
|
|
201
218
|
overlay_half: Image.Image | None = None
|
|
219
|
+
plate: bool = False # 当前 overlay 有没有气泡底板(空态为 False)
|
|
202
220
|
box_maps: tuple[tuple, ...] = ()
|
|
203
221
|
box_union_half: Image.Image | None = None
|
|
204
222
|
_mic_pos: tuple[int, int] = field(default=(0, 0), repr=False)
|
|
@@ -217,18 +235,23 @@ class Geometry:
|
|
|
217
235
|
slabs=slabs_for(w, h), mask_hard=mask_hard,
|
|
218
236
|
warp_x=warp_x, warp_y=warp_y,
|
|
219
237
|
_mic_pos=(MIC_MARGIN[0], h - MIC_MARGIN[1]))
|
|
220
|
-
return base.with_shapes(shapes, version=version)
|
|
238
|
+
return base.with_shapes(shapes, version=version, plate=False)
|
|
221
239
|
|
|
222
|
-
def with_shapes(self, shapes: Iterable[Box], version: int | None = None
|
|
240
|
+
def with_shapes(self, shapes: Iterable[Box], version: int | None = None,
|
|
241
|
+
plate: bool = True) -> "Geometry":
|
|
223
242
|
shapes = tuple(shapes)
|
|
224
|
-
overlay = _overlay(self.width, self.height, shapes)
|
|
243
|
+
overlay = _overlay(self.width, self.height, shapes, plate=plate)
|
|
225
244
|
hw, hh = max(1, self.width // 2), max(1, self.height // 2)
|
|
245
|
+
# GPU 只按 (尺寸, version) 决定要不要重传纹理:形状没变、只多了底板时
|
|
246
|
+
# 也得换 version,否则会一直显示空态那张 overlay。
|
|
247
|
+
bump = version is None or plate != self.plate
|
|
226
248
|
return replace(
|
|
227
249
|
self,
|
|
228
|
-
version=(self.version + 1) if
|
|
250
|
+
version=(self.version + 1) if bump else self.version,
|
|
229
251
|
shapes=shapes,
|
|
230
252
|
overlay=overlay,
|
|
231
253
|
overlay_half=overlay.resize((hw, hh), Image.Resampling.BILINEAR),
|
|
254
|
+
plate=plate,
|
|
232
255
|
box_maps=_box_maps(shapes, self.width, self.height),
|
|
233
256
|
box_union_half=_box_union(self.width, self.height, hw, hh, shapes),
|
|
234
257
|
)
|
|
@@ -380,7 +380,7 @@ class GpuRenderer:
|
|
|
380
380
|
return None
|
|
381
381
|
gw, gh = shot.shot.size
|
|
382
382
|
raw = np.frombuffer(shot.shot.bgra, dtype=np.uint8).reshape(gh, gw, 4)
|
|
383
|
-
if source.cappable:
|
|
383
|
+
if source.cappable and not source.solid:
|
|
384
384
|
# 录屏模式下必须挖掉自己,否则背景里永远有本窗口 → moved 恒真 →
|
|
385
385
|
# 静态跳帧一次都不触发,还会自我反馈出拖尾。CPU 路径在
|
|
386
386
|
# CaptureSource.to_image() 里做,GPU 直接吃 bgra,得在这里补上。
|