@mulingai-npm/redis 2.6.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
|
};
|
|
@@ -92,7 +93,10 @@ export declare class MulingstreamChunkManager {
|
|
|
92
93
|
status: StepStatus;
|
|
93
94
|
}>): Promise<boolean>;
|
|
94
95
|
discardStt(roomId: string, chunkNumber: number): Promise<boolean>;
|
|
95
|
-
updateFinalTranscription(roomId: string, chunkNumber: number,
|
|
96
|
+
updateFinalTranscription(roomId: string, chunkNumber: number, options: {
|
|
97
|
+
transcription?: string;
|
|
98
|
+
sttStatus?: StepStatus;
|
|
99
|
+
}): Promise<MulingstreamChunkData | null>;
|
|
96
100
|
/**
|
|
97
101
|
* Discards all post-STT steps for a given chunk:
|
|
98
102
|
* sets all translation[].status & tts[].status to "DISCARDED".
|
|
@@ -102,10 +106,21 @@ export declare class MulingstreamChunkManager {
|
|
|
102
106
|
* Discards a specific language in both translation and tts for a chunk.
|
|
103
107
|
*/
|
|
104
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>;
|
|
105
113
|
updateTranslation(roomId: string, chunkNumber: number, language: string, options: {
|
|
106
114
|
translation?: string;
|
|
107
115
|
status?: StepStatus;
|
|
108
|
-
}): Promise<
|
|
116
|
+
}): Promise<MulingstreamChunkData | null>;
|
|
109
117
|
updateTranslationInBulk(roomId: string, chunkNumber: number, translations: Record<string, string>, status?: StepStatus): Promise<MulingstreamChunkData | null>;
|
|
118
|
+
updateTts(roomId: string, chunkNumber: number, language: string, options: {
|
|
119
|
+
ttsAudioPath?: string;
|
|
120
|
+
status?: StepStatus;
|
|
121
|
+
isEmitted?: boolean;
|
|
122
|
+
totalCheck?: number;
|
|
123
|
+
}): Promise<MulingstreamChunkData | null>;
|
|
124
|
+
increaseTotalCheck(roomId: string, chunkNumber: number, language: string): Promise<MulingstreamChunkData | null>;
|
|
110
125
|
areTranslationsProcessed(roomId: string, chunkNumber: number): Promise<boolean>;
|
|
111
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 = {
|
|
@@ -193,22 +194,23 @@ class MulingstreamChunkManager {
|
|
|
193
194
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
194
195
|
return true;
|
|
195
196
|
}
|
|
196
|
-
async updateFinalTranscription(roomId, chunkNumber,
|
|
197
|
+
async updateFinalTranscription(roomId, chunkNumber, options) {
|
|
198
|
+
// 1) fetch room’s chunks
|
|
197
199
|
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
198
|
-
if (!chunks)
|
|
200
|
+
if (!chunks)
|
|
199
201
|
return null;
|
|
200
|
-
|
|
202
|
+
// 2) locate the chunk
|
|
201
203
|
const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
202
|
-
if (idx === -1)
|
|
204
|
+
if (idx === -1)
|
|
203
205
|
return null;
|
|
206
|
+
// 3) apply updates only when the key is present
|
|
207
|
+
if (options.transcription !== undefined) {
|
|
208
|
+
chunks[idx].finalTranscription = options.transcription;
|
|
204
209
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
chunks[idx].finalTranscription = transcription;
|
|
208
|
-
}
|
|
209
|
-
if (sttStatus !== null) {
|
|
210
|
-
chunks[idx].sttStatus = sttStatus;
|
|
210
|
+
if (options.sttStatus !== undefined) {
|
|
211
|
+
chunks[idx].sttStatus = options.sttStatus;
|
|
211
212
|
}
|
|
213
|
+
// 4) persist and return
|
|
212
214
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
213
215
|
return chunks[idx];
|
|
214
216
|
}
|
|
@@ -257,30 +259,61 @@ class MulingstreamChunkManager {
|
|
|
257
259
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
258
260
|
return true;
|
|
259
261
|
}
|
|
260
|
-
async
|
|
261
|
-
//
|
|
262
|
+
async discardLanguages(roomId, chunkNumber, options) {
|
|
263
|
+
// 1) fetch the room’s chunks
|
|
262
264
|
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
263
265
|
if (!chunks)
|
|
264
|
-
return
|
|
265
|
-
//
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
return
|
|
269
|
-
const chunk = chunks[
|
|
270
|
-
//
|
|
271
|
-
if (
|
|
272
|
-
|
|
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
|
+
}
|
|
273
287
|
}
|
|
288
|
+
// 5) persist and return
|
|
289
|
+
chunks[idx] = chunk;
|
|
290
|
+
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
291
|
+
return chunk;
|
|
292
|
+
}
|
|
293
|
+
async updateTranslation(roomId, chunkNumber, language, options) {
|
|
294
|
+
// 1) fetch the room’s chunks
|
|
295
|
+
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
296
|
+
if (!chunks)
|
|
297
|
+
return null;
|
|
298
|
+
// 2) locate the chunk
|
|
299
|
+
const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
300
|
+
if (idx === -1)
|
|
301
|
+
return null;
|
|
302
|
+
const chunk = chunks[idx];
|
|
303
|
+
// 3) ensure the requested language exists
|
|
304
|
+
if (!chunk.translation[language])
|
|
305
|
+
return null;
|
|
306
|
+
// 4) apply updates only for provided keys
|
|
274
307
|
if (options.translation !== undefined) {
|
|
275
308
|
chunk.translation[language].translation = options.translation;
|
|
276
309
|
}
|
|
277
310
|
if (options.status !== undefined) {
|
|
278
311
|
chunk.translation[language].status = options.status;
|
|
279
312
|
}
|
|
280
|
-
//
|
|
281
|
-
chunks[
|
|
313
|
+
// 5) persist and return
|
|
314
|
+
chunks[idx] = chunk;
|
|
282
315
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
283
|
-
return
|
|
316
|
+
return chunk;
|
|
284
317
|
}
|
|
285
318
|
async updateTranslationInBulk(roomId, chunkNumber, translations, status = 'READY') {
|
|
286
319
|
// 1) fetch the room array
|
|
@@ -307,6 +340,55 @@ class MulingstreamChunkManager {
|
|
|
307
340
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
308
341
|
return chunk;
|
|
309
342
|
}
|
|
343
|
+
async updateTts(roomId, chunkNumber, language, options) {
|
|
344
|
+
// 1) fetch the room’s chunks
|
|
345
|
+
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
346
|
+
if (!chunks)
|
|
347
|
+
return null;
|
|
348
|
+
// 2) locate the chunk
|
|
349
|
+
const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
350
|
+
if (idx === -1)
|
|
351
|
+
return null;
|
|
352
|
+
const chunk = chunks[idx];
|
|
353
|
+
// 3) ensure the language exists in the TTS map
|
|
354
|
+
if (!chunk.tts[language])
|
|
355
|
+
return null;
|
|
356
|
+
// 4) apply only the provided keys
|
|
357
|
+
if (options.ttsAudioPath !== undefined) {
|
|
358
|
+
chunk.tts[language].ttsAudioPath = options.ttsAudioPath;
|
|
359
|
+
}
|
|
360
|
+
if (options.status !== undefined) {
|
|
361
|
+
chunk.tts[language].status = options.status;
|
|
362
|
+
}
|
|
363
|
+
if (options.isEmitted !== undefined) {
|
|
364
|
+
chunk.tts[language].isEmitted = options.isEmitted;
|
|
365
|
+
}
|
|
366
|
+
if (options.totalCheck !== undefined) {
|
|
367
|
+
chunk.tts[language].totalCheck = options.totalCheck;
|
|
368
|
+
}
|
|
369
|
+
// 5) persist and return the updated chunk
|
|
370
|
+
chunks[idx] = chunk;
|
|
371
|
+
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
372
|
+
return chunk;
|
|
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
|
+
}
|
|
310
392
|
async areTranslationsProcessed(roomId, chunkNumber) {
|
|
311
393
|
const chunk = await this.getMulingstreamChunkById(roomId, chunkNumber);
|
|
312
394
|
if (!chunk) {
|