@eslaykey/dsh-breeze-tts 1.0.3 → 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 +7 -0
- package/client.js +12 -1
- package/index.js +15 -2
- package/package.json +1 -1
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.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
|
+
|
|
8
15
|
## [1.0.3] - 2026-10-31
|
|
9
16
|
|
|
10
17
|
### Fixed
|
package/client.js
CHANGED
|
@@ -482,7 +482,15 @@ function stripEmoji(text) {
|
|
|
482
482
|
|
|
483
483
|
function cleanForSpeech(text, keepTags) {
|
|
484
484
|
let value = String(text ?? '')
|
|
485
|
-
|
|
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, keepTags) {
|
|
|
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
|
|
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
|
-
|
|
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