@eslaykey/dsh-breeze-tts 1.0.2 → 1.0.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
@@ -5,6 +5,20 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), version
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.0.4] - 2026-10-31
9
+
10
+ ### Fixed
11
+ - Emotion tags were mangled by the text cleaner before synthesis, so auto-speak spoke the tag fragments instead of applying them
12
+ - A 260 ms breath is now inserted between synthesized segments, so tone changes no longer sound clipped together
13
+
14
+
15
+ ## [1.0.3] - 2026-10-31
16
+
17
+ ### Fixed
18
+ - Auto-speak dropped emotion tags before synthesis, so tagged replies lost their per-segment tone; the per-message button was unaffected because it used a different text path
19
+ - Auto-speak could fire while the reply was still being generated; it now waits until the text has been stable for a few seconds
20
+
21
+
8
22
  ## [1.0.1] - 2026-10-30
9
23
 
10
24
  ### Added
package/README.md CHANGED
@@ -4,13 +4,25 @@
4
4
 
5
5
  ## 安装
6
6
 
7
- 装进当前 profile,然后重启 DSH:
8
-
9
7
  ```bash
10
- dsh plugin --profile <profile> add <package-name>
8
+ dsh plugin --profile desktop add @eslaykey/dsh-breeze-tts
9
+ ```
10
+
11
+ 如果提示 `dsh : 无法将“dsh”项识别为 cmdlet…`,说明 CLI 不在 PATH 上。DSH 桌面版自带的 CLI 在:
12
+
13
+ ```
14
+ D:\ds\resources\runtime\cli\bin\dsh.cmd
15
+ ```
16
+
17
+ 两条路任选:把 `D:\ds\resources\runtime\cli\bin` 加进用户 PATH(加完重开终端),或者直接用完整路径:
18
+
19
+ ```powershell
20
+ & "D:\ds\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add @eslaykey/dsh-breeze-tts
11
21
  ```
12
22
 
13
- 首次使用需要在设置里填 Breeze 的 API key(`brz_` 开头),获取地址:<https://breezeblue.ai/app/developer/api-keys>。
23
+ 装完**重启 DSH**。然后进「设置 → 语音朗读」,在顶部填入 Breeze 的 API key(`brz_` 开头)点「连接」,成功会显示当前余额。
24
+
25
+ API key 在这里申请:<https://breezeblue.ai/app/developer/api-keys>
14
26
 
15
27
  ## 能做什么
16
28
 
@@ -78,7 +90,21 @@ allowBuilds:
78
90
 
79
91
  **合成返回 401 / 403**
80
92
 
81
- API key 无效或已过期。到 <https://breezeblue.ai/app/developer/api-keys> 重新生成,写进 `~/.dsh/breeze.json` 的 `apiKey`。
93
+ API key 无效或已过期。到 <https://breezeblue.ai/app/developer/api-keys> 重新生成,回到设置页重新「连接」,或者直接写进 `~/.dsh/breeze.json` 的 `apiKey`。
94
+
95
+ **合成返回 502 / 503 / 504**
96
+
97
+ 这是 Breeze 服务端的问题,不是本机故障:网关在时限内没等到源站响应。插件会自动重试一次;仍然失败就稍后再试。余额和音色列表这类免费接口此时通常仍然可用,所以「余额正常但试听报错」不代表 key 有问题。
98
+
99
+ ## 开发
100
+
101
+ ```bash
102
+ git clone <this repo>
103
+ cd dsh-breeze-tts
104
+ dsh plugin --profile desktop add . # 以链接方式装进 profile,改完重启生效
105
+ ```
106
+
107
+ 改 Host 代码必须重启 DSH;改 Client 代码同样要重启(DSH 桌面版没有页面刷新)。
82
108
 
83
109
  ## License
84
110
 
package/client.js CHANGED
@@ -480,9 +480,17 @@ function stripEmoji(text) {
480
480
  return out
481
481
  }
482
482
 
483
- function cleanForSpeech(text) {
483
+ function cleanForSpeech(text, keepTags) {
484
484
  let value = String(text ?? '')
485
- value = value.replace(/<!--[\s\S]*?-->/g, ' ')
485
+ const tags = []
486
+ if (keepTags) {
487
+ value = value.replace(/<!--[\s\S]*?-->/g, (match) => {
488
+ tags.push(match)
489
+ return '@@TAG' + (tags.length - 1) + '@@'
490
+ })
491
+ } else {
492
+ value = value.replace(/<!--[\s\S]*?-->/g, ' ')
493
+ }
486
494
  value = value.replace(/!\[[^\]]*\]\([^)]*\)/g, ' ')
487
495
  value = value.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
488
496
  value = value.replace(/https?:\/\/[^\s)]+/g, ' ')
@@ -492,6 +500,9 @@ function cleanForSpeech(text) {
492
500
  value = value.replace(/\s+([:,。!?;、)】」》])/g, '$1')
493
501
  value = value.replace(/([(【「《])\s+/g, '$1')
494
502
  value = value.replace(/\s+/g, ' ')
503
+ if (keepTags && tags.length) {
504
+ value = value.replace(/@@TAG(\d+)@@/g, (match, index) => tags[Number(index)] || ' ')
505
+ }
495
506
  return value.trim()
496
507
  }
497
508
 
