@eslaykey/dsh-breeze-tts 1.0.0 → 1.0.2
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 +28 -18
- package/client.js +99 -2
- package/index.js +35 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project are documented here.
|
|
4
|
-
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versioning follows [SemVer](https://semver.org/).
|
|
5
|
-
|
|
6
|
-
## [Unreleased]
|
|
7
|
-
|
|
8
|
-
## [1.0.
|
|
9
|
-
|
|
10
|
-
### Added
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versioning follows [SemVer](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [1.0.1] - 2026-10-30
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- API key binding directly in the settings page: paste a key, validate it against the account balance, and disconnect when needed
|
|
12
|
+
- Built-in tone names are localized (English UI shows Natural / Warm / Formal / Lively)
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Emotion tags were counted against the auto-speak character limit and could be spoken aloud
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [1.0.0] - 2026-10-30
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- Three agent tools: `tts_speak`, `tts_voices`, `tts_status`
|
|
22
|
+
- Settings page: voice, delivery preset, preview line, daily character limit, balance, usage bar
|
|
23
|
+
- One-click "read this reply" action on every finalized assistant message
|
|
24
|
+
- Auto-speak for replies within a configurable character limit (off by default)
|
|
25
|
+
- Voice design: generate three candidates from a text description, audition and save
|
|
26
|
+
- Sentence-level language detection so mixed Chinese/English text keeps the right accent
|
|
27
|
+
- Six built-in public voices across gender, age and accent
|
|
28
|
+
- Localized error messages with an API code map (auth, rate limit, credits, validation, daily quota)
|
package/client.js
CHANGED
|
@@ -10,7 +10,10 @@ window.__ModuleLoader__.load({
|
|
|
10
10
|
zh: {
|
|
11
11
|
meta: { title: 'Breeze 语音朗读', description: '用 Breeze Blue 把文字念出来。' },
|
|
12
12
|
section: { title: '语音朗读', subtitle: 'Breeze Blue · 文字转语音' },
|
|
13
|
+
tone: { normal: '自然', warm: '温和', formal: '正式', lively: '活泼' },
|
|
14
|
+
|
|
13
15
|
err: {
|
|
16
|
+
server: 'Breeze 服务端暂时不可用或响应超时,请稍后重试',
|
|
14
17
|
auth: 'API key 无效或已失效,请重新填写',
|
|
15
18
|
rate: '请求太频繁,稍等几秒再试',
|
|
16
19
|
credits: '积分余额不足,请先充值或调低每日上限',
|
|
@@ -31,6 +34,14 @@ window.__ModuleLoader__.load({
|
|
|
31
34
|
autoSpeakHint: '对字数不超过设定值的新回复自动朗读,默认关闭',
|
|
32
35
|
renameBlocked: '内置音色和公开音色不能重命名',
|
|
33
36
|
voiceManageHint: '只有你自己生成的音色可以在这里改名或删除',
|
|
37
|
+
apiKey: 'API Key',
|
|
38
|
+
keyBound: '已连接',
|
|
39
|
+
keyMissing: '尚未连接,填入 Breeze 的 API key 后点连接',
|
|
40
|
+
keyRequired: '请先填入 API key',
|
|
41
|
+
keyConnected: '连接成功',
|
|
42
|
+
keyDisconnected: '已断开',
|
|
43
|
+
connect: '连接',
|
|
44
|
+
disconnect: '断开',
|
|
34
45
|
cloneNotice: '本插件不提供音色克隆。需要克隆自己的声音,请到 Breeze 官网的音色库创建,克隆好的音色会自动出现在上面的列表里。',
|
|
35
46
|
renameVoice: '重命名',
|
|
36
47
|
renamePlaceholder: '新的音色名称',
|
|
@@ -103,7 +114,10 @@ window.__ModuleLoader__.load({
|
|
|
103
114
|
en: {
|
|
104
115
|
meta: { title: 'Breeze Voice', description: 'Read text aloud with Breeze Blue.' },
|
|
105
116
|
section: { title: 'Voice', subtitle: 'Breeze Blue · text to speech' },
|
|
117
|
+
tone: { normal: 'Natural', warm: 'Warm', formal: 'Formal', lively: 'Lively' },
|
|
118
|
+
|
|
106
119
|
err: {
|
|
120
|
+
server: 'The Breeze service is unavailable or timed out. Try again in a moment.',
|
|
107
121
|
auth: 'The API key is invalid or expired. Please enter it again.',
|
|
108
122
|
rate: 'Too many requests. Wait a few seconds and retry.',
|
|
109
123
|
credits: 'Not enough credits. Top up or lower the daily limit.',
|
|
@@ -120,6 +134,14 @@ window.__ModuleLoader__.load({
|
|
|
120
134
|
status: { ready: 'Ready', missingKey: 'Missing API key', credits: 'credits', chars: 'chars' },
|
|
121
135
|
hint: { key: 'Write the Breeze API key into apiKey of ~/.dsh/breeze.json.', limit: 'Synthesis is refused past the limit so credits cannot run away.' },
|
|
122
136
|
extra: {
|
|
137
|
+
apiKey: 'API key',
|
|
138
|
+
keyBound: 'Connected',
|
|
139
|
+
keyMissing: 'Not connected. Paste your Breeze API key and press Connect.',
|
|
140
|
+
keyRequired: 'Enter an API key first',
|
|
141
|
+
keyConnected: 'Connected',
|
|
142
|
+
keyDisconnected: 'Disconnected',
|
|
143
|
+
connect: 'Connect',
|
|
144
|
+
disconnect: 'Disconnect',
|
|
123
145
|
autoSpeak: 'Auto speak',
|
|
124
146
|
autoSpeakHint: 'Automatically read new replies within the configured character limit. Off by default.',
|
|
125
147
|
renameBlocked: 'Built-in and public voices cannot be renamed',
|
|
@@ -254,6 +276,7 @@ window.__ModuleLoader__.load({
|
|
|
254
276
|
if (status === 401 || code === 'AUTH_REQUIRED') return t('err.auth')
|
|
255
277
|
if (status === 429) return t('err.rate')
|
|
256
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')
|
|
257
280
|
if (/at least 3 characters/i.test(message)) return t('err.tooShort')
|
|
258
281
|
if (/daily limit/i.test(message)) return t('err.daily')
|
|
259
282
|
return message
|
|
@@ -701,6 +724,8 @@ function cleanForSpeech(text) {
|
|
|
701
724
|
const [voiceRenameOpen, setVoiceRenameOpen] = React.useState(false)
|
|
702
725
|
const [voiceNameDraft, setVoiceNameDraft] = React.useState('')
|
|
703
726
|
const [designName, setDesignName] = React.useState('')
|
|
727
|
+
const [apiKeyInput, setApiKeyInput] = React.useState('')
|
|
728
|
+
const [connectNote, setConnectNote] = React.useState(null)
|
|
704
729
|
const [voiceNames, setVoiceNames] = React.useState({})
|
|
705
730
|
const [libraryOpen, setLibraryOpen] = React.useState(false)
|
|
706
731
|
const [libraryQuery, setLibraryQuery] = React.useState('')
|
|
@@ -737,13 +762,15 @@ function cleanForSpeech(text) {
|
|
|
737
762
|
setCustomMood(String(data.customMood || ''))
|
|
738
763
|
}, [state.data])
|
|
739
764
|
|
|
765
|
+
const hasKey = Boolean(state.data && state.data.hasKey)
|
|
740
766
|
React.useEffect(() => {
|
|
767
|
+
if (!hasKey) return undefined
|
|
741
768
|
let alive = true
|
|
742
769
|
api('/voices')
|
|
743
770
|
.then((data) => { if (alive) setVoices(data.voices || []) })
|
|
744
771
|
.catch(() => { if (alive) setVoices([]) })
|
|
745
772
|
return () => { alive = false }
|
|
746
|
-
}, [])
|
|
773
|
+
}, [hasKey])
|
|
747
774
|
|
|
748
775
|
const data = state.data
|
|
749
776
|
const presets = data && Array.isArray(data.voicePresets) ? data.voicePresets : []
|
|
@@ -752,6 +779,47 @@ function cleanForSpeech(text) {
|
|
|
752
779
|
const used = data && data.today ? data.today.chars : 0
|
|
753
780
|
const limit = data && data.today ? data.today.limit : dailyChars
|
|
754
781
|
|
|
782
|
+
const connectKey = async () => {
|
|
783
|
+
const key = apiKeyInput.trim()
|
|
784
|
+
if (!key) {
|
|
785
|
+
setConnectNote({ tone: 'error', text: t('extra.keyRequired') })
|
|
786
|
+
return
|
|
787
|
+
}
|
|
788
|
+
setPhase('connect')
|
|
789
|
+
setConnectNote(null)
|
|
790
|
+
try {
|
|
791
|
+
const result = await api('/connect', {
|
|
792
|
+
method: 'POST',
|
|
793
|
+
headers: { 'content-type': 'application/json' },
|
|
794
|
+
body: JSON.stringify({ apiKey: key }),
|
|
795
|
+
})
|
|
796
|
+
setApiKeyInput('')
|
|
797
|
+
setConnectNote({
|
|
798
|
+
tone: 'ok',
|
|
799
|
+
text: t('extra.keyConnected') + (typeof result.balance === 'number' ? ' · ' + result.balance.toFixed(1) + ' ' + t('status.credits') : ''),
|
|
800
|
+
})
|
|
801
|
+
reload()
|
|
802
|
+
const freshVoices = await api('/voices').catch(() => null)
|
|
803
|
+
if (freshVoices && Array.isArray(freshVoices.voices)) setVoices(freshVoices.voices)
|
|
804
|
+
} catch (error) {
|
|
805
|
+
setConnectNote({ tone: 'error', text: humanError(t, error) })
|
|
806
|
+
}
|
|
807
|
+
setPhase('idle')
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
const disconnectKey = async () => {
|
|
811
|
+
setPhase('disconnect')
|
|
812
|
+
setConnectNote(null)
|
|
813
|
+
try {
|
|
814
|
+
await api('/disconnect', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' })
|
|
815
|
+
setConnectNote({ tone: 'muted', text: t('extra.keyDisconnected') })
|
|
816
|
+
reload()
|
|
817
|
+
} catch (error) {
|
|
818
|
+
setConnectNote({ tone: 'error', text: humanError(t, error) })
|
|
819
|
+
}
|
|
820
|
+
setPhase('idle')
|
|
821
|
+
}
|
|
822
|
+
|
|
755
823
|
const preview = async () => {
|
|
756
824
|
setPhase('preview')
|
|
757
825
|
setNotice('')
|
|
@@ -1063,6 +1131,34 @@ function cleanForSpeech(text) {
|
|
|
1063
1131
|
state.error ? h('p', { className: 'dsh-breeze-hint', style: { color: COLOR.error } }, state.error) : null,
|
|
1064
1132
|
|
|
1065
1133
|
h('div', { style: { display: 'flex', flexDirection: 'column' } },
|
|
1134
|
+
row(t('extra.apiKey'),
|
|
1135
|
+
h('input', {
|
|
1136
|
+
className: 'dsh-breeze-control',
|
|
1137
|
+
style: { flex: 1, minWidth: 220, maxWidth: 360 },
|
|
1138
|
+
type: 'password',
|
|
1139
|
+
placeholder: data && data.hasKey ? t('extra.keyBound') : 'brz_...',
|
|
1140
|
+
value: apiKeyInput,
|
|
1141
|
+
onChange: (event) => setApiKeyInput(event.target.value),
|
|
1142
|
+
}),
|
|
1143
|
+
h('button', {
|
|
1144
|
+
type: 'button', className: 'dsh-breeze-btn', 'data-primary': 'true',
|
|
1145
|
+
onClick: connectKey, disabled: phase === 'connect',
|
|
1146
|
+
}, phase === 'connect' ? Spinner(12) : t('extra.connect')),
|
|
1147
|
+
data && data.hasKey
|
|
1148
|
+
? h('button', {
|
|
1149
|
+
type: 'button', className: 'dsh-breeze-btn',
|
|
1150
|
+
onClick: disconnectKey, disabled: phase === 'disconnect',
|
|
1151
|
+
}, t('extra.disconnect'))
|
|
1152
|
+
: null,
|
|
1153
|
+
h('span', {
|
|
1154
|
+
style: {
|
|
1155
|
+
fontSize: 12,
|
|
1156
|
+
color: connectNote
|
|
1157
|
+
? (connectNote.tone === 'error' ? COLOR.error : connectNote.tone === 'ok' ? COLOR.success : COLOR.secondary)
|
|
1158
|
+
: COLOR.secondary,
|
|
1159
|
+
},
|
|
1160
|
+
}, connectNote ? connectNote.text : (data && data.hasKey ? t('extra.keyBound') : t('extra.keyMissing')))),
|
|
1161
|
+
|
|
1066
1162
|
row(t('label.voice'),
|
|
1067
1163
|
h('select', {
|
|
1068
1164
|
className: 'dsh-breeze-control',
|
|
@@ -1170,7 +1266,8 @@ function cleanForSpeech(text) {
|
|
|
1170
1266
|
onChange: (event) => setMoodId(event.target.value),
|
|
1171
1267
|
},
|
|
1172
1268
|
tones.map((tone) => h('option', { key: tone.id, value: tone.id },
|
|
1173
|
-
|
|
1269
|
+
(tone.builtin ? t('tone.' + tone.id) : tone.name)
|
|
1270
|
+
+ (tone.builtin ? '' : ' · ' + t('extra.customTag'))))),
|
|
1174
1271
|
h('button', { type: 'button', className: 'dsh-breeze-btn', onClick: startNewTone }, t('extra.newTone')),
|
|
1175
1272
|
activeTone && !activeTone.builtin
|
|
1176
1273
|
? h('button', { type: 'button', className: 'dsh-breeze-btn', onClick: startEditTone }, t('extra.editTone'))
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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) ?? {}
|
|
@@ -687,6 +692,7 @@ export function apply(ctx, config) {
|
|
|
687
692
|
}
|
|
688
693
|
return json(200, {
|
|
689
694
|
ok: Boolean(s.apiKey) && !error,
|
|
695
|
+
hasKey: Boolean(s.apiKey),
|
|
690
696
|
voiceId: s.voiceId,
|
|
691
697
|
modelId: s.modelId,
|
|
692
698
|
moodId: s.moodId ?? 'normal',
|
|
@@ -906,6 +912,30 @@ export function apply(ctx, config) {
|
|
|
906
912
|
if (st5.voiceId === voiceId) await writeStore({ voiceId: 'voc_rc894j8q2auu' })
|
|
907
913
|
return json(200, { ok: true, voiceId })
|
|
908
914
|
}
|
|
915
|
+
if (route === '/connect' && req.method === 'POST') {
|
|
916
|
+
const body = await readBody()
|
|
917
|
+
const key = String(body.apiKey ?? '').trim()
|
|
918
|
+
if (!key) return json(400, { ok: false, error: 'api key required' })
|
|
919
|
+
try {
|
|
920
|
+
const balance = await callApi('/balance', { apiKey: key })
|
|
921
|
+
await writeStore({ apiKey: key })
|
|
922
|
+
return json(200, { ok: true, balance: balance.balance ?? null })
|
|
923
|
+
} catch (caught) {
|
|
924
|
+
return json(400, {
|
|
925
|
+
ok: false,
|
|
926
|
+
error: caught instanceof Error ? caught.message : String(caught),
|
|
927
|
+
code: caught && caught.code ? String(caught.code) : '',
|
|
928
|
+
status: caught && caught.status ? Number(caught.status) : 0,
|
|
929
|
+
})
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if (route === '/disconnect' && req.method === 'POST') {
|
|
933
|
+
const store = await readStore()
|
|
934
|
+
delete store.apiKey
|
|
935
|
+
delete store.api_key
|
|
936
|
+
await writeFile(SETTINGS_PATH, JSON.stringify(store, null, 2), 'utf8')
|
|
937
|
+
return json(200, { ok: true })
|
|
938
|
+
}
|
|
909
939
|
if (route === '/settings' && req.method === 'POST') {
|
|
910
940
|
const body = await readBody()
|
|
911
941
|
const patch = {}
|
package/package.json
CHANGED