@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.
@@ -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
@@ -1,4 +0,0 @@
1
- export class AdaptiveRouter {
2
- constructor({registry, role, lang}){ this.registry=registry; this.role=role; this.lang=lang }
3
- pick(){ const list=this.registry.list(); return list[0]?.id || null }
4
- }