@mulingai-npm/redis 1.4.0 → 1.5.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.
@@ -1,5 +1,5 @@
1
1
  import { RedisClient } from '../redis-client';
2
- type AudioSttStatus = 'RECEIVED' | 'DISCARDED' | 'READY' | 'USED';
2
+ type AudioSttStatus = 'RECEIVED' | 'DISCARDED' | 'EMPTY' | 'READY' | 'USED';
3
3
  export type AudioSttData = {
4
4
  audioSttId: string;
5
5
  roomId: string;
@@ -11,6 +11,7 @@ export type AudioSttData = {
11
11
  isLast: boolean;
12
12
  language: string;
13
13
  theme: string;
14
+ services: string[];
14
15
  azureTranscription?: string;
15
16
  whisperTranscription?: string;
16
17
  googleTranscription?: string;
@@ -27,5 +28,6 @@ export declare class AudioSttManager {
27
28
  getAllAudioSttByRoom(roomId: string): Promise<AudioSttData[]>;
28
29
  getAudioStt(audioSttId: string): Promise<AudioSttData | null>;
29
30
  updateAudioSttStatus(audioSttId: string, status: AudioSttStatus): Promise<boolean>;
31
+ updateAudioSttAzureTranscription(audioSttId: string, azureTranscription: string, status: AudioSttStatus): Promise<boolean>;
30
32
  }
31
33
  export {};
@@ -19,6 +19,7 @@ class AudioSttManager {
19
19
  isLast: data.isLast === 'true',
20
20
  language: data.language,
21
21
  theme: data.theme,
22
+ services: data.services ? JSON.parse(data.services) : [],
22
23
  azureTranscription: data.azureTranscription || undefined,
23
24
  whisperTranscription: data.whisperTranscription || undefined,
24
25
  googleTranscription: data.googleTranscription || undefined,
@@ -33,6 +34,7 @@ class AudioSttManager {
33
34
  // - Optionally sets an expiration (4h).
34
35
  async addAudioStt(sttData) {
35
36
  const audioSttId = `[${sttData.roomId}]-[${(0, uuid_1.v4)()}]`;
37
+ const servicesJson = sttData.services ? JSON.stringify(sttData.services) : '[]';
36
38
  // Add audioSttId to the set for that room
37
39
  await this.redisClient.sadd(`room:${sttData.roomId}:audioStt`, audioSttId);
38
40
  // Store audio-stt data in a hash
@@ -47,6 +49,7 @@ class AudioSttManager {
47
49
  isLast: sttData.isLast.toString(),
48
50
  language: sttData.language,
49
51
  theme: sttData.theme,
52
+ services: servicesJson,
50
53
  processingStart: Date.now().toString(),
51
54
  totalStatusCheck: (0).toString(),
52
55
  status: 'RECEIVED'
@@ -110,5 +113,19 @@ class AudioSttManager {
110
113
  });
111
114
  return true;
112
115
  }
116
+ async updateAudioSttAzureTranscription(audioSttId, azureTranscription, status) {
117
+ // Attempt to fetch the data first
118
+ const data = await this.redisClient.hgetall(`audioStt:${audioSttId}`);
119
+ if (!data || !data.audioSttId) {
120
+ // AudioStt either doesn’t exist or has expired
121
+ return false;
122
+ }
123
+ // Update the azureTranscription and status fields
124
+ await this.redisClient.hset(`audioStt:${audioSttId}`, {
125
+ azureTranscription,
126
+ status
127
+ });
128
+ return true;
129
+ }
113
130
  }
114
131
  exports.AudioSttManager = AudioSttManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {