@mulingai-npm/redis 1.13.2 → 1.14.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.
@@ -8,6 +8,9 @@ export type MulingstreamRoomData = {
8
8
  lastReadyChunk: number;
9
9
  lastUsedChunk: number;
10
10
  lastDiscardedChunk: number;
11
+ lastReadyTranscription: number;
12
+ lastUsedTranscription: number;
13
+ lastDiscardedTranscription: number;
11
14
  stt: {
12
15
  [sttProvider: string]: {
13
16
  lastReadyStt: number;
@@ -60,6 +63,11 @@ export declare class MulingstreamRoomTracker {
60
63
  * Any argument passed as null means "do not update that field."
61
64
  */
62
65
  updateChunkTracker(roomId: string, lastReadyChunk: number | null, lastUsedChunk: number | null, lastDiscardedChunk: number | null): Promise<boolean>;
66
+ /**
67
+ * Updates the transcription tracker fields (lastReadyTranscription, lastUsedTranscription , lastDiscardedTranscription).
68
+ * Any argument passed as null means "do not update that field."
69
+ */
70
+ updateTranscriptionTracker(roomId: string, lastReadyTranscription: number | null, lastUsedTranscription: number | null, lastDiscardedTranscription: number | null): Promise<boolean>;
63
71
  /**
64
72
  * Updates the stt tracker for a specific STT provider in the room.
65
73
  * If any argument is null, we do not update that field.
@@ -21,6 +21,9 @@ class MulingstreamRoomTracker {
21
21
  lastReadyChunk: parseInt(data.lastReadyChunk, 10),
22
22
  lastUsedChunk: parseInt(data.lastUsedChunk, 10),
23
23
  lastDiscardedChunk: parseInt(data.lastDiscardedChunk, 10),
24
+ lastReadyTranscription: parseInt(data.lastReadyTranscription, 10),
25
+ lastUsedTranscription: parseInt(data.lastUsedTranscription, 10),
26
+ lastDiscardedTranscription: parseInt(data.lastDiscardedTranscription, 10),
24
27
  stt,
25
28
  translation,
26
29
  tts
@@ -72,6 +75,9 @@ class MulingstreamRoomTracker {
72
75
  const lastReadyChunk = -1;
73
76
  const lastUsedChunk = -1;
74
77
  const lastDiscardedChunk = -1;
78
+ const lastReadyTranscription = -1;
79
+ const lastUsedTranscription = -1;
80
+ const lastDiscardedTranscription = -1;
75
81
  // Store everything in Redis
76
82
  await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, {
77
83
  mulingstreamRoomTrackerId,
@@ -81,6 +87,9 @@ class MulingstreamRoomTracker {
81
87
  lastReadyChunk: lastReadyChunk.toString(),
82
88
  lastUsedChunk: lastUsedChunk.toString(),
83
89
  lastDiscardedChunk: lastDiscardedChunk.toString(),
90
+ lastReadyTranscription: lastReadyTranscription.toString(),
91
+ lastUsedTranscription: lastUsedTranscription.toString(),
92
+ lastDiscardedTranscription: lastDiscardedTranscription.toString(),
84
93
  stt: JSON.stringify(stt),
85
94
  translation: JSON.stringify(translation),
86
95
  tts: JSON.stringify(tts)
@@ -143,6 +152,31 @@ class MulingstreamRoomTracker {
143
152
  }
144
153
  return true;
145
154
  }
155
+ /**
156
+ * Updates the transcription tracker fields (lastReadyTranscription, lastUsedTranscription , lastDiscardedTranscription).
157
+ * Any argument passed as null means "do not update that field."
158
+ */
159
+ async updateTranscriptionTracker(roomId, lastReadyTranscription, lastUsedTranscription, lastDiscardedTranscription) {
160
+ const mulingstreamRoomTrackerId = `[${roomId}]`;
161
+ const data = await this.redisClient.hgetall(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`);
162
+ if (!data || !data.mulingstreamRoomTrackerId) {
163
+ return false;
164
+ }
165
+ const updates = {};
166
+ if (lastReadyTranscription !== null) {
167
+ updates.lastReadyTranscription = lastReadyTranscription.toString();
168
+ }
169
+ if (lastUsedTranscription !== null) {
170
+ updates.lastUsedTranscription = lastUsedTranscription.toString();
171
+ }
172
+ if (lastDiscardedTranscription !== null) {
173
+ updates.lastDiscardedTranscription = lastDiscardedTranscription.toString();
174
+ }
175
+ if (Object.keys(updates).length > 0) {
176
+ await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, updates);
177
+ }
178
+ return true;
179
+ }
146
180
  /**
147
181
  * Updates the stt tracker for a specific STT provider in the room.
148
182
  * If any argument is null, we do not update that field.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "1.13.2",
3
+ "version": "1.14.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {