@mulingai-npm/redis 1.14.0 → 1.14.1
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.
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { RedisClient } from '../redis-client';
|
|
2
|
-
type AudioSttStatus = 'RECEIVED' | 'DISCARDED' | 'EMPTY' | 'READY' | 'USED';
|
|
3
|
-
export type AudioSttData = {
|
|
4
|
-
audioSttId: string;
|
|
5
|
-
roomId: string;
|
|
6
|
-
start: number;
|
|
7
|
-
end: number;
|
|
8
|
-
duration: number;
|
|
9
|
-
chunkNumber: number;
|
|
10
|
-
isFirst: boolean;
|
|
11
|
-
isLast: boolean;
|
|
12
|
-
language: string;
|
|
13
|
-
theme: string;
|
|
14
|
-
services: string[];
|
|
15
|
-
azureTranscription?: string;
|
|
16
|
-
whisperTranscription?: string;
|
|
17
|
-
googleTranscription?: string;
|
|
18
|
-
processingStart: number;
|
|
19
|
-
totalStatusCheck: number;
|
|
20
|
-
status: AudioSttStatus;
|
|
21
|
-
};
|
|
22
|
-
export declare class AudioSttManager {
|
|
23
|
-
private redisClient;
|
|
24
|
-
constructor(redisClient: RedisClient);
|
|
25
|
-
private parseHashData;
|
|
26
|
-
addAudioStt(sttData: Omit<AudioSttData, 'audioSttId' | 'processingStart' | 'totalStatusCheck' | 'status'>): Promise<string>;
|
|
27
|
-
getAllAudioStt(): Promise<AudioSttData[]>;
|
|
28
|
-
getAllAudioSttByRoom(roomId: string): Promise<AudioSttData[]>;
|
|
29
|
-
getAudioStt(audioSttId: string): Promise<AudioSttData | null>;
|
|
30
|
-
updateAudioSttStatus(audioSttId: string, status: AudioSttStatus): Promise<boolean>;
|
|
31
|
-
updateAudioSttAzureTranscription(audioSttId: string, azureTranscription: string, status: AudioSttStatus): Promise<boolean>;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AudioSttManager = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
const EXPIRATION = 4 * 60 * 60; // 4 hours in seconds
|
|
6
|
-
class AudioSttManager {
|
|
7
|
-
constructor(redisClient) {
|
|
8
|
-
this.redisClient = redisClient;
|
|
9
|
-
}
|
|
10
|
-
parseHashData(data) {
|
|
11
|
-
return {
|
|
12
|
-
audioSttId: data.audioSttId,
|
|
13
|
-
roomId: data.roomId,
|
|
14
|
-
start: parseInt(data.start, 10),
|
|
15
|
-
end: parseInt(data.end, 10),
|
|
16
|
-
duration: parseInt(data.duration, 10),
|
|
17
|
-
chunkNumber: parseInt(data.chunkNumber, 10),
|
|
18
|
-
isFirst: data.isFirst === 'true',
|
|
19
|
-
isLast: data.isLast === 'true',
|
|
20
|
-
language: data.language,
|
|
21
|
-
theme: data.theme,
|
|
22
|
-
services: data.services ? JSON.parse(data.services) : [],
|
|
23
|
-
azureTranscription: data.azureTranscription || undefined,
|
|
24
|
-
whisperTranscription: data.whisperTranscription || undefined,
|
|
25
|
-
googleTranscription: data.googleTranscription || undefined,
|
|
26
|
-
processingStart: parseInt(data.processingStart, 10),
|
|
27
|
-
totalStatusCheck: parseInt(data.totalStatusCheck, 10),
|
|
28
|
-
status: data.status
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Creates a new audio-stt entry.
|
|
32
|
-
// - Generates a unique audioSttId and adds it to the room’s set.
|
|
33
|
-
// - Stores the data in a Redis hash under `audioStt:{audioSttId}`.
|
|
34
|
-
// - Optionally sets an expiration (4h).
|
|
35
|
-
async addAudioStt(sttData) {
|
|
36
|
-
const audioSttId = `[${sttData.roomId}]-[${(0, uuid_1.v4)()}]`;
|
|
37
|
-
const servicesJson = sttData.services ? JSON.stringify(sttData.services) : '[]';
|
|
38
|
-
// Add audioSttId to the set for that room
|
|
39
|
-
await this.redisClient.sadd(`room:${sttData.roomId}:audioStt`, audioSttId);
|
|
40
|
-
// Store audio-stt data in a hash
|
|
41
|
-
await this.redisClient.hset(`audioStt:${audioSttId}`, {
|
|
42
|
-
audioSttId,
|
|
43
|
-
roomId: sttData.roomId,
|
|
44
|
-
start: sttData.start.toString(),
|
|
45
|
-
end: sttData.end.toString(),
|
|
46
|
-
duration: sttData.duration.toString(),
|
|
47
|
-
chunkNumber: sttData.chunkNumber.toString(),
|
|
48
|
-
isFirst: sttData.isFirst.toString(),
|
|
49
|
-
isLast: sttData.isLast.toString(),
|
|
50
|
-
language: sttData.language,
|
|
51
|
-
theme: sttData.theme,
|
|
52
|
-
services: servicesJson,
|
|
53
|
-
processingStart: Date.now().toString(),
|
|
54
|
-
totalStatusCheck: (0).toString(),
|
|
55
|
-
status: 'RECEIVED'
|
|
56
|
-
});
|
|
57
|
-
// Set expiration if desired
|
|
58
|
-
await this.redisClient.expire(`audioStt:${audioSttId}`, EXPIRATION);
|
|
59
|
-
return audioSttId;
|
|
60
|
-
}
|
|
61
|
-
// Retrieves *all* audio-stt entries by scanning the keys that match `audioStt:*`
|
|
62
|
-
async getAllAudioStt() {
|
|
63
|
-
const keys = await this.redisClient.keys('audioStt:*');
|
|
64
|
-
if (!keys || keys.length === 0) {
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
const results = [];
|
|
68
|
-
for (const key of keys) {
|
|
69
|
-
const data = await this.redisClient.hgetall(key);
|
|
70
|
-
if (data && data.audioSttId) {
|
|
71
|
-
results.push(this.parseHashData(data));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return results;
|
|
75
|
-
}
|
|
76
|
-
// Retrieves all audio-stt entries for a specific room by looking up
|
|
77
|
-
// the set `room:{roomId}:audioStt` and then fetching each hash.
|
|
78
|
-
async getAllAudioSttByRoom(roomId) {
|
|
79
|
-
const audioSttIds = await this.redisClient.smembers(`room:${roomId}:audioStt`);
|
|
80
|
-
if (!audioSttIds || audioSttIds.length === 0) {
|
|
81
|
-
return [];
|
|
82
|
-
}
|
|
83
|
-
const results = [];
|
|
84
|
-
for (const id of audioSttIds) {
|
|
85
|
-
const data = await this.redisClient.hgetall(`audioStt:${id}`);
|
|
86
|
-
// if the hash doesn't exist, it may have expired, so remove from the set
|
|
87
|
-
if (!data || Object.keys(data).length === 0) {
|
|
88
|
-
await this.redisClient.srem(`room:${roomId}:audioStt`, id);
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
results.push(this.parseHashData(data));
|
|
92
|
-
}
|
|
93
|
-
return results;
|
|
94
|
-
}
|
|
95
|
-
// Retrieves a single audio-stt entry by ID.
|
|
96
|
-
async getAudioStt(audioSttId) {
|
|
97
|
-
const data = await this.redisClient.hgetall(`audioStt:${audioSttId}`);
|
|
98
|
-
if (!data || !data.audioSttId) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
return this.parseHashData(data);
|
|
102
|
-
}
|
|
103
|
-
async updateAudioSttStatus(audioSttId, status) {
|
|
104
|
-
// Attempt to fetch the data first
|
|
105
|
-
const data = await this.redisClient.hgetall(`audioStt:${audioSttId}`);
|
|
106
|
-
if (!data || !data.audioSttId) {
|
|
107
|
-
// AudioStt either doesn’t exist or has expired
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
// update the status field
|
|
111
|
-
await this.redisClient.hset(`audioStt:${audioSttId}`, {
|
|
112
|
-
status
|
|
113
|
-
});
|
|
114
|
-
return true;
|
|
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
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.AudioSttManager = AudioSttManager;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { RedisClient } from '../redis-client';
|
|
2
|
-
export type SttProvider = 'azure' | 'whisper' | 'google' | 'aws';
|
|
3
|
-
export type MulingstreamRoomData = {
|
|
4
|
-
mulingstreamRoomTrackerId: string;
|
|
5
|
-
roomId: string;
|
|
6
|
-
lastReadyChunk: number;
|
|
7
|
-
lastUsedChunk: number;
|
|
8
|
-
lastDiscardedChunk: number;
|
|
9
|
-
stt: {
|
|
10
|
-
[sttProvider: string]: {
|
|
11
|
-
lastReadyStt: number;
|
|
12
|
-
lastUsedStt: number;
|
|
13
|
-
lastDiscardedStt: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
translation: {
|
|
17
|
-
[language: string]: {
|
|
18
|
-
lastReadyTranslation: number;
|
|
19
|
-
lastUsedTranslation: number;
|
|
20
|
-
lastDiscardedTranslation: number;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
tts: {
|
|
24
|
-
[language: string]: {
|
|
25
|
-
lastReadyTts: number;
|
|
26
|
-
lastUsedTts: number;
|
|
27
|
-
lastDiscardedTts: number;
|
|
28
|
-
lastEmittedTts: number;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export declare class MulingstreamRoomTracker {
|
|
33
|
-
private redisClient;
|
|
34
|
-
constructor(redisClient: RedisClient);
|
|
35
|
-
private parseHashData;
|
|
36
|
-
/**
|
|
37
|
-
* Initializes a new MulingstreamRoomTracker for a given room.
|
|
38
|
-
* - The ID is `[roomId]`.
|
|
39
|
-
* - All "lastReady", "lastUsed", "lastDiscarded", etc. are set to -1 initially.
|
|
40
|
-
* - The sttProviders array is used to create stt sub-objects.
|
|
41
|
-
* - The targetLanguages array is used to create translation/tts sub-objects.
|
|
42
|
-
*/
|
|
43
|
-
initMulingstreamRoomTracker(params: {
|
|
44
|
-
roomId: string;
|
|
45
|
-
sttProviders: SttProvider[];
|
|
46
|
-
targetLanguages: string[];
|
|
47
|
-
}): Promise<string>;
|
|
48
|
-
/**
|
|
49
|
-
* Retrieves all MulingstreamRoomTrackers by scanning keys `mulingstreamRoomTracker:*`.
|
|
50
|
-
*/
|
|
51
|
-
getMulingstreamRoomTrackers(): Promise<MulingstreamRoomData[]>;
|
|
52
|
-
/**
|
|
53
|
-
* Retrieves a single MulingstreamRoomTracker by roomId.
|
|
54
|
-
*/
|
|
55
|
-
getMulingstreamRoomTracker(roomId: string): Promise<MulingstreamRoomData | null>;
|
|
56
|
-
/**
|
|
57
|
-
* Updates the chunk-level tracker fields (lastReadyChunk, lastUsedChunk, lastDiscardedChunk).
|
|
58
|
-
* Any argument passed as null means "do not update that field."
|
|
59
|
-
*/
|
|
60
|
-
updateChunkTracker(roomId: string, lastReadyChunk: number | null, lastUsedChunk: number | null, lastDiscardedChunk: number | null): Promise<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* Updates the stt tracker for a specific STT provider in the room.
|
|
63
|
-
* If any argument is null, we do not update that field.
|
|
64
|
-
*/
|
|
65
|
-
updateSttTracker(roomId: string, sttProvider: SttProvider, lastReadyStt: number | null, lastUsedStt: number | null, lastDiscardedStt: number | null): Promise<boolean>;
|
|
66
|
-
/**
|
|
67
|
-
* Updates the translation tracker for a specific language in the room.
|
|
68
|
-
* If any argument is null, we do not update that field.
|
|
69
|
-
*/
|
|
70
|
-
updateTranslationTracker(roomId: string, language: string, lastReadyTranslation: number | null, lastUsedTranslation: number | null, lastDiscardedTranslation: number | null): Promise<boolean>;
|
|
71
|
-
/**
|
|
72
|
-
* Updates the TTS tracker for a specific language in the room.
|
|
73
|
-
* If any argument is null, we do not update that field.
|
|
74
|
-
*/
|
|
75
|
-
updateTtsTracker(roomId: string, language: string, lastReadyTts: number | null, lastUsedTts: number | null, lastDiscardedTts: number | null, lastEmittedTts: number | null): Promise<boolean>;
|
|
76
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MulingstreamRoomTracker = void 0;
|
|
4
|
-
const EXPIRATION = 48 * 60 * 60; // 48 hours in seconds
|
|
5
|
-
class MulingstreamRoomTracker {
|
|
6
|
-
constructor(redisClient) {
|
|
7
|
-
this.redisClient = redisClient;
|
|
8
|
-
}
|
|
9
|
-
parseHashData(data) {
|
|
10
|
-
const stt = JSON.parse(data.stt);
|
|
11
|
-
const translation = JSON.parse(data.translation);
|
|
12
|
-
const tts = JSON.parse(data.tts);
|
|
13
|
-
return {
|
|
14
|
-
mulingstreamRoomTrackerId: data.mulingstreamRoomTrackerId,
|
|
15
|
-
roomId: data.roomId,
|
|
16
|
-
lastReadyChunk: parseInt(data.lastReadyChunk, 10),
|
|
17
|
-
lastUsedChunk: parseInt(data.lastUsedChunk, 10),
|
|
18
|
-
lastDiscardedChunk: parseInt(data.lastDiscardedChunk, 10),
|
|
19
|
-
stt,
|
|
20
|
-
translation,
|
|
21
|
-
tts
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Initializes a new MulingstreamRoomTracker for a given room.
|
|
26
|
-
* - The ID is `[roomId]`.
|
|
27
|
-
* - All "lastReady", "lastUsed", "lastDiscarded", etc. are set to -1 initially.
|
|
28
|
-
* - The sttProviders array is used to create stt sub-objects.
|
|
29
|
-
* - The targetLanguages array is used to create translation/tts sub-objects.
|
|
30
|
-
*/
|
|
31
|
-
async initMulingstreamRoomTracker(params) {
|
|
32
|
-
const { roomId, sttProviders, targetLanguages } = params;
|
|
33
|
-
// We'll use [roomId] as the unique ID
|
|
34
|
-
const mulingstreamRoomTrackerId = `[${roomId}]`;
|
|
35
|
-
// Build stt object
|
|
36
|
-
// For each provider, set lastReadyStt = -1, lastUsedStt = -1, lastDiscardedStt = -1
|
|
37
|
-
const stt = {};
|
|
38
|
-
for (const provider of sttProviders) {
|
|
39
|
-
stt[provider] = {
|
|
40
|
-
lastReadyStt: -1,
|
|
41
|
-
lastUsedStt: -1,
|
|
42
|
-
lastDiscardedStt: -1
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
// Build translation object
|
|
46
|
-
// For each target language, set lastReadyTranslation = -1, lastUsedTranslation = -1, lastDiscardedTranslation = -1
|
|
47
|
-
const translation = {};
|
|
48
|
-
for (const lang of targetLanguages) {
|
|
49
|
-
translation[lang] = {
|
|
50
|
-
lastReadyTranslation: -1,
|
|
51
|
-
lastUsedTranslation: -1,
|
|
52
|
-
lastDiscardedTranslation: -1
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
// Build tts object
|
|
56
|
-
// For each target language, set lastReadyTts = -1, lastUsedTts = -1, lastDiscardedTts = -1, lastEmittedTts = -1
|
|
57
|
-
const tts = {};
|
|
58
|
-
for (const lang of targetLanguages) {
|
|
59
|
-
tts[lang] = {
|
|
60
|
-
lastReadyTts: -1,
|
|
61
|
-
lastUsedTts: -1,
|
|
62
|
-
lastDiscardedTts: -1,
|
|
63
|
-
lastEmittedTts: -1
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
// Root-level chunk trackers
|
|
67
|
-
const lastReadyChunk = -1;
|
|
68
|
-
const lastUsedChunk = -1;
|
|
69
|
-
const lastDiscardedChunk = -1;
|
|
70
|
-
// Store everything in Redis
|
|
71
|
-
await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, {
|
|
72
|
-
mulingstreamRoomTrackerId,
|
|
73
|
-
roomId,
|
|
74
|
-
lastReadyChunk: lastReadyChunk.toString(),
|
|
75
|
-
lastUsedChunk: lastUsedChunk.toString(),
|
|
76
|
-
lastDiscardedChunk: lastDiscardedChunk.toString(),
|
|
77
|
-
stt: JSON.stringify(stt),
|
|
78
|
-
translation: JSON.stringify(translation),
|
|
79
|
-
tts: JSON.stringify(tts)
|
|
80
|
-
});
|
|
81
|
-
// set expiration
|
|
82
|
-
await this.redisClient.expire(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, EXPIRATION);
|
|
83
|
-
return mulingstreamRoomTrackerId;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Retrieves all MulingstreamRoomTrackers by scanning keys `mulingstreamRoomTracker:*`.
|
|
87
|
-
*/
|
|
88
|
-
async getMulingstreamRoomTrackers() {
|
|
89
|
-
const pattern = 'mulingstreamRoomTracker:*';
|
|
90
|
-
const keys = await this.redisClient.keys(pattern);
|
|
91
|
-
if (!keys || keys.length === 0) {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
const results = [];
|
|
95
|
-
for (const key of keys) {
|
|
96
|
-
const data = await this.redisClient.hgetall(key);
|
|
97
|
-
if (data && data.mulingstreamRoomTrackerId) {
|
|
98
|
-
results.push(this.parseHashData(data));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return results;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Retrieves a single MulingstreamRoomTracker by roomId.
|
|
105
|
-
*/
|
|
106
|
-
async getMulingstreamRoomTracker(roomId) {
|
|
107
|
-
const mulingstreamRoomTrackerId = `[${roomId}]`;
|
|
108
|
-
const data = await this.redisClient.hgetall(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`);
|
|
109
|
-
if (!data || !data.mulingstreamRoomTrackerId) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
return this.parseHashData(data);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Updates the chunk-level tracker fields (lastReadyChunk, lastUsedChunk, lastDiscardedChunk).
|
|
116
|
-
* Any argument passed as null means "do not update that field."
|
|
117
|
-
*/
|
|
118
|
-
async updateChunkTracker(roomId, lastReadyChunk, lastUsedChunk, lastDiscardedChunk) {
|
|
119
|
-
const mulingstreamRoomTrackerId = `[${roomId}]`;
|
|
120
|
-
const data = await this.redisClient.hgetall(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`);
|
|
121
|
-
if (!data || !data.mulingstreamRoomTrackerId) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
const updates = {};
|
|
125
|
-
if (lastReadyChunk !== null) {
|
|
126
|
-
updates.lastReadyChunk = lastReadyChunk.toString();
|
|
127
|
-
}
|
|
128
|
-
if (lastUsedChunk !== null) {
|
|
129
|
-
updates.lastUsedChunk = lastUsedChunk.toString();
|
|
130
|
-
}
|
|
131
|
-
if (lastDiscardedChunk !== null) {
|
|
132
|
-
updates.lastDiscardedChunk = lastDiscardedChunk.toString();
|
|
133
|
-
}
|
|
134
|
-
if (Object.keys(updates).length > 0) {
|
|
135
|
-
await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, updates);
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Updates the stt tracker for a specific STT provider in the room.
|
|
141
|
-
* If any argument is null, we do not update that field.
|
|
142
|
-
*/
|
|
143
|
-
async updateSttTracker(roomId, sttProvider, lastReadyStt, lastUsedStt, lastDiscardedStt) {
|
|
144
|
-
const mulingstreamRoomTrackerId = `[${roomId}]`;
|
|
145
|
-
const data = await this.redisClient.hgetall(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`);
|
|
146
|
-
if (!data || !data.mulingstreamRoomTrackerId) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
const stt = JSON.parse(data.stt);
|
|
150
|
-
if (!stt[sttProvider]) {
|
|
151
|
-
return false; // The provider doesn't exist in this room
|
|
152
|
-
}
|
|
153
|
-
if (lastReadyStt !== null) {
|
|
154
|
-
stt[sttProvider].lastReadyStt = lastReadyStt;
|
|
155
|
-
}
|
|
156
|
-
if (lastUsedStt !== null) {
|
|
157
|
-
stt[sttProvider].lastUsedStt = lastUsedStt;
|
|
158
|
-
}
|
|
159
|
-
if (lastDiscardedStt !== null) {
|
|
160
|
-
stt[sttProvider].lastDiscardedStt = lastDiscardedStt;
|
|
161
|
-
}
|
|
162
|
-
await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, {
|
|
163
|
-
stt: JSON.stringify(stt)
|
|
164
|
-
});
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Updates the translation tracker for a specific language in the room.
|
|
169
|
-
* If any argument is null, we do not update that field.
|
|
170
|
-
*/
|
|
171
|
-
async updateTranslationTracker(roomId, language, lastReadyTranslation, lastUsedTranslation, lastDiscardedTranslation) {
|
|
172
|
-
const mulingstreamRoomTrackerId = `[${roomId}]`;
|
|
173
|
-
const data = await this.redisClient.hgetall(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`);
|
|
174
|
-
if (!data || !data.mulingstreamRoomTrackerId) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
const translation = JSON.parse(data.translation);
|
|
178
|
-
if (!translation[language]) {
|
|
179
|
-
return false; // The language isn't tracked in this room
|
|
180
|
-
}
|
|
181
|
-
if (lastReadyTranslation !== null) {
|
|
182
|
-
translation[language].lastReadyTranslation = lastReadyTranslation;
|
|
183
|
-
}
|
|
184
|
-
if (lastUsedTranslation !== null) {
|
|
185
|
-
translation[language].lastUsedTranslation = lastUsedTranslation;
|
|
186
|
-
}
|
|
187
|
-
if (lastDiscardedTranslation !== null) {
|
|
188
|
-
translation[language].lastDiscardedTranslation = lastDiscardedTranslation;
|
|
189
|
-
}
|
|
190
|
-
await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, {
|
|
191
|
-
translation: JSON.stringify(translation)
|
|
192
|
-
});
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Updates the TTS tracker for a specific language in the room.
|
|
197
|
-
* If any argument is null, we do not update that field.
|
|
198
|
-
*/
|
|
199
|
-
async updateTtsTracker(roomId, language, lastReadyTts, lastUsedTts, lastDiscardedTts, lastEmittedTts) {
|
|
200
|
-
const mulingstreamRoomTrackerId = `[${roomId}]`;
|
|
201
|
-
const data = await this.redisClient.hgetall(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`);
|
|
202
|
-
if (!data || !data.mulingstreamRoomTrackerId) {
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
const tts = JSON.parse(data.tts);
|
|
206
|
-
if (!tts[language]) {
|
|
207
|
-
return false; // The language isn't tracked in this room
|
|
208
|
-
}
|
|
209
|
-
if (lastReadyTts !== null) {
|
|
210
|
-
tts[language].lastReadyTts = lastReadyTts;
|
|
211
|
-
}
|
|
212
|
-
if (lastUsedTts !== null) {
|
|
213
|
-
tts[language].lastUsedTts = lastUsedTts;
|
|
214
|
-
}
|
|
215
|
-
if (lastDiscardedTts !== null) {
|
|
216
|
-
tts[language].lastDiscardedTts = lastDiscardedTts;
|
|
217
|
-
}
|
|
218
|
-
if (lastEmittedTts !== null) {
|
|
219
|
-
tts[language].lastEmittedTts = lastEmittedTts;
|
|
220
|
-
}
|
|
221
|
-
await this.redisClient.hset(`mulingstreamRoomTracker:${mulingstreamRoomTrackerId}`, {
|
|
222
|
-
tts: JSON.stringify(tts)
|
|
223
|
-
});
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
exports.MulingstreamRoomTracker = MulingstreamRoomTracker;
|