@goodandready/dsh-tts 0.3.22 → 0.4.0
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/README.md +12 -12
- package/README.ru.md +13 -10
- package/README.zh.md +10 -10
- package/lib/cache.js +4 -5
- package/lib/client.js +105 -88
- package/lib/engines/f5.js +45 -33
- package/lib/engines/kokoro.js +21 -29
- package/lib/engines/types.js +26 -13
- package/lib/http-util.js +27 -0
- package/lib/index.js +70 -467
- package/lib/providers.js +105 -25
- package/lib/routes.js +400 -0
- package/lib/stream-hub.js +31 -0
- package/lib/text.js +46 -19
- package/package.json +6 -3
- package/scripts/f5_daemon.py +40 -0
- package/lib/client/worklet.js +0 -71
- package/lib/router.js +0 -4
package/lib/client/worklet.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
class TTSWorklet extends AudioWorkletProcessor {
|
|
2
|
-
constructor() {
|
|
3
|
-
super()
|
|
4
|
-
this.bufferQueue = []
|
|
5
|
-
this.currentChunk = null
|
|
6
|
-
this.chunkOffset = 0
|
|
7
|
-
this.playing = true
|
|
8
|
-
|
|
9
|
-
this.port.onmessage = (event) => {
|
|
10
|
-
const data = event.data
|
|
11
|
-
if (!data) return
|
|
12
|
-
if (data.type === 'chunk' && data.pcm instanceof Float32Array) {
|
|
13
|
-
this.bufferQueue.push(data.pcm)
|
|
14
|
-
} else if (data.type === 'clear' || data.type === 'stop') {
|
|
15
|
-
this.bufferQueue = []
|
|
16
|
-
this.currentChunk = null
|
|
17
|
-
this.chunkOffset = 0
|
|
18
|
-
} else if (data.type === 'pause') {
|
|
19
|
-
this.playing = false
|
|
20
|
-
} else if (data.type === 'resume') {
|
|
21
|
-
this.playing = true
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
process(inputs, outputs, parameters) {
|
|
27
|
-
const output = outputs[0]
|
|
28
|
-
if (!output || !output[0]) return true
|
|
29
|
-
const channel = output[0]
|
|
30
|
-
const bufferLength = channel.length
|
|
31
|
-
|
|
32
|
-
if (!this.playing) {
|
|
33
|
-
channel.fill(0)
|
|
34
|
-
return true
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let written = 0
|
|
38
|
-
while (written < bufferLength) {
|
|
39
|
-
if (!this.currentChunk || this.chunkOffset >= this.currentChunk.length) {
|
|
40
|
-
if (this.bufferQueue.length === 0) {
|
|
41
|
-
this.currentChunk = null
|
|
42
|
-
break
|
|
43
|
-
}
|
|
44
|
-
this.currentChunk = this.bufferQueue.shift()
|
|
45
|
-
this.chunkOffset = 0
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const available = this.currentChunk.length - this.chunkOffset
|
|
49
|
-
const needed = bufferLength - written
|
|
50
|
-
const toCopy = Math.min(available, needed)
|
|
51
|
-
|
|
52
|
-
for (let i = 0; i < toCopy; i++) {
|
|
53
|
-
channel[written + i] = this.currentChunk[this.chunkOffset + i]
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this.chunkOffset += toCopy
|
|
57
|
-
written += toCopy
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Fill remaining output buffer with silence if queue is drained
|
|
61
|
-
if (written < bufferLength) {
|
|
62
|
-
for (let i = written; i < bufferLength; i++) {
|
|
63
|
-
channel[i] = 0
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
registerProcessor('tts-worklet', TTSWorklet)
|
package/lib/router.js
DELETED