@mulingai-npm/redis 2.7.0 → 2.9.1
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.
|
@@ -36,6 +36,7 @@ export type MulingstreamChunkData = {
|
|
|
36
36
|
ttsAudioPath: string;
|
|
37
37
|
status: StepStatus;
|
|
38
38
|
isEmitted: boolean;
|
|
39
|
+
totalCheck: number;
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
42
|
};
|
|
@@ -105,6 +106,10 @@ export declare class MulingstreamChunkManager {
|
|
|
105
106
|
* Discards a specific language in both translation and tts for a chunk.
|
|
106
107
|
*/
|
|
107
108
|
discardLanguage(roomId: string, chunkNumber: number, language: string): Promise<boolean>;
|
|
109
|
+
discardLanguages(roomId: string, chunkNumber: number, options: {
|
|
110
|
+
translation?: string[];
|
|
111
|
+
tts?: string[];
|
|
112
|
+
}): Promise<MulingstreamChunkData | null>;
|
|
108
113
|
updateTranslation(roomId: string, chunkNumber: number, language: string, options: {
|
|
109
114
|
translation?: string;
|
|
110
115
|
status?: StepStatus;
|
|
@@ -114,6 +119,8 @@ export declare class MulingstreamChunkManager {
|
|
|
114
119
|
ttsAudioPath?: string;
|
|
115
120
|
status?: StepStatus;
|
|
116
121
|
isEmitted?: boolean;
|
|
122
|
+
totalCheck?: number;
|
|
117
123
|
}): Promise<MulingstreamChunkData | null>;
|
|
124
|
+
increaseTotalCheck(roomId: string, chunkNumber: number, language: string): Promise<MulingstreamChunkData | null>;
|
|
118
125
|
areTranslationsProcessed(roomId: string, chunkNumber: number): Promise<boolean>;
|
|
119
126
|
}
|
|
@@ -79,7 +79,8 @@ class MulingstreamChunkManager {
|
|
|
79
79
|
tts[lang] = {
|
|
80
80
|
ttsAudioPath: '',
|
|
81
81
|
status: 'INIT',
|
|
82
|
-
isEmitted: false
|
|
82
|
+
isEmitted: false,
|
|
83
|
+
totalCheck: 0
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
const newChunk = {
|
|
@@ -258,6 +259,39 @@ class MulingstreamChunkManager {
|
|
|
258
259
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
259
260
|
return true;
|
|
260
261
|
}
|
|
262
|
+
async discardLanguages(roomId, chunkNumber, options) {
|
|
263
|
+
// 1) fetch room’s chunks
|
|
264
|
+
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
265
|
+
if (!chunks)
|
|
266
|
+
return null;
|
|
267
|
+
// 2) locate the chunk
|
|
268
|
+
const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
269
|
+
if (idx === -1)
|
|
270
|
+
return null;
|
|
271
|
+
const chunk = chunks[idx];
|
|
272
|
+
// 3) discard translation languages still in INIT
|
|
273
|
+
if (options.translation) {
|
|
274
|
+
for (const lang of options.translation) {
|
|
275
|
+
const entry = chunk.translation[lang];
|
|
276
|
+
if (entry && entry.status === 'INIT') {
|
|
277
|
+
entry.status = 'DISCARDED';
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// 4) discard TTS languages still in INIT
|
|
282
|
+
if (options.tts) {
|
|
283
|
+
for (const lang of options.tts) {
|
|
284
|
+
const entry = chunk.tts[lang];
|
|
285
|
+
if (entry && entry.status === 'INIT') {
|
|
286
|
+
entry.status = 'DISCARDED';
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// 5) persist and return
|
|
291
|
+
chunks[idx] = chunk;
|
|
292
|
+
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
293
|
+
return chunk;
|
|
294
|
+
}
|
|
261
295
|
async updateTranslation(roomId, chunkNumber, language, options) {
|
|
262
296
|
// 1) fetch the room’s chunks
|
|
263
297
|
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
@@ -331,11 +365,32 @@ class MulingstreamChunkManager {
|
|
|
331
365
|
if (options.isEmitted !== undefined) {
|
|
332
366
|
chunk.tts[language].isEmitted = options.isEmitted;
|
|
333
367
|
}
|
|
368
|
+
if (options.totalCheck !== undefined) {
|
|
369
|
+
chunk.tts[language].totalCheck = options.totalCheck;
|
|
370
|
+
}
|
|
334
371
|
// 5) persist and return the updated chunk
|
|
335
372
|
chunks[idx] = chunk;
|
|
336
373
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
337
374
|
return chunk;
|
|
338
375
|
}
|
|
376
|
+
async increaseTotalCheck(roomId, chunkNumber, language) {
|
|
377
|
+
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
378
|
+
if (!chunks) {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
382
|
+
if (idx === -1) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
const chunk = chunks[idx];
|
|
386
|
+
if (!chunk.tts[language]) {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
chunk.tts[language].totalCheck += 1;
|
|
390
|
+
chunks[idx] = chunk;
|
|
391
|
+
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
392
|
+
return chunk;
|
|
393
|
+
}
|
|
339
394
|
async areTranslationsProcessed(roomId, chunkNumber) {
|
|
340
395
|
const chunk = await this.getMulingstreamChunkById(roomId, chunkNumber);
|
|
341
396
|
if (!chunk) {
|