jbc-dssi 1.1.161 → 1.1.162
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/lib/tts.js +1 -11
- package/package.json +1 -1
package/lib/tts.js
CHANGED
|
@@ -7,9 +7,7 @@ export const TTS_VOICES = [
|
|
|
7
7
|
];
|
|
8
8
|
|
|
9
9
|
const TTS_WS = 'wss://api.deepseek.com/v1/tools/tts';
|
|
10
|
-
|
|
11
|
-
const MAX_INFLIGHT = 2;
|
|
12
|
-
const CONNECT_TIMEOUT_MS = 15_000;
|
|
10
|
+
|
|
13
11
|
|
|
14
12
|
function voiceOf(id) {
|
|
15
13
|
return TTS_VOICES.some((v) => v.id === id) ? id : TTS_VOICES[0].id;
|
|
@@ -37,10 +35,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
37
35
|
|
|
38
36
|
async function open({ id, voice, onPage, onDone, onError }) {
|
|
39
37
|
if (typeof id !== 'string' || id === '') return;
|
|
40
|
-
if (sessions.size >= MAX_INFLIGHT) {
|
|
41
|
-
onError?.({ id, error: normalizeError('busy') });
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
38
|
const early = [];
|
|
45
39
|
let earlyEnd = false;
|
|
46
40
|
sessions.set(id, {
|
|
@@ -82,7 +76,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
82
76
|
};
|
|
83
77
|
sessions.set(id, session);
|
|
84
78
|
|
|
85
|
-
const timer = setTimeout(() => finish(session, id, { code: 'timeout' }), CONNECT_TIMEOUT_MS);
|
|
86
79
|
|
|
87
80
|
function flushPages(bytes) {
|
|
88
81
|
for (const chunk of bytes) {
|
|
@@ -94,7 +87,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
94
87
|
function finish(target, sessionId, error) {
|
|
95
88
|
if (target.settled) return;
|
|
96
89
|
target.settled = true;
|
|
97
|
-
clearTimeout(timer);
|
|
98
90
|
sessions.delete(sessionId);
|
|
99
91
|
try {
|
|
100
92
|
target.ws.close();
|
|
@@ -119,8 +111,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
119
111
|
session.pending.push(text);
|
|
120
112
|
return;
|
|
121
113
|
}
|
|
122
|
-
if (session.chars >= MAX_CHARS) return;
|
|
123
|
-
session.chars += text.length;
|
|
124
114
|
try {
|
|
125
115
|
ws.send(JSON.stringify({ event: 'text', text }));
|
|
126
116
|
} catch (err) {
|