dsh-sixlayer-memory 2.5.3 → 2.5.4

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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # 变更记录 · dsh-sixlayer-memory(六层记忆底座)
2
2
 
3
+ ## 2.5.4 — 2026-12-05
4
+
5
+ 修「字幕条弹出来了但一个字都没有」,并把字幕条改成**透明**。
6
+
7
+ ### 修复
8
+
9
+ - **设备名为空 → ffmpeg 直接退出**:流式识别没做设备自动发现,`-i audio=` 让 ffmpeg 报
10
+ `Malformed dshow input string` 并立刻退出(日志里就是这个),于是只有字幕条、没有字。
11
+ 现在和整段识别一样,先 `-list_devices` 挑第一个麦克风;找不到就明确报"没有麦克风"。
12
+ - 采集进程异常退出时把 ffmpeg 的 stderr 带进 `reason`,不再静默失败。
13
+
14
+ ### 界面
15
+
16
+ - **字幕条改为全透明**:只有文字(白字 + 黑色投影),没有底板,压在游戏/网页上也不挡内容;
17
+ 字号 30、居中、底部往上 240px。
18
+
19
+ ### 回归
20
+
21
+ - 真机验证:4 秒采到 108800 字节音频(≈3.4 秒 16k 单声道),设备自动发现生效
22
+ - 全量 35 个套件全绿
23
+
24
+ ---
25
+
3
26
  ## 2.5.3 — 2026-12-05
4
27
 
