@mulingai-npm/redis 2.7.0 → 2.9.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.
|
@@ -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,37 @@ 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 the 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 the requested translation languages
|
|
273
|
+
if (options.translation) {
|
|
274
|
+
for (const lang of options.translation) {
|
|
275
|
+
if (chunk.translation[lang]) {
|
|
276
|
+
chunk.translation[lang].status = 'DISCARDED';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// 4) discard the requested TTS languages
|
|
281
|
+
if (options.tts) {
|
|
282
|
+
for (const lang of options.tts) {
|
|
283
|
+
if (chunk.tts[lang]) {
|
|
284
|
+
chunk.tts[lang].status = 'DISCARDED';
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
// 5) persist and return
|
|
289
|
+
chunks[idx] = chunk;
|
|
290
|
+
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
291
|
+
return chunk;
|
|
292
|
+
}
|
|
261
293
|
async updateTranslation(roomId, chunkNumber, language, options) {
|
|
262
294
|
// 1) fetch the room’s chunks
|
|
263
295
|
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
@@ -331,11 +363,32 @@ class MulingstreamChunkManager {
|
|
|
331
363
|
if (options.isEmitted !== undefined) {
|
|
332
364
|
chunk.tts[language].isEmitted = options.isEmitted;
|
|
333
365
|
}
|
|
366
|
+
if (options.totalCheck !== undefined) {
|
|
367
|
+
chunk.tts[language].totalCheck = options.totalCheck;
|
|
368
|
+
}
|
|
334
369
|
// 5) persist and return the updated chunk
|
|
335
370
|
chunks[idx] = chunk;
|
|
336
371
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
337
372
|
return chunk;
|
|
338
373
|
}
|
|
374
|
+
async increaseTotalCheck(roomId, chunkNumber, language) {
|
|
375
|
+
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
376
|
+
if (!chunks) {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
380
|
+
if (idx === -1) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
const chunk = chunks[idx];
|
|
384
|
+
if (!chunk.tts[language]) {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
chunk.tts[language].totalCheck += 1;
|
|
388
|
+
chunks[idx] = chunk;
|
|
389
|
+
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
390
|
+
return chunk;
|
|
391
|
+
}
|
|
339
392
|
async areTranslationsProcessed(roomId, chunkNumber) {
|
|
340
393
|
const chunk = await this.getMulingstreamChunkById(roomId, chunkNumber);
|
|
341
394
|
if (!chunk) {
|