@eslaykey/dsh-breeze-tts 1.0.1 → 1.0.3

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,13 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), version
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.0.3] - 2026-10-31
9
+
10
+ ### Fixed
11
+ - 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
12
+ - Auto-speak could fire while the reply was still being generated; it now waits until the text has been stable for a few seconds
13
+
14
+
8
15
  ## [1.0.1] - 2026-10-30
9
16
 
10
17
  ### 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
@@ -13,6 +13,7 @@ window.__ModuleLoader__.load({
13
13
  tone: { normal: '自然', warm: '温和', formal: '正式', lively: '活泼' },
14
14
 
15
15
  err: {
16
+ server: 'Breeze 服务端暂时不可用或响应超时,请稍后重试',
16
17
  auth: 'API key 无效或已失效,请重新填写',
17
18
  rate: '请求太频繁,稍等几秒再试',
18
19
  credits: '积分余额不足,请先充值或调低每日上限',
@@ -116,6 +117,7 @@ window.__ModuleLoader__.load({
116
117
  tone: { normal: 'Natural', warm: 'Warm', formal: 'Formal', lively: 'Lively' },
117
118
 
118
119
  err: {
120
+ server: 'The Breeze service is unavailable or timed out. Try again in a moment.',
119
121
  auth: 'The API key is invalid or expired. Please enter it again.',
120
122
  rate: 'Too many requests. Wait a few seconds and retry.',
121
123
  credits: 'Not enough credits. Top up or lower the daily limit.',
@@ -274,6 +276,7 @@ window.__ModuleLoader__.load({
274
276
  if (status === 401 || code === 'AUTH_REQUIRED') return t('err.auth')
275
277
  if (status === 429) return t('err.rate')
276
278
  if (status === 402 || /credit/i.test(code) || /insufficient/i.test(message)) return t('err.credits')
279
+ if (status >= 500 || /50[234]/.test(message)) return t('err.server')
277
280
  if (/at least 3 characters/i.test(message)) return t('err.tooShort')
278
281
  if (/daily limit/i.test(message)) return t('err.daily')
279
282
  return message
@@ -477,9 +480,9 @@ function stripEmoji(text) {
477
480
  return out
478
481
  }
479
482
 
480
- function cleanForSpeech(text) {
483
+ function cleanForSpeech(text, keepTags) {
481
484
  let value = String(text ?? '')
482
- value = value.replace(/<!--[\s\S]*?-->/g, ' ')
485
+ if (!keepTags) value = value.replace(/<!--[\s\S]*?-->/g, ' ')
483
486
  value = value.replace(/!\[[^\]]*\]\([^)]*\)/g, ' ')
484
487
  value = value.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
485
488
  value = value.replace(/https?:\/\/[^\s)]+/g, ' ')
@@ -512,7 +515,7 @@ function cleanForSpeech(text) {
512
515
  if (!target) return ""
513
516
  const message = target.message && typeof target.message === "object" ? target.message : target
514
517
  const direct = textBlocks(message.content, [])
515
- if (direct.length) return cleanForSpeech(direct.join(String.fromCharCode(10)))
518
+ if (direct.length) return cleanForSpeech(direct.join(String.fromCharCode(10)), true)
516
519
  const typed = collectText(message, [], 0).join(String.fromCharCode(10)).trim()
517
520
  if (typed) return typed
518
521
  return collectAnyText(message, [], 0).join(String.fromCharCode(10)).trim()
@@ -590,6 +593,7 @@ function cleanForSpeech(text) {
590
593
  }
591
594
  const primed = React.useRef(false)
592
595
  const debounce = React.useRef(null)
596
+ const pendingRef = React.useRef(null)
593
597
  const focused = React.useRef(true)
594
598
  const snapshot = typeof props.useChat === 'function'
595
599
  ? props.useChat((value) => (value && typeof value === 'object' ? value.legacy : undefined))
@@ -634,11 +638,12 @@ function cleanForSpeech(text) {
634
638
  }
635
639
 
636
640
  if (debounce.current) window.clearTimeout(debounce.current)
637
- debounce.current = window.setTimeout(evaluate, 600)
641
+ debounce.current = window.setTimeout(evaluate, 1000)
638
642
  return
639
643
 
640
644
  function evaluate() {
641
645
  let text = ''
646
+ let measure = ''
642
647
  let id = ''
643
648
  for (let index = nodes.length - 1; index >= 0; index -= 1) {
644
649
  const node = nodes[index]
@@ -653,14 +658,29 @@ function cleanForSpeech(text) {
653
658
  } catch {
654
659
  raw = ''
655
660
  }
656
- const cleaned = cleanForSpeech(raw)
657
- if (!cleaned) continue
658
- const recent = played.current.texts.get(cleaned.slice(0, 80))
661
+ const spokenText = cleanForSpeech(raw, true)
662
+ const plain = cleanForSpeech(raw)
663
+ if (!plain) continue
664
+ const recent = played.current.texts.get(plain.slice(0, 80))
659
665
  if (recent && Date.now() - recent < 60000) {
660
666
  markSpoken(candidateId, '')
661
667
  continue
662
668
  }
663
- text = cleaned
669
+ const pending = pendingRef.current
670
+ if (!pending || pending.id !== candidateId || pending.text !== spokenText) {
671
+ pendingRef.current = { id: candidateId, text: spokenText, at: Date.now() }
672
+ if (debounce.current) window.clearTimeout(debounce.current)
673
+ debounce.current = window.setTimeout(evaluate, 1200)
674
+ return
675
+ }
676
+ if (Date.now() - pending.at < 2500) {
677
+ if (debounce.current) window.clearTimeout(debounce.current)
678
+ debounce.current = window.setTimeout(evaluate, 1200)
679
+ return
680
+ }
681
+ pendingRef.current = null
682
+ text = spokenText
683
+ measure = plain
664
684
  id = candidateId
665
685
  break
666
686
  }
@@ -681,7 +701,7 @@ function cleanForSpeech(text) {
681
701
  const limit = Number((data && data.autoSpeakMaxChars) || 0)
682
702
  if (!data || !data.autoSpeak) return null
683
703
  if (limit <= 0) return null
684
- if (text.length > limit) return null
704
+ if (measure.length > limit) return null
685
705
  if (!data.backgroundPlay && !focused.current) return null
686
706
  return speakRemotely({ text }, { host: true })
687
707
  })
@@ -759,13 +779,15 @@ function cleanForSpeech(text) {
759
779
  setCustomMood(String(data.customMood || ''))
760
780
  }, [state.data])
761
781
 
782
+ const hasKey = Boolean(state.data && state.data.hasKey)
762
783
  React.useEffect(() => {
784
+ if (!hasKey) return undefined
763
785
  let alive = true
764
786
  api('/voices')
765
787
  .then((data) => { if (alive) setVoices(data.voices || []) })
766
788
  .catch(() => { if (alive) setVoices([]) })
767
789
  return () => { alive = false }
768
- }, [])
790
+ }, [hasKey])
769
791
 
770
792
  const data = state.data
771
793
  const presets = data && Array.isArray(data.voicePresets) ? data.voicePresets : []
@@ -794,6 +816,8 @@ function cleanForSpeech(text) {
794
816
  text: t('extra.keyConnected') + (typeof result.balance === 'number' ? ' · ' + result.balance.toFixed(1) + ' ' + t('status.credits') : ''),
795
817
  })
796
818
  reload()
819
+ const freshVoices = await api('/voices').catch(() => null)
820
+ if (freshVoices && Array.isArray(freshVoices.voices)) setVoices(freshVoices.voices)
797
821
  } catch (error) {
798
822
  setConnectNote({ tone: 'error', text: humanError(t, error) })
799
823
  }
package/index.js CHANGED
@@ -288,11 +288,16 @@ async function callApi(pathname, options = {}) {
288
288
  if (apiKey) headers['xi-api-key'] = apiKey
289
289
  const isForm = typeof FormData !== 'undefined' && body instanceof FormData
290
290
  if (body !== undefined && !isForm) headers['content-type'] = 'application/json'
291
- const response = await fetch(url, {
292
- method,
293
- headers,
294
- body: body === undefined ? undefined : isForm ? body : JSON.stringify(body),
295
- })
291
+ let response
292
+ for (let attempt = 0; attempt < 2; attempt += 1) {
293
+ response = await fetch(url, {
294
+ method,
295
+ headers,
296
+ body: body === undefined ? undefined : isForm ? body : JSON.stringify(body),
297
+ })
298
+ if (response.ok || ![502, 503, 504].includes(response.status)) break
299
+ if (attempt === 0) await new Promise((resolve) => setTimeout(resolve, 1500))
300
+ }
296
301
  if (!response.ok) {
297
302
  const text = await response.text()
298
303
  const parsed = parseJson(text) ?? {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslaykey/dsh-breeze-tts",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
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
  }