5
28
  修「按热键一点声音都没有」:热键被上一次留下的孤儿进程占着。
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  dsh plugin --profile desktop add dsh-sixlayer-memory
12
12
  ```
13
13
 
14
- **当前版本**:2.5.3 · **35 个工具** · schema v9 · 零外部依赖 · 回归 35 个套件全绿
14
+ **当前版本**:2.5.4 · **35 个工具** · schema v9 · 零外部依赖 · 回归 35 个套件全绿
15
15
 
16
16
  📦 [npm](https://www.npmjs.com/package/dsh-sixlayer-memory) · 🎬 [40 秒介绍视频](media/intro-40s.mp4) · 📝 [变更记录](CHANGELOG.md)
17
17
 
@@ -1,5 +1,6 @@
1
- # overlay.ps1 -- always-on-top subtitle bar for streaming speech recognition.
2
- # Polls a UTF-8 text file and shows its content. Exit when the file disappears.
1
+ # overlay.ps1 -- always-on-top subtitle bar for streaming speech recognition.
2
+ # Transparent by design: only the text is visible, with a soft shadow so it stays
3
+ # readable over any background. Polls a UTF-8 text file; exits when it disappears.
3
4
  # Usage: powershell -STA -NoProfile -ExecutionPolicy Bypass -File overlay.ps1 -Path <file> -Title <text>
4
5
  param(
5
6
  [Parameter(Mandatory = $true)][string]$Path,
@@ -11,38 +12,52 @@ Add-Type -AssemblyName PresentationFramework
11
12
  Add-Type -AssemblyName PresentationCore
12
13
  Add-Type -AssemblyName WindowsBase
13
14
 
15
+ function Brush([string]$hex) {
16
+ return [System.Windows.Media.BrushConverter]::new().ConvertFromString($hex)
17
+ }
18
+
14
19
  $w = New-Object System.Windows.Window
15
20
  $w.WindowStyle = 'None'
16
21
  $w.AllowsTransparency = $true
17
- $w.Background = [System.Windows.Media.BrushConverter]::new().ConvertFromString('#E6141A22')
22
+ $w.Background = [System.Windows.Media.Brushes]::Transparent
18
23
  $w.Topmost = $true
19
24
  $w.ShowInTaskbar = $false
20
25
  $w.ResizeMode = 'NoResize'
21
- $w.Width = 940
22
- $w.Height = 96
23
- $screen = [System.Windows.SystemParameters]::PrimaryScreenWidth
24
- $w.Left = ($screen - 940) / 2
25
- $w.Top = [System.Windows.SystemParameters]::PrimaryScreenHeight - 220
26
-
27
- $border = New-Object System.Windows.Controls.Border
28
- $border.CornerRadius = [System.Windows.CornerRadius]::new(14)
29
- $border.Padding = [System.Windows.Thickness]::new(20, 10, 20, 10)
30
- $border.Background = [System.Windows.Media.BrushConverter]::new().ConvertFromString('#F21B2330')
26
+ $w.Width = 1000
27
+ $w.Height = 132
28
+ $w.Left = ([System.Windows.SystemParameters]::PrimaryScreenWidth - 1000) / 2
29
+ $w.Top = [System.Windows.SystemParameters]::PrimaryScreenHeight - 240
31
30
 
31
+ # 只有文字,没有底板;靠阴影保证任何背景上都看得清
32
32
  $stack = New-Object System.Windows.Controls.StackPanel
33
+ $stack.HorizontalAlignment = 'Center'
34
+ $stack.VerticalAlignment = 'Bottom'
35
+ $stack.Margin = [System.Windows.Thickness]::new(0, 0, 0, 6)
36
+
33
37
  $tip = New-Object System.Windows.Controls.TextBlock
34
38
  $tip.Text = $Title
35
39
  $tip.FontSize = 12
36
- $tip.Foreground = [System.Windows.Media.BrushConverter]::new().ConvertFromString('#88FFFFFF')
37
- $tip.Margin = [System.Windows.Thickness]::new(0, 0, 0, 4)
40
+ $tip.Foreground = Brush '#B3FFFFFF'
41
+ $tip.HorizontalAlignment = 'Center'
42
+ $tip.Margin = [System.Windows.Thickness]::new(0, 0, 0, 2)
43
+ $tipShadow = New-Object System.Windows.Media.Effects.DropShadowEffect
44
+ $tipShadow.Color = [System.Windows.Media.Colors]::Black
45
+ $tipShadow.BlurRadius = 4
46
+ $tipShadow.ShadowDepth = 0
47
+ $tipShadow.Opacity = 0.95
48
+ $tip.Effect = $tipShadow
49
+
38
50
  $tb = New-Object System.Windows.Controls.TextBlock
39
- $tb.FontSize = 24
51
+ $tb.FontSize = 30
52
+ $tb.FontWeight = 'SemiBold'
40
53
  $tb.TextWrapping = 'Wrap'
41
- $tb.Foreground = [System.Windows.Media.BrushConverter]::new().ConvertFromString('#FFFFFFFF')
54
+ $tb.TextAlignment = 'Center'
55
+ $tb.Foreground = Brush '#FFFFFFFF'
56
+ $tb.Effect = $tipShadow.Clone()
57
+
42
58
  $stack.Children.Add($tip) | Out-Null
43
59
  $stack.Children.Add($tb) | Out-Null
44
- $border.Child = $stack
45
- $w.Content = $border
60
+ $w.Content = $stack
46
61
 
47
62
  $timer = New-Object System.Windows.Threading.DispatcherTimer
48
63
  $timer.Interval = [TimeSpan]::FromMilliseconds(120)
@@ -15,6 +15,7 @@ import fs from 'node:fs'
15
15
  import path from 'node:path'
16
16
  import { createRequire } from 'node:module'
17
17
  import { fileURLToPath } from 'node:url'
18
+ import { listAudioDevices } from './asr.js'
18
19
 
19
20
  const require_ = createRequire(fileURLToPath(import.meta.url))
20
21
 
@@ -178,8 +179,19 @@ export class StreamRecognizer {
178
179
  this.stream = this.recognizer.createStream()
179
180
  this.text = ''
180
181
  this.startedAt = Date.now()
182
+ this.lastError = ''
181
183
 
182
- const args = ['-hide_banner', '-loglevel', 'error', '-f', 'dshow', '-i', `audio=${this.device}`, '-ac', '1', '-ar', '16000', '-f', 's16le', '-']
184
+ // 设备名不能空着:`-i audio=` 会让 ffmpeg 报 "Malformed dshow input string" 然后立刻退出,
185
+ // 表现就是"字幕条出来了但一个字都没有"。
186
+ let dev = this.device
187
+ if (!dev) {
188
+ const devices = await listAudioDevices({ ffmpegPath: this.ffmpegPath })
189
+ dev = devices[0] ?? ''
190
+ if (!dev) return { ok: false, reason: '没有找到麦克风设备' }
191
+ this.device = dev
192
+ }
193
+
194
+ const args = ['-hide_banner', '-loglevel', 'error', '-f', 'dshow', '-i', `audio=${dev}`, '-ac', '1', '-ar', '16000', '-f', 's16le', '-']
183
195
  let child
184
196
  try {
185
197
  child = spawn(this.ffmpegPath, args, { windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'] })
@@ -198,12 +210,17 @@ export class StreamRecognizer {
198
210
  this._feed(buf)
199
211
  }
200
212
  })
201
- child.stderr.on('data', (c) => this.log(String(c).trim().slice(0, 160)))
213
+ child.stderr.on('data', (c) => {
214
+ const msg = String(c).trim().slice(0, 160)
215
+ if (msg) this.lastError = msg
216
+ this.log(msg)
217
+ })
202
218
  child.on('exit', (code) => {
203
219
  if (this.child === child) this.child = null
220
+ if (code && !this.lastError) this.lastError = `麦克风采集退出(code=${code})`
204
221
  this.log(`ffmpeg 退出 code=${code}`)
205
222
  })
206
- return { ok: true }
223
+ return { ok: true, device: dev }
207
224
  }
208
225
 
209
226
  _feed(buf) {
@@ -229,7 +246,9 @@ export class StreamRecognizer {
229
246
  /** 停止并给出最终文本。 @returns {Promise<{ok:boolean, text:string, ms:number, reason?:string}>} */
230
247
  async stop() {
231
248
  const child = this.child
232
- if (!child) return { ok: false, text: '', ms: 0, reason: '没有在流式识别' }
249
+ if (!child) {
250
+ return { ok: false, text: this.text || '', ms: Date.now() - (this.startedAt || Date.now()), reason: this.lastError || '麦克风没有在采集(ffmpeg 已退出)' }
251
+ }
233
252
  this.child = null
234
253
  const ms = Date.now() - this.startedAt
235
254
  await new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sixlayer-memory",
3
- "version": "2.5.3",
3
+ "version": "2.5.4",
4
4
  "private": false,
5
5
  "description": "DSH 工作台:六层记忆底座(每轮自动召回 + 候选沉淀 + 闸门审计)+ 零件化,支持 QQ 随身使用。",
6
6
  "type": "module",