@mulingai-npm/redis 1.13.0 → 1.13.2

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.
@@ -1,5 +1,5 @@
1
1
  export declare enum RedisDatabase {
2
2
  MULINGSTREAM_LISTENER = 0,
3
- MULINGSTREAM_ROOM = 1,
3
+ MULINGSTREAM_ROOM_TRACKER = 1,
4
4
  MULINGSTREAM_CHUNK = 2
5
5
  }
@@ -4,6 +4,6 @@ exports.RedisDatabase = void 0;
4
4
  var RedisDatabase;
5
5
  (function (RedisDatabase) {
6
6
  RedisDatabase[RedisDatabase["MULINGSTREAM_LISTENER"] = 0] = "MULINGSTREAM_LISTENER";
7
- RedisDatabase[RedisDatabase["MULINGSTREAM_ROOM"] = 1] = "MULINGSTREAM_ROOM";
7
+ RedisDatabase[RedisDatabase["MULINGSTREAM_ROOM_TRACKER"] = 1] = "MULINGSTREAM_ROOM_TRACKER";
8
8
  RedisDatabase[RedisDatabase["MULINGSTREAM_CHUNK"] = 2] = "MULINGSTREAM_CHUNK";
9
9
  })(RedisDatabase = exports.RedisDatabase || (exports.RedisDatabase = {}));
@@ -67,4 +67,19 @@ export declare class MulingstreamChunkManager {
67
67
  updateFinalTranscription(mulingstreamChunkId: string, finalTranscription: string): Promise<boolean>;
68
68
  updateSttStatus(mulingstreamChunkId: string, service: SttProvider, status: StepStatus): Promise<boolean>;
69
69
  updateTranscription(mulingstreamChunkId: string, service: SttProvider, transcription: string, sttStatus: StepStatus): Promise<boolean>;
70
+ /****
71
+ * Discards all post-STT steps for a given chunk, i.e. sets
72
+ * all translation[].status and all tts[].status to "DISCARDED".
73
+ ****/
74
+ discardAllPostStt(mulingstreamChunkId: string): Promise<boolean>;
75
+ /****
76
+ * Discards all post-translation steps for a given chunk, i.e. sets
77
+ * all tts[].status to "DISCARDED" (leaves translation alone).
78
+ ****/
79
+ discardAllPostTranslation(mulingstreamChunkId: string): Promise<boolean>;
80
+ /****
81
+ * Discards a specific language in both the translation and tts objects,
82
+ * setting status to DISCARDED for just that one language.
83
+ ****/
84
+ discardLanguage(mulingstreamChunkId: string, language: string): Promise<boolean>;
70
85
  }
@@ -206,5 +206,83 @@ class MulingstreamChunkManager {
206
206
  });
207
207
  return true;
208
208
  }