@@ -515,7 +526,7 @@ function cleanForSpeech(text) {
515
526
  if (!target) return ""
516
527
  const message = target.message && typeof target.message === "object" ? target.message : target
517
528
  const direct = textBlocks(message.content, [])
518
- if (direct.length) return cleanForSpeech(direct.join(String.fromCharCode(10)))
529
+ if (direct.length) return cleanForSpeech(direct.join(String.fromCharCode(10)), true)
519
530
  const typed = collectText(message, [], 0).join(String.fromCharCode(10)).trim()
520
531
  if (typed) return typed
521
532
  return collectAnyText(message, [], 0).join(String.fromCharCode(10)).trim()
@@ -593,6 +604,7 @@ function cleanForSpeech(text) {
593
604
  }
594
605
  const primed = React.useRef(false)
595
606
  const debounce = React.useRef(null)
607
+ const pendingRef = React.useRef(null)
596
608
  const focused = React.useRef(true)
597
609
  const snapshot = typeof props.useChat === 'function'
598
610
  ? props.useChat((value) => (value && typeof value === 'object' ? value.legacy : undefined))
@@ -637,11 +649,12 @@ function cleanForSpeech(text) {
637
649
  }
638
650
 
639
651
  if (debounce.current) window.clearTimeout(debounce.current)
640
- debounce.current = window.setTimeout(evaluate, 600)
652
+ debounce.current = window.setTimeout(evaluate, 1000)
641
653
  return
642
654
 
643
655
  function evaluate() {
644
656
  let text = ''
657
+ let measure = ''
645
658
  let id = ''
646
659
  for (let index = nodes.length - 1; index >= 0; index -= 1) {
647
660
  const node = nodes[index]
@@ -656,14 +669,29 @@ function cleanForSpeech(text) {
656
669
  } catch {
657
670
  raw = ''
658
671
  }
659
- const cleaned = cleanForSpeech(raw)
660
- if (!cleaned) continue
661
- const recent = played.current.texts.get(cleaned.slice(0, 80))
672
+ const spokenText = cleanForSpeech(raw, true)
673
+ const plain = cleanForSpeech(raw)
674
+ if (!plain) continue
675
+ const recent = played.current.texts.get(plain.slice(0, 80))
662
676
  if (recent && Date.now() - recent < 60000) {
663
677
  markSpoken(candidateId, '')
664
678
  continue
665
679
  }
666
- text = cleaned
680
+ const pending = pendingRef.current
681
+ if (!pending || pending.id !== candidateId || pending.text !== spokenText) {
682
+ pendingRef.current = { id: candidateId, text: spokenText, at: Date.now() }
683
+ if (debounce.current) window.clearTimeout(debounce.current)
684
+ debounce.current = window.setTimeout(evaluate, 1200)
685
+ return
686
+ }
687
+ if (Date.now() - pending.at < 2500) {
688
+ if (debounce.current) window.clearTimeout(debounce.current)
689
+ debounce.current = window.setTimeout(evaluate, 1200)
690
+ return
691
+ }
692
+ pendingRef.current = null
693
+ text = spokenText
694
+ measure = plain
667
695
  id = candidateId
668
696
  break
669
697
  }
@@ -684,7 +712,7 @@ function cleanForSpeech(text) {
684
712
  const limit = Number((data && data.autoSpeakMaxChars) || 0)
685
713
  if (!data || !data.autoSpeak) return null
686
714
  if (limit <= 0) return null
687
- if (text.length > limit) return null
715
+ if (measure.length > limit) return null
688
716
  if (!data.backgroundPlay && !focused.current) return null
689
717
  return speakRemotely({ text }, { host: true })
690
718
  })
package/index.js CHANGED
@@ -245,9 +245,10 @@ function chunkByLanguage(text, limit = 900) {
245
245
  return chunks
246
246
  }
247
247
 
248
- function concatWav(buffers) {
248
+ function concatWav(buffers, gapMs = 260) {
249
249
  let fmt = null
250
250
  const frames = []
251
+ let gapBytes = 0
251
252
  for (const buffer of buffers) {
252
253
  if (buffer.toString('ascii', 0, 4) !== 'RIFF') throw new Error('not a wav payload')
253
254
  let pos = 12
@@ -264,7 +265,19 @@ function concatWav(buffers) {
264
265
  if (!fmt) fmt = localFmt
265
266
  else if (!fmt.equals(localFmt)) throw new Error('wav format mismatch')
266
267
  }
267
- const body = Buffer.concat(frames)
268
+ if (fmt && fmt.length >= 16 && frames.length > 1) {
269
+ const channels = fmt.readUInt16LE(2)
270
+ const sampleRate = fmt.readUInt32LE(4)
271
+ const bits = fmt.readUInt16LE(14)
272
+ const blockAlign = Math.max(1, Math.round((channels * bits) / 8))
273
+ gapBytes = Math.round((sampleRate * gapMs) / 1000) * blockAlign
274
+ }
275
+ const parts = []
276
+ for (let index = 0; index < frames.length; index += 1) {
277
+ parts.push(frames[index])
278
+ if (index < frames.length - 1 && gapBytes > 0) parts.push(Buffer.alloc(gapBytes))
279
+ }
280
+ const body = Buffer.concat(parts)
268
281
  const header = Buffer.alloc(12)
269
282
  header.write('RIFF', 0, 'ascii')
270
283
  header.writeUInt32LE(4 + (8 + fmt.length) + (8 + body.length), 4)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslaykey/dsh-breeze-tts",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Breeze Blue text-to-speech for DeepSeek Harness: agent tools, reply playback, voice design and a settings page.",
5
5
  "author": "eslaykey",
6
6
  "license": "MIT",
@@ -45,5 +45,13 @@
45
45
  "text-to-speech",
46
46
  "breeze",
47
47
  "voice"
48
- ]
48
+ ],
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/EslayKey/dsh-breeze-tts.git"
52
+ },
53
+ "homepage": "https://github.com/EslayKey/dsh-breeze-tts#readme",
54
+ "bugs": {
55
+ "url": "https://github.com/EslayKey/dsh-breeze-tts/issues"
56
+ }
49
57
  }