@mulingai-npm/redis 3.29.2 → 3.29.3
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.
|
@@ -39,6 +39,8 @@ export type MulingstreamChunkData = {
|
|
|
39
39
|
duration?: number;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
+
isComplete: boolean;
|
|
43
|
+
isSaved: boolean;
|
|
42
44
|
};
|
|
43
45
|
export declare class MulingstreamChunkManager {
|
|
44
46
|
private redisClient;
|
|
@@ -96,6 +98,26 @@ export declare class MulingstreamChunkManager {
|
|
|
96
98
|
duration?: number;
|
|
97
99
|
}): Promise<MulingstreamChunkData | null>;
|
|
98
100
|
areTranslationsProcessed(roomId: string, n: number): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Check if all TTS for all target languages are done (READY, USED, or DISCARDED - not INIT)
|
|
103
|
+
*/
|
|
104
|
+
isChunkComplete(roomId: string, n: number): Promise<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* Mark a chunk as complete (all TTS finished for all target languages)
|
|
107
|
+
*/
|
|
108
|
+
markChunkComplete(roomId: string, n: number): Promise<MulingstreamChunkData | null>;
|
|
109
|
+
/**
|
|
110
|
+
* Mark a chunk as saved to database
|
|
111
|
+
*/
|
|
112
|
+
markChunkSaved(roomId: string, n: number): Promise<MulingstreamChunkData | null>;
|
|
113
|
+
/**
|
|
114
|
+
* Get all complete but unsaved chunks for a room
|
|
115
|
+
*/
|
|
116
|
+
getCompleteUnsavedChunks(roomId: string): Promise<MulingstreamChunkData[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Mark multiple chunks as saved in batch
|
|
119
|
+
*/
|
|
120
|
+
markChunksSaved(roomId: string, chunkNumbers: number[]): Promise<void>;
|
|
99
121
|
/**
|
|
100
122
|
* @deprecated This function is replaced by ChunkSequencer (5-sequencer-handler.ts)
|
|
101
123
|
*
|
|
@@ -35,7 +35,9 @@ class MulingstreamChunkManager {
|
|
|
35
35
|
createdAt: parseInt(h.createdAt, 10),
|
|
36
36
|
streamingChunk: this.deserialize(h.streamingChunk),
|
|
37
37
|
translation: this.deserialize(h.translation),
|
|
38
|
-
tts: this.deserialize(h.tts)
|
|
38
|
+
tts: this.deserialize(h.tts),
|
|
39
|
+
isComplete: h.isComplete === 'true',
|
|
40
|
+
isSaved: h.isSaved === 'true'
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
getTimeout() {
|
|
@@ -124,7 +126,9 @@ class MulingstreamChunkManager {
|
|
|
124
126
|
createdAt,
|
|
125
127
|
streamingChunk,
|
|
126
128
|
translation,
|
|
127
|
-
tts
|
|
129
|
+
tts,
|
|
130
|
+
isComplete: false,
|
|
131
|
+
isSaved: false
|
|
128
132
|
};
|
|
129
133
|
const hash = {
|
|
130
134
|
chunkId,
|
|
@@ -137,7 +141,9 @@ class MulingstreamChunkManager {
|
|
|
137
141
|
createdAt: String(createdAt),
|
|
138
142
|
streamingChunk: this.serialize(streamingChunk),
|
|
139
143
|
translation: this.serialize(translation),
|
|
140
|
-
tts: this.serialize(tts)
|
|
144
|
+
tts: this.serialize(tts),
|
|
145
|
+
isComplete: 'false',
|
|
146
|
+
isSaved: 'false'
|
|
141
147
|
};
|
|
142
148
|
const pipe = this.redisClient.pipeline();
|
|
143
149
|
pipe.hset(this.chunkHashKey(chunkId), hash);
|
|
@@ -185,7 +191,9 @@ class MulingstreamChunkManager {
|
|
|
185
191
|
finalTranscription: chunk.finalTranscription,
|
|
186
192
|
translation: this.serialize(chunk.translation),
|
|
187
193
|
tts: this.serialize(chunk.tts),
|
|
188
|
-
streamingChunk: this.serialize(chunk.streamingChunk)
|
|
194
|
+
streamingChunk: this.serialize(chunk.streamingChunk),
|
|
195
|
+
isComplete: String(chunk.isComplete),
|
|
196
|
+
isSaved: String(chunk.isSaved)
|
|
189
197
|
});
|
|
190
198
|
p.expire(key, EXPIRATION);
|
|
191
199
|
await p.exec();
|
|
@@ -259,6 +267,47 @@ class MulingstreamChunkManager {
|
|
|
259
267
|
const c = await this.getMulingstreamChunkById(roomId, n);
|
|
260
268
|
return !!c && Object.values(c.translation).every((t) => t.status !== 'INIT');
|
|
261
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Check if all TTS for all target languages are done (READY, USED, or DISCARDED - not INIT)
|
|
272
|
+
*/
|
|
273
|
+
async isChunkComplete(roomId, n) {
|
|
274
|
+
const c = await this.getMulingstreamChunkById(roomId, n);
|
|
275
|
+
if (!c)
|
|
276
|
+
return false;
|
|
277
|
+
return Object.values(c.tts).every((t) => t.status !== 'INIT');
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Mark a chunk as complete (all TTS finished for all target languages)
|
|
281
|
+
*/
|
|
282
|
+
async markChunkComplete(roomId, n) {
|
|
283
|
+
return this.withChunk(roomId, n, (c) => {
|
|
284
|
+
c.isComplete = true;
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Mark a chunk as saved to database
|
|
289
|
+
*/
|
|
290
|
+
async markChunkSaved(roomId, n) {
|
|
291
|
+
return this.withChunk(roomId, n, (c) => {
|
|
292
|
+
c.isSaved = true;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Get all complete but unsaved chunks for a room
|
|
297
|
+
*/
|
|
298
|
+
async getCompleteUnsavedChunks(roomId) {
|
|
299
|
+
var _a;
|
|
300
|
+
const chunks = (_a = (await this.getMulingstreamChunksByRoom(roomId))) !== null && _a !== void 0 ? _a : [];
|
|
301
|
+
return chunks.filter((c) => c.isComplete && !c.isSaved);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Mark multiple chunks as saved in batch
|
|
305
|
+
*/
|
|
306
|
+
async markChunksSaved(roomId, chunkNumbers) {
|
|
307
|
+
for (const n of chunkNumbers) {
|
|
308
|
+
await this.markChunkSaved(roomId, n);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
262
311
|
/**
|
|
263
312
|
* @deprecated This function is replaced by ChunkSequencer (5-sequencer-handler.ts)
|
|
264
313
|
*
|