209
+ /****
210
+ * Discards all post-STT steps for a given chunk, i.e. sets
211
+ * all translation[].status and all tts[].status to "DISCARDED".
212
+ ****/
213
+ async discardAllPostStt(mulingstreamChunkId) {
214
+ // Fetch the chunk
215
+ const data = await this.redisClient.hgetall(`mulingstreamChunk:${mulingstreamChunkId}`);
216
+ if (!data || !data.mulingstreamChunkId) {
217
+ return false;
218
+ }
219
+ // Parse the translation and tts objects
220
+ const translation = JSON.parse(data.translation);
221
+ const tts = JSON.parse(data.tts);
222
+ // Set every language status to DISCARDED in translation
223
+ for (const lang of Object.keys(translation)) {
224
+ translation[lang].status = 'DISCARDED';
225
+ }
226
+ // Set every language status to DISCARDED in tts
227
+ for (const lang of Object.keys(tts)) {
228
+ tts[lang].status = 'DISCARDED';
229
+ }
230
+ // Write back
231
+ await this.redisClient.hset(`mulingstreamChunk:${mulingstreamChunkId}`, {
232
+ translation: JSON.stringify(translation),
233
+ tts: JSON.stringify(tts)
234
+ });
235
+ return true;
236
+ }
237
+ /****
238
+ * Discards all post-translation steps for a given chunk, i.e. sets
239
+ * all tts[].status to "DISCARDED" (leaves translation alone).
240
+ ****/
241
+ async discardAllPostTranslation(mulingstreamChunkId) {
242
+ // Fetch the chunk
243
+ const data = await this.redisClient.hgetall(`mulingstreamChunk:${mulingstreamChunkId}`);
244
+ if (!data || !data.mulingstreamChunkId) {
245
+ return false;
246
+ }
247
+ // Parse the tts object
248
+ const tts = JSON.parse(data.tts);
249
+ // Set every language status to DISCARDED in tts
250
+ for (const lang of Object.keys(tts)) {
251
+ tts[lang].status = 'DISCARDED';
252
+ }
253
+ // Write back
254
+ await this.redisClient.hset(`mulingstreamChunk:${mulingstreamChunkId}`, {
255
+ tts: JSON.stringify(tts)
256
+ });
257
+ return true;
258
+ }
259
+ /****
260
+ * Discards a specific language in both the translation and tts objects,
261
+ * setting status to DISCARDED for just that one language.
262
+ ****/
263
+ async discardLanguage(mulingstreamChunkId, language) {
264
+ // Fetch the chunk
265
+ const data = await this.redisClient.hgetall(`mulingstreamChunk:${mulingstreamChunkId}`);
266
+ if (!data || !data.mulingstreamChunkId) {
267
+ return false;
268
+ }
269
+ // Parse the translation and tts objects
270
+ const translation = JSON.parse(data.translation);
271
+ const tts = JSON.parse(data.tts);
272
+ // If the language exists in translation, discard
273
+ if (translation[language]) {
274
+ translation[language].status = 'DISCARDED';
275
+ }
276
+ // If the language exists in tts, discard
277
+ if (tts[language]) {
278
+ tts[language].status = 'DISCARDED';
279
+ }
280
+ // Write back
281
+ await this.redisClient.hset(`mulingstreamChunk:${mulingstreamChunkId}`, {
282
+ translation: JSON.stringify(translation),
283
+ tts: JSON.stringify(tts)
284
+ });
285
+ return true;
286
+ }
209
287
  }
210
288
  exports.MulingstreamChunkManager = MulingstreamChunkManager;
@@ -3,6 +3,8 @@ export type SttProvider = 'azure' | 'whisper' | 'google' | 'aws';
3
3
  export type MulingstreamRoomData = {
4
4
  mulingstreamRoomTrackerId: string;
5
5
  roomId: string;
6
+ sttProviders: SttProvider[];
7
+ targetLanguages: string[];
6
8
  lastReadyChunk: number;
7
9
  lastUsedChunk: number;
8
10
  lastDiscardedChunk: number;
@@ -7,12 +7,17 @@ class MulingstreamRoomTracker {
7
7
  this.redisClient = redisClient;
8
8
  }
9
9
  parseHashData(data) {
10
+ // Parse any JSON fields
11
+ const sttProviders = JSON.parse(data.sttProviders);
12
+ const targetLanguages = JSON.parse(data.targetLanguages);
10
13
  const stt = JSON.parse(data.stt);
11
14
  const translation = JSON.parse(data.translation);
12
15
  const tts = JSON.parse(data.tts);
13
16
  return {
14
17
  mulingstreamRoomTrackerId: data.mulingstreamRoomTrackerId,
15
18
  roomId: data.roomId,
19
+ sttProviders,
20
+ targetLanguages,
16
21
  lastReadyChunk: parseInt(data.lastReadyChunk, 10),
17
22
  lastUsedChunk: parseInt(data.lastUsedChunk, 10),
18
23
  lastDiscardedChunk: parseInt(data.lastDiscardedChunk, 10),
@@ -71,6 +76,8 @@ class MulingstreamRoomTracker {
71
76
  await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, {
72
77
  mulingstreamRoomTrackerId,
73
78
  roomId,
79
+ sttProviders: JSON.stringify(sttProviders),
80
+ targetLanguages: JSON.stringify(targetLanguages),
74
81
  lastReadyChunk: lastReadyChunk.toString(),
75
82
  lastUsedChunk: lastUsedChunk.toString(),
76
83
  lastDiscardedChunk: lastDiscardedChunk.toString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {