dsh-folia 4.26.0-pre.21 → 4.26.0-pre.22

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.
@@ -131,8 +131,19 @@ export function createVoiceRecorder(deps) {
131
131
  const audioPath = join(dir, 'input.wav');
132
132
  const startedAt = Date.now();
133
133
  let result = null;
134
+ let usedPlain = false;
134
135
  try {
135
- result = await runFfmpeg(await resolveFfmpeg(null), [...dshowArgs(device, opts), audioPath], opts.maxMs + 8000);
136
+ const ff = await resolveFfmpeg(null);
137
+ result = await runFfmpeg(ff, [...dshowArgs(device, opts), audioPath], opts.maxMs + 8000);
138
+ // 兜底:某些环境(实测 dsh web / Electron 主进程)里 ffmpeg 不接受 -af silencedetect,
139
+ // 会立刻非零退出。这时退化成"固定时长采集":宁可少一点智能,也不能录不到。
140
+ if (result && result.code !== 0) {
141
+ const args = dshowArgs(device, opts);
142
+ const cut = args.indexOf('-af');
143
+ const plain = cut >= 0 ? args.slice(0, cut).concat(args.slice(cut + 2)) : args;
144
+ const retry = await runFfmpeg(ff, [...plain, audioPath], opts.maxMs + 8000);
145
+ if (retry && retry.code === 0) { result = retry; usedPlain = true; }
146
+ }
136
147
  } catch {
137
148
  rmSync(dir, { recursive: true, force: true });
138
149
  lastCode = 'ffmpeg-missing';
@@ -146,7 +157,9 @@ export function createVoiceRecorder(deps) {
146
157
  lastCode = 'no-device';
147
158
  continue;
148
159
  }
149
- const ended = detectSpeechEnd(stderr);
160
+ let ended = detectSpeechEnd(stderr);
161
+ // 固定时长兜底采集里没有 silencedetect 标记 ⇒ 直接按 maxMs 当语音段,别误判成 no-speech
162
+ if (!ended && usedPlain) ended = { speechEnd: opts.maxMs / 1000 };
150
163
  if (!ended) {
151
164
  rmSync(dir, { recursive: true, force: true });
152
165
  lastCode = 'no-speech';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "4.26.0-pre.21",
3
+ "version": "4.26.0-pre.22",
4
4
  "description": "DSH 壁纸引擎:本机 WE 壁纸实时渲染,视频/网页/开机动画/桌宠皮肤,一键拉取在线素材。",
5
5
  "type": "module",
6
6
  "engines": {