@mulingai-npm/redis 2.2.0 → 2.3.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.
@@ -6,8 +6,8 @@ export type MulingstreamChunkData = {
6
6
  chunkNumber: number;
7
7
  language: string;
8
8
  sttProviders: SttProvider[];
9
- translationTargetLanguages: string[];
10
- ttsTargetLanguages: string[];
9
+ targetLanguages: string[];
10
+ shortCodeTargetLanguages: string[];
11
11
  finalTranscription: string;
12
12
  sttStatus: StepStatus;
13
13
  audioChunk: {
@@ -71,8 +71,8 @@ export declare class MulingstreamChunkManager {
71
71
  isLast: boolean;
72
72
  theme: string;
73
73
  sttProviders: SttProvider[];
74
- translationTargetLanguages: string[];
75
- ttsTargetLanguages: string[];
74
+ targetLanguages: string[];
75
+ shortCodeTargetLanguages: string[];
76
76
  }): Promise<void>;
77
77
  /**
78
78
  * Given roomId and chunkNumber, return the single chunk from the array
@@ -100,4 +100,8 @@ export declare class MulingstreamChunkManager {
100
100
  * Discards a specific language in both translation and tts for a chunk.
101
101
  */
102
102
  discardLanguage(roomId: string, chunkNumber: number, language: string): Promise<boolean>;
103
+ updateTranslation(roomId: string, chunkNumber: number, language: string, options: {
104
+ translation?: string;
105
+ status?: StepStatus;
106
+ }): Promise<boolean>;
103
107
  }
@@ -52,7 +52,7 @@ class MulingstreamChunkManager {
52
52
  }
53
53
  async addMulingstreamChunk(params) {
54
54
  var _a;
55
- const { roomId, chunkNumber, language, start, end, duration, isFirst, isLast, theme, sttProviders, translationTargetLanguages, ttsTargetLanguages } = params;
55
+ const { roomId, chunkNumber, language, start, end, duration, isFirst, isLast, theme, sttProviders, targetLanguages, shortCodeTargetLanguages } = params;
56
56
  const audioChunk = {
57
57
  start,
58
58
  end,
@@ -71,13 +71,11 @@ class MulingstreamChunkManager {
71
71
  }
72
72
  const translation = {};
73
73
  const tts = {};
74
- for (const lang of translationTargetLanguages) {
74
+ for (const lang of targetLanguages) {
75
75
  translation[lang] = {
76
76
  translation: '',
77
77
  status: 'INIT'
78
78
  };
79
- }
80
- for (const lang of ttsTargetLanguages) {
81
79
  tts[lang] = {
82
80
  ttsAudioPath: '',
83
81
  status: 'INIT',
@@ -89,8 +87,8 @@ class MulingstreamChunkManager {
89
87
  chunkNumber,
90
88
  language,
91
89
  sttProviders,
92
- translationTargetLanguages,
93
- ttsTargetLanguages,
90
+ targetLanguages,
91
+ shortCodeTargetLanguages,
94
92
  finalTranscription: '',
95
93
  sttStatus: 'INIT',
96
94
  audioChunk,
@@ -215,5 +213,30 @@ class MulingstreamChunkManager {
215
213
  await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
216
214
  return true;
217
215
  }
216
+ async updateTranslation(roomId, chunkNumber, language, options) {
217
+ // Fetch all chunks for this room
218
+ const chunks = await this.getMulingstreamChunksByRoom(roomId);
219
+ if (!chunks)
220
+ return false;
221
+ // Locate the target chunk
222
+ const chunkIndex = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
223
+ if (chunkIndex === -1)
224
+ return false;
225
+ const chunk = chunks[chunkIndex];
226
+ // Make sure the requested language exists in this chunk
227
+ if (!chunk.translation[language]) {
228
+ return false;
229
+ }
230
+ if (options.translation !== undefined) {
231
+ chunk.translation[language].translation = options.translation;
232
+ }
233
+ if (options.status !== undefined) {
234
+ chunk.translation[language].status = options.status;
235
+ }
236
+ // Persist the whole array back to Redis
237
+ chunks[chunkIndex] = chunk;
238
+ await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
239
+ return true;
240
+ }
218
241
  }
219
242
  exports.MulingstreamChunkManager = MulingstreamChunkManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {