@mulingai-npm/redis 3.35.0 → 3.35.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.
|
@@ -30,6 +30,7 @@ export type MulingstreamChunkData = {
|
|
|
30
30
|
shortCodeTargetLanguages: string[];
|
|
31
31
|
finalTranscription: string;
|
|
32
32
|
createdAt: number;
|
|
33
|
+
creditUsageSessionId?: number | null;
|
|
33
34
|
streamingChunk: StreamingChunkData;
|
|
34
35
|
translation: {
|
|
35
36
|
[language: string]: {
|
|
@@ -75,6 +76,7 @@ export declare class MulingstreamChunkManager {
|
|
|
75
76
|
sttProvider: SttProvider;
|
|
76
77
|
targetLanguages: string[];
|
|
77
78
|
shortCodeTargetLanguages: string[];
|
|
79
|
+
creditUsageSessionId?: number | null;
|
|
78
80
|
streamingData: {
|
|
79
81
|
startMs: number;
|
|
80
82
|
endMs: number;
|
|
@@ -34,6 +34,7 @@ class MulingstreamChunkManager {
|
|
|
34
34
|
shortCodeTargetLanguages: this.deserialize(h.shortCodeTargetLanguages),
|
|
35
35
|
finalTranscription: h.finalTranscription,
|
|
36
36
|
createdAt: parseInt(h.createdAt, 10),
|
|
37
|
+
creditUsageSessionId: h.creditUsageSessionId ? parseInt(h.creditUsageSessionId, 10) : null,
|
|
37
38
|
streamingChunk: this.deserialize(h.streamingChunk),
|
|
38
39
|
translation: this.deserialize(h.translation),
|
|
39
40
|
tts: this.deserialize(h.tts),
|
|
@@ -75,7 +76,7 @@ class MulingstreamChunkManager {
|
|
|
75
76
|
*/
|
|
76
77
|
async addStreamingChunk(params) {
|
|
77
78
|
var _a, _b;
|
|
78
|
-
const { roomId, userId, chunkNumber, language, transcription, sttProvider, targetLanguages, shortCodeTargetLanguages, streamingData } = params;
|
|
79
|
+
const { roomId, userId, chunkNumber, language, transcription, sttProvider, targetLanguages, shortCodeTargetLanguages, creditUsageSessionId, streamingData } = params;
|
|
79
80
|
// Clear room if this is first chunk (new session)
|
|
80
81
|
if (chunkNumber === 1) {
|
|
81
82
|
const old = await this.redisClient.zrange(this.roomZsetKey(roomId), 0, -1);
|
|
@@ -127,6 +128,7 @@ class MulingstreamChunkManager {
|
|
|
127
128
|
shortCodeTargetLanguages,
|
|
128
129
|
finalTranscription: transcription,
|
|
129
130
|
createdAt,
|
|
131
|
+
creditUsageSessionId: creditUsageSessionId !== null && creditUsageSessionId !== void 0 ? creditUsageSessionId : null,
|
|
130
132
|
streamingChunk,
|
|
131
133
|
translation,
|
|
132
134
|
tts,
|
|
@@ -143,6 +145,7 @@ class MulingstreamChunkManager {
|
|
|
143
145
|
shortCodeTargetLanguages: this.serialize(shortCodeTargetLanguages),
|
|
144
146
|
finalTranscription: transcription,
|
|
145
147
|
createdAt: String(createdAt),
|
|
148
|
+
creditUsageSessionId: creditUsageSessionId != null ? String(creditUsageSessionId) : '',
|
|
146
149
|
streamingChunk: this.serialize(streamingChunk),
|
|
147
150
|
translation: this.serialize(translation),
|
|
148
151
|
tts: this.serialize(tts),
|
|
@@ -36,6 +36,8 @@ export declare class MulingstreamSpeakerManager {
|
|
|
36
36
|
isRoomEmpty(roomId: string): Promise<boolean>;
|
|
37
37
|
updateSourceLanguage(socketId: string, newLang: string): Promise<boolean>;
|
|
38
38
|
updateTargetLanguages(socketId: string, languages: string[]): Promise<boolean>;
|
|
39
|
+
updateSourceLanguageByRoomId(roomId: string, newLang: string): Promise<number>;
|
|
40
|
+
updateTargetLanguagesByRoomId(roomId: string, languages: string[]): Promise<number>;
|
|
39
41
|
increaseRecordingDuration(socketId: string, delta: number): Promise<number>;
|
|
40
42
|
private cleanIndexes;
|
|
41
43
|
}
|
|
@@ -201,6 +201,24 @@ class MulingstreamSpeakerManager {
|
|
|
201
201
|
await this.redisClient.hset(this.buildKey(speaker.speakerId), { targetLanguages: JSON.stringify(languages) });
|
|
202
202
|
return true;
|
|
203
203
|
}
|
|
204
|
+
async updateSourceLanguageByRoomId(roomId, newLang) {
|
|
205
|
+
const speakers = await this.getSpeakersByRoomId(roomId);
|
|
206
|
+
let updated = 0;
|
|
207
|
+
for (const speaker of speakers) {
|
|
208
|
+
await this.redisClient.hset(this.buildKey(speaker.speakerId), { sourceLanguage: newLang });
|
|
209
|
+
updated++;
|
|
210
|
+
}
|
|
211
|
+
return updated;
|
|
212
|
+
}
|
|
213
|
+
async updateTargetLanguagesByRoomId(roomId, languages) {
|
|
214
|
+
const speakers = await this.getSpeakersByRoomId(roomId);
|
|
215
|
+
let updated = 0;
|
|
216
|
+
for (const speaker of speakers) {
|
|
217
|
+
await this.redisClient.hset(this.buildKey(speaker.speakerId), { targetLanguages: JSON.stringify(languages) });
|
|
218
|
+
updated++;
|
|
219
|
+
}
|
|
220
|
+
return updated;
|
|
221
|
+
}
|
|
204
222
|
async increaseRecordingDuration(socketId, delta) {
|
|
205
223
|
const speaker = await this.getSpeakerBySocketId(socketId);
|
|
206
224
|
if (speaker === null)
|