@webex/internal-plugin-voicea 3.12.0-next.8 → 3.12.0-next.80
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/dist/constants.js +4 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/types/constants.d.ts +2 -1
- package/dist/types/index.d.ts +6 -3
- package/dist/types/voicea-plugin.d.ts +23 -0
- package/dist/types/voicea.d.ts +89 -37
- package/dist/types/voicea.types.d.ts +19 -1
- package/dist/voicea-plugin.js +59 -0
- package/dist/voicea-plugin.js.map +1 -0
- package/dist/voicea.js +273 -173
- package/dist/voicea.js.map +1 -1
- package/dist/voicea.types.js.map +1 -1
- package/package.json +9 -9
- package/src/constants.ts +2 -1
- package/src/index.ts +7 -5
- package/src/voicea-plugin.ts +33 -0
- package/src/voicea.ts +274 -178
- package/src/voicea.types.ts +22 -0
- package/test/unit/spec/voicea-plugin.js +83 -0
- package/test/unit/spec/voicea.js +836 -1125
package/dist/voicea.js
CHANGED
|
@@ -12,6 +12,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
12
12
|
value: true
|
|
13
13
|
});
|
|
14
14
|
exports.default = exports.VoiceaChannel = void 0;
|
|
15
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
15
16
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
16
17
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
17
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
@@ -20,6 +21,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
20
21
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
21
22
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
22
23
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
24
|
+
var _events = _interopRequireDefault(require("events"));
|
|
23
25
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
24
26
|
var _webexCore = require("@webex/webex-core");
|
|
25
27
|
var _constants = require("./constants");
|
|
@@ -27,39 +29,49 @@ var _utils = require("./utils");
|
|
|
27
29
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
30
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
31
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
30
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } //
|
|
32
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // @ts-ignore - webex-core types
|
|
33
|
+
// @ts-ignore - internal-plugin-llm types
|
|
31
34
|
/**
|
|
32
|
-
* @description VoiceaChannel
|
|
35
|
+
* @description VoiceaChannel — handles voicea/transcription functionality for a single LLM connection.
|
|
36
|
+
* Created via `webex.internal.voicea.createChannel(llmChannel)`. The caller owns the
|
|
37
|
+
* channel and is responsible for its lifecycle.
|
|
33
38
|
* @export
|
|
34
39
|
* @class VoiceaChannel
|
|
35
40
|
*/
|
|
36
|
-
var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (
|
|
41
|
+
var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_EventEmitter) {
|
|
37
42
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
43
|
+
* Creates a VoiceaChannel, optionally bound to an LLMChannel.
|
|
44
|
+
* If no llmChannel is provided, call switchLLMChannel() later to attach one.
|
|
45
|
+
* @param {LLMChannel} [llmChannel] - The LLM channel to use (optional)
|
|
46
|
+
* @param {Function} request - The request function for making API calls (typically webex.request bound to webex)
|
|
40
47
|
*/
|
|
41
|
-
function VoiceaChannel() {
|
|
48
|
+
function VoiceaChannel(llmChannel, request) {
|
|
42
49
|
var _this;
|
|
43
50
|
(0, _classCallCheck2.default)(this, VoiceaChannel);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_this = _callSuper(this, VoiceaChannel, [].concat(args));
|
|
48
|
-
(0, _defineProperty2.default)(_this, "namespace", _constants.VOICEA);
|
|
51
|
+
_this = _callSuper(this, VoiceaChannel);
|
|
52
|
+
(0, _defineProperty2.default)(_this, "request", void 0);
|
|
53
|
+
(0, _defineProperty2.default)(_this, "llmChannel", void 0);
|
|
49
54
|
(0, _defineProperty2.default)(_this, "seqNum", void 0);
|
|
50
55
|
(0, _defineProperty2.default)(_this, "areCaptionsEnabled", void 0);
|
|
51
56
|
(0, _defineProperty2.default)(_this, "hasSubscribedToEvents", false);
|
|
52
57
|
(0, _defineProperty2.default)(_this, "captionServiceId", void 0);
|
|
53
58
|
(0, _defineProperty2.default)(_this, "announceStatus", void 0);
|
|
54
59
|
(0, _defineProperty2.default)(_this, "captionStatus", void 0);
|
|
55
|
-
(0, _defineProperty2.default)(_this, "
|
|
60
|
+
(0, _defineProperty2.default)(_this, "keepTranscriptionSubscribed", void 0);
|
|
56
61
|
(0, _defineProperty2.default)(_this, "toggleManualCaptionStatus", void 0);
|
|
57
62
|
(0, _defineProperty2.default)(_this, "currentSpokenLanguage", void 0);
|
|
58
63
|
(0, _defineProperty2.default)(_this, "spokenLanguages", []);
|
|
59
64
|
(0, _defineProperty2.default)(_this, "currentCaptionLanguage", void 0);
|
|
65
|
+
// Target channel for reconciler pattern - the channel voicea WANTS to be bound to
|
|
66
|
+
(0, _defineProperty2.default)(_this, "targetLLMChannel", void 0);
|
|
67
|
+
// Single pending 'online' listener for deferred reconciliation
|
|
68
|
+
(0, _defineProperty2.default)(_this, "_pendingOnlineListener", void 0);
|
|
69
|
+
// Tracks whether caption restoration is pending (set on switch, cleared on restore)
|
|
70
|
+
(0, _defineProperty2.default)(_this, "_pendingCaptionRestore", false);
|
|
60
71
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
72
|
+
* Process events from LLM channel
|
|
73
|
+
* @param {Object} e - Event data
|
|
74
|
+
* @returns {void}
|
|
63
75
|
*/
|
|
64
76
|
(0, _defineProperty2.default)(_this, "eventProcessor", function (e) {
|
|
65
77
|
var _e$headers;
|
|
@@ -76,6 +88,9 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
76
88
|
case _constants.AIBRIDGE_RELAY_TYPES.VOICEA.TRANSCRIPTION:
|
|
77
89
|
_this.processTranscription(e.data.voiceaPayload);
|
|
78
90
|
break;
|
|
91
|
+
case _constants.AIBRIDGE_RELAY_TYPES.VOICEA.SPEAKER_NAME_UPDATE:
|
|
92
|
+
_this.processSpeakerNameUpdate(e.data.voiceaPayload);
|
|
93
|
+
break;
|
|
79
94
|
case _constants.AIBRIDGE_RELAY_TYPES.MANUAL.TRANSCRIPTION:
|
|
80
95
|
case _constants.AIBRIDGE_RELAY_TYPES.MANUAL.CAPTIONER:
|
|
81
96
|
_this.processManualTranscription(_objectSpread(_objectSpread({}, e.data.transcriptPayload), {}, {
|
|
@@ -94,8 +109,7 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
94
109
|
*/
|
|
95
110
|
(0, _defineProperty2.default)(_this, "processManualTranscription", function (transcriptPayload) {
|
|
96
111
|
if (transcriptPayload.type === _constants.TRANSCRIPTION_TYPE.MANUAL_CAPTION_FINAL_RESULT || transcriptPayload.type === _constants.TRANSCRIPTION_TYPE.MANUAL_CAPTION_INTERIM_RESULT) {
|
|
97
|
-
|
|
98
|
-
_this.trigger(_constants.EVENT_TRIGGERS.NEW_MANUAL_CAPTION, {
|
|
112
|
+
_this.emit(_constants.EVENT_TRIGGERS.NEW_MANUAL_CAPTION, {
|
|
99
113
|
isFinal: transcriptPayload.type === _constants.TRANSCRIPTION_TYPE.MANUAL_CAPTION_FINAL_RESULT,
|
|
100
114
|
transcriptId: transcriptPayload.id,
|
|
101
115
|
transcripts: transcriptPayload.transcripts,
|
|
@@ -104,54 +118,59 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
104
118
|
});
|
|
105
119
|
}
|
|
106
120
|
});
|
|
121
|
+
/**
|
|
122
|
+
* Process speaker name update and send alert
|
|
123
|
+
* @param {SpeakerNameUpdatePayload} voiceaPayload
|
|
124
|
+
* @returns {void}
|
|
125
|
+
*/
|
|
126
|
+
(0, _defineProperty2.default)(_this, "processSpeakerNameUpdate", function (voiceaPayload) {
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
_this.emit(_constants.EVENT_TRIGGERS.SPEAKER_NAME_UPDATED, voiceaPayload);
|
|
129
|
+
});
|
|
107
130
|
/**
|
|
108
131
|
* Process Transcript and send alert
|
|
109
132
|
* @param {TranscriptionResponse} voiceaPayload
|
|
110
133
|
* @returns {void}
|
|
111
134
|
*/
|
|
112
135
|
(0, _defineProperty2.default)(_this, "processTranscription", function (voiceaPayload) {
|
|
136
|
+
var _voiceaPayload$transc, _voiceaPayload$highli, _voiceaPayload$highli2, _voiceaPayload$highli3, _voiceaPayload$highli4, _voiceaPayload$highli5, _voiceaPayload$highli6, _voiceaPayload$highli7;
|
|
113
137
|
switch (voiceaPayload.type) {
|
|
114
138
|
case _constants.TRANSCRIPTION_TYPE.TRANSCRIPT_INTERIM_RESULTS:
|
|
115
|
-
|
|
116
|
-
_this.trigger(_constants.EVENT_TRIGGERS.NEW_CAPTION, {
|
|
139
|
+
_this.emit(_constants.EVENT_TRIGGERS.NEW_CAPTION, {
|
|
117
140
|
isFinal: false,
|
|
118
141
|
transcriptId: voiceaPayload.transcript_id,
|
|
119
142
|
transcripts: voiceaPayload.transcripts
|
|
120
143
|
});
|
|
121
144
|
break;
|
|
122
145
|
case _constants.TRANSCRIPTION_TYPE.TRANSCRIPT_FINAL_RESULT:
|
|
123
|
-
|
|
124
|
-
_this.trigger(_constants.EVENT_TRIGGERS.NEW_CAPTION, {
|
|
146
|
+
_this.emit(_constants.EVENT_TRIGGERS.NEW_CAPTION, {
|
|
125
147
|
isFinal: true,
|
|
126
148
|
transcriptId: voiceaPayload.transcript_id,
|
|
127
|
-
transcripts: voiceaPayload.transcripts.map(function (transcript) {
|
|
149
|
+
transcripts: (_voiceaPayload$transc = voiceaPayload.transcripts) === null || _voiceaPayload$transc === void 0 ? void 0 : _voiceaPayload$transc.map(function (transcript) {
|
|
128
150
|
transcript.timestamp = (0, _utils.millisToMinutesAndSeconds)(transcript.end_millis);
|
|
129
151
|
return transcript;
|
|
130
152
|
})
|
|
131
153
|
});
|
|
132
154
|
break;
|
|
133
155
|
case _constants.TRANSCRIPTION_TYPE.HIGHLIGHT_CREATED:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
timestamp: (0, _utils.millisToMinutesAndSeconds)(voiceaPayload.highlight.end_millis)
|
|
156
|
+
_this.emit(_constants.EVENT_TRIGGERS.HIGHLIGHT_CREATED, {
|
|
157
|
+
csis: (_voiceaPayload$highli = voiceaPayload.highlight) === null || _voiceaPayload$highli === void 0 ? void 0 : _voiceaPayload$highli.csis,
|
|
158
|
+
highlightId: (_voiceaPayload$highli2 = voiceaPayload.highlight) === null || _voiceaPayload$highli2 === void 0 ? void 0 : _voiceaPayload$highli2.highlight_id,
|
|
159
|
+
text: (_voiceaPayload$highli3 = voiceaPayload.highlight) === null || _voiceaPayload$highli3 === void 0 ? void 0 : _voiceaPayload$highli3.transcript,
|
|
160
|
+
highlightLabel: (_voiceaPayload$highli4 = voiceaPayload.highlight) === null || _voiceaPayload$highli4 === void 0 ? void 0 : _voiceaPayload$highli4.highlight_label,
|
|
161
|
+
highlightSource: (_voiceaPayload$highli5 = voiceaPayload.highlight) === null || _voiceaPayload$highli5 === void 0 ? void 0 : _voiceaPayload$highli5.highlight_source,
|
|
162
|
+
timestamp: (0, _utils.millisToMinutesAndSeconds)((_voiceaPayload$highli6 = (_voiceaPayload$highli7 = voiceaPayload.highlight) === null || _voiceaPayload$highli7 === void 0 ? void 0 : _voiceaPayload$highli7.end_millis) !== null && _voiceaPayload$highli6 !== void 0 ? _voiceaPayload$highli6 : 0)
|
|
142
163
|
});
|
|
143
164
|
break;
|
|
144
165
|
case _constants.TRANSCRIPTION_TYPE.EVA_THANKS:
|
|
145
|
-
|
|
146
|
-
_this.trigger(_constants.EVENT_TRIGGERS.EVA_COMMAND, {
|
|
166
|
+
_this.emit(_constants.EVENT_TRIGGERS.EVA_COMMAND, {
|
|
147
167
|
isListening: false,
|
|
148
168
|
text: voiceaPayload.command_response
|
|
149
169
|
});
|
|
150
170
|
break;
|
|
151
171
|
case _constants.TRANSCRIPTION_TYPE.EVA_WAKE:
|
|
152
172
|
case _constants.TRANSCRIPTION_TYPE.EVA_CANCEL:
|
|
153
|
-
|
|
154
|
-
_this.trigger(_constants.EVENT_TRIGGERS.EVA_COMMAND, {
|
|
173
|
+
_this.emit(_constants.EVENT_TRIGGERS.EVA_COMMAND, {
|
|
155
174
|
isListening: voiceaPayload.type === _constants.TRANSCRIPTION_TYPE.EVA_WAKE
|
|
156
175
|
});
|
|
157
176
|
break;
|
|
@@ -159,8 +178,7 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
159
178
|
{
|
|
160
179
|
var isInSpokenLanguages = _this.spokenLanguages.includes(voiceaPayload.language);
|
|
161
180
|
if (isInSpokenLanguages) {
|
|
162
|
-
|
|
163
|
-
_this.trigger(_constants.EVENT_TRIGGERS.LANGUAGE_DETECTED, {
|
|
181
|
+
_this.emit(_constants.EVENT_TRIGGERS.LANGUAGE_DETECTED, {
|
|
164
182
|
languageCode: voiceaPayload.language
|
|
165
183
|
});
|
|
166
184
|
}
|
|
@@ -177,13 +195,11 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
177
195
|
*/
|
|
178
196
|
(0, _defineProperty2.default)(_this, "processCaptionLanguageResponse", function (voiceaPayload) {
|
|
179
197
|
if (voiceaPayload.statusCode === 200) {
|
|
180
|
-
|
|
181
|
-
_this.trigger(_constants.EVENT_TRIGGERS.CAPTION_LANGUAGE_UPDATE, {
|
|
198
|
+
_this.emit(_constants.EVENT_TRIGGERS.CAPTION_LANGUAGE_UPDATE, {
|
|
182
199
|
statusCode: 200
|
|
183
200
|
});
|
|
184
201
|
} else {
|
|
185
|
-
|
|
186
|
-
_this.trigger(_constants.EVENT_TRIGGERS.CAPTION_LANGUAGE_UPDATE, {
|
|
202
|
+
_this.emit(_constants.EVENT_TRIGGERS.CAPTION_LANGUAGE_UPDATE, {
|
|
187
203
|
statusCode: voiceaPayload.errorCode,
|
|
188
204
|
errorMessage: voiceaPayload.message
|
|
189
205
|
});
|
|
@@ -203,56 +219,34 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
203
219
|
currentSpokenLanguage: _this.currentSpokenLanguage
|
|
204
220
|
};
|
|
205
221
|
_this.spokenLanguages = (_voiceaPayload$ASR$sp2 = voiceaPayload === null || voiceaPayload === void 0 ? void 0 : (_voiceaPayload$ASR2 = voiceaPayload.ASR) === null || _voiceaPayload$ASR2 === void 0 ? void 0 : _voiceaPayload$ASR2.spoken_languages) !== null && _voiceaPayload$ASR$sp2 !== void 0 ? _voiceaPayload$ASR$sp2 : [];
|
|
206
|
-
|
|
207
|
-
_this.trigger(_constants.EVENT_TRIGGERS.VOICEA_ANNOUNCEMENT, voiceaLanguageOptions);
|
|
222
|
+
_this.emit(_constants.EVENT_TRIGGERS.VOICEA_ANNOUNCEMENT, voiceaLanguageOptions);
|
|
208
223
|
});
|
|
209
224
|
/**
|
|
210
|
-
* Indicates whether the
|
|
225
|
+
* Indicates whether the LLM channel is connected.
|
|
211
226
|
* @returns {boolean}
|
|
212
227
|
*/
|
|
213
228
|
(0, _defineProperty2.default)(_this, "isLLMConnected", function () {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
_this.webex.internal.llm.isConnected() ||
|
|
217
|
-
// @ts-ignore
|
|
218
|
-
_this.webex.internal.llm.isConnected(_constants.LLM_PRACTICE_SESSION)
|
|
219
|
-
);
|
|
229
|
+
var _this$llmChannel$isCo, _this$llmChannel;
|
|
230
|
+
return (_this$llmChannel$isCo = (_this$llmChannel = _this.llmChannel) === null || _this$llmChannel === void 0 ? void 0 : _this$llmChannel.isConnected()) !== null && _this$llmChannel$isCo !== void 0 ? _this$llmChannel$isCo : false;
|
|
220
231
|
});
|
|
221
|
-
(0, _defineProperty2.default)(_this, "
|
|
222
|
-
return _this.
|
|
223
|
-
});
|
|
224
|
-
/**
|
|
225
|
-
* Resolves the active LLM publish transport, preferring the practice-session
|
|
226
|
-
* connection only when that session is fully connected.
|
|
227
|
-
* @returns {Object}
|
|
228
|
-
*/
|
|
229
|
-
(0, _defineProperty2.default)(_this, "getPublishTransport", function () {
|
|
230
|
-
// @ts-ignore
|
|
231
|
-
var llm = _this.webex.internal.llm;
|
|
232
|
-
var isPracticeSessionConnected = llm.isConnected(_constants.LLM_PRACTICE_SESSION);
|
|
233
|
-
return {
|
|
234
|
-
socket: isPracticeSessionConnected && llm.getSocket(_constants.LLM_PRACTICE_SESSION) || llm.socket,
|
|
235
|
-
binding: isPracticeSessionConnected && llm.getBinding(_constants.LLM_PRACTICE_SESSION) || llm.getBinding(),
|
|
236
|
-
datachannelUrl: isPracticeSessionConnected && llm.getDatachannelUrl(_constants.LLM_PRACTICE_SESSION) || llm.getDatachannelUrl()
|
|
237
|
-
};
|
|
232
|
+
(0, _defineProperty2.default)(_this, "getKeepTranscriptionSubscribed", function () {
|
|
233
|
+
return _this.keepTranscriptionSubscribed;
|
|
238
234
|
});
|
|
239
235
|
/**
|
|
240
236
|
* Sends Announcement to add voicea to the meeting
|
|
241
237
|
* @returns {void}
|
|
242
238
|
*/
|
|
243
239
|
(0, _defineProperty2.default)(_this, "sendAnnouncement", function () {
|
|
240
|
+
var llm = _this.requireLLMChannel();
|
|
244
241
|
_this.announceStatus = _constants.ANNOUNCE_STATUS.JOINING;
|
|
245
|
-
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
binding = _this$getPublishTrans.binding;
|
|
249
|
-
socket.send({
|
|
242
|
+
var socket = llm.getSocket();
|
|
243
|
+
var binding = llm.getBinding();
|
|
244
|
+
var payload = {
|
|
250
245
|
id: "".concat(_this.seqNum),
|
|
251
246
|
type: 'publishRequest',
|
|
252
|
-
recipients: {
|
|
253
|
-
// @ts-ignore
|
|
247
|
+
recipients: [{
|
|
254
248
|
route: binding
|
|
255
|
-
},
|
|
249
|
+
}],
|
|
256
250
|
// If captionServiceId exists, send it as the 'to' header; otherwise keep headers empty.
|
|
257
251
|
headers: _this.captionServiceId ? {
|
|
258
252
|
to: _this.captionServiceId
|
|
@@ -265,7 +259,8 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
265
259
|
relayType: _constants.AIBRIDGE_RELAY_TYPES.VOICEA.CLIENT_ANNOUNCEMENT
|
|
266
260
|
},
|
|
267
261
|
trackingId: "".concat(_webexCore.config.trackingIdPrefix, "_").concat(_uuid.default.v4().toString())
|
|
268
|
-
}
|
|
262
|
+
};
|
|
263
|
+
socket.send(payload);
|
|
269
264
|
_this.seqNum += 1;
|
|
270
265
|
});
|
|
271
266
|
/**
|
|
@@ -275,26 +270,21 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
275
270
|
* @returns {Promise}
|
|
276
271
|
*/
|
|
277
272
|
(0, _defineProperty2.default)(_this, "setSpokenLanguage", function (languageCode, languageAssignment) {
|
|
278
|
-
return (
|
|
279
|
-
|
|
280
|
-
_this.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
_this.trigger(_constants.EVENT_TRIGGERS.SPOKEN_LANGUAGE_UPDATE, {
|
|
294
|
-
languageCode: languageCode
|
|
295
|
-
});
|
|
296
|
-
})
|
|
297
|
-
);
|
|
273
|
+
return _this.request({
|
|
274
|
+
method: 'PUT',
|
|
275
|
+
url: "".concat(_this.requireLLMChannel().getLocusUrl(), "/controls/"),
|
|
276
|
+
body: {
|
|
277
|
+
transcribe: _objectSpread({
|
|
278
|
+
spokenLanguage: languageCode
|
|
279
|
+
}, languageAssignment && {
|
|
280
|
+
languageAssignment: languageAssignment
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
}).then(function () {
|
|
284
|
+
_this.emit(_constants.EVENT_TRIGGERS.SPOKEN_LANGUAGE_UPDATE, {
|
|
285
|
+
languageCode: languageCode
|
|
286
|
+
});
|
|
287
|
+
});
|
|
298
288
|
});
|
|
299
289
|
/**
|
|
300
290
|
* Request Language translation
|
|
@@ -305,16 +295,15 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
305
295
|
if (!_this.isLLMConnected()) {
|
|
306
296
|
return;
|
|
307
297
|
}
|
|
308
|
-
var
|
|
309
|
-
|
|
310
|
-
|
|
298
|
+
var llm = _this.requireLLMChannel();
|
|
299
|
+
var socket = llm.getSocket();
|
|
300
|
+
var binding = llm.getBinding();
|
|
311
301
|
socket.send({
|
|
312
302
|
id: "".concat(_this.seqNum),
|
|
313
303
|
type: 'publishRequest',
|
|
314
|
-
recipients: {
|
|
315
|
-
// @ts-ignore
|
|
304
|
+
recipients: [{
|
|
316
305
|
route: binding
|
|
317
|
-
},
|
|
306
|
+
}],
|
|
318
307
|
headers: {
|
|
319
308
|
to: _this.captionServiceId
|
|
320
309
|
},
|
|
@@ -343,16 +332,15 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
343
332
|
if (!_this.isLLMConnected()) {
|
|
344
333
|
return;
|
|
345
334
|
}
|
|
346
|
-
var
|
|
347
|
-
|
|
348
|
-
|
|
335
|
+
var llm = _this.requireLLMChannel();
|
|
336
|
+
var socket = llm.getSocket();
|
|
337
|
+
var binding = llm.getBinding();
|
|
349
338
|
socket === null || socket === void 0 ? void 0 : socket.send({
|
|
350
339
|
id: "".concat(_this.seqNum),
|
|
351
340
|
type: 'publishRequest',
|
|
352
|
-
recipients: {
|
|
353
|
-
// @ts-ignore
|
|
341
|
+
recipients: [{
|
|
354
342
|
route: binding
|
|
355
|
-
},
|
|
343
|
+
}],
|
|
356
344
|
headers: {},
|
|
357
345
|
data: {
|
|
358
346
|
eventType: 'relay.event',
|
|
@@ -375,39 +363,35 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
375
363
|
});
|
|
376
364
|
/**
|
|
377
365
|
* request turn on Captions
|
|
378
|
-
* @param {string} [languageCode] - Optional Parameter for spoken language code
|
|
366
|
+
* @param {string} [languageCode] - Optional Parameter for spoken language code
|
|
379
367
|
* @returns {Promise}
|
|
380
368
|
*/
|
|
381
369
|
(0, _defineProperty2.default)(_this, "requestTurnOnCaptions", function (languageCode) {
|
|
382
370
|
_this.captionStatus = _constants.TURN_ON_CAPTION_STATUS.SENDING;
|
|
383
|
-
|
|
384
|
-
// only set the spoken language if it is provided
|
|
371
|
+
var locusUrl = _this.requireLLMChannel().getLocusUrl();
|
|
385
372
|
var body = {
|
|
386
373
|
transcribe: {
|
|
387
374
|
caption: true
|
|
388
375
|
},
|
|
389
376
|
languageCode: languageCode
|
|
390
377
|
};
|
|
391
|
-
|
|
392
|
-
// @ts-ignore
|
|
393
|
-
// eslint-disable-next-line newline-before-return
|
|
394
378
|
return _this.request({
|
|
395
379
|
method: 'PUT',
|
|
396
|
-
|
|
397
|
-
url: "".concat(_this.webex.internal.llm.getLocusUrl(), "/controls/"),
|
|
380
|
+
url: "".concat(locusUrl, "/controls/"),
|
|
398
381
|
body: body
|
|
399
382
|
}).then(function () {
|
|
400
|
-
|
|
401
|
-
_this.trigger(_constants.EVENT_TRIGGERS.CAPTIONS_TURNED_ON);
|
|
383
|
+
_this.emit(_constants.EVENT_TRIGGERS.CAPTIONS_TURNED_ON);
|
|
402
384
|
_this.areCaptionsEnabled = true;
|
|
403
385
|
_this.captionStatus = _constants.TURN_ON_CAPTION_STATUS.ENABLED;
|
|
404
386
|
_this.announce();
|
|
405
387
|
_this.updateSubchannelSubscriptionsAndSyncCaptionState({
|
|
406
388
|
subscribe: ['transcription']
|
|
407
389
|
}, true);
|
|
408
|
-
}).catch(function () {
|
|
390
|
+
}).catch(function (error) {
|
|
409
391
|
_this.captionStatus = _constants.TURN_ON_CAPTION_STATUS.IDLE;
|
|
410
|
-
throw new Error('turn on captions fail'
|
|
392
|
+
throw new Error('turn on captions fail', {
|
|
393
|
+
cause: error
|
|
394
|
+
});
|
|
411
395
|
});
|
|
412
396
|
});
|
|
413
397
|
/**
|
|
@@ -425,7 +409,7 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
425
409
|
return _this.announceStatus === _constants.ANNOUNCE_STATUS.JOINED;
|
|
426
410
|
});
|
|
427
411
|
/**
|
|
428
|
-
* announce to voicea data
|
|
412
|
+
* announce to voicea data channel
|
|
429
413
|
* @returns {void}
|
|
430
414
|
*/
|
|
431
415
|
(0, _defineProperty2.default)(_this, "announce", function () {
|
|
@@ -454,7 +438,7 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
454
438
|
return _regenerator.default.wrap(function (_context) {
|
|
455
439
|
while (1) switch (_context.prev = _context.next) {
|
|
456
440
|
case 0:
|
|
457
|
-
if (!
|
|
441
|
+
if (!_this.isCaptionProcessing()) {
|
|
458
442
|
_context.next = 1;
|
|
459
443
|
break;
|
|
460
444
|
}
|
|
@@ -484,11 +468,9 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
484
468
|
* @returns {Promise}
|
|
485
469
|
*/
|
|
486
470
|
(0, _defineProperty2.default)(_this, "toggleTranscribing", function (activate, spokenLanguage) {
|
|
487
|
-
// @ts-ignore
|
|
488
471
|
return _this.request({
|
|
489
472
|
method: 'PUT',
|
|
490
|
-
|
|
491
|
-
url: "".concat(_this.webex.internal.llm.getLocusUrl(), "/controls/"),
|
|
473
|
+
url: "".concat(_this.requireLLMChannel().getLocusUrl(), "/controls/"),
|
|
492
474
|
body: {
|
|
493
475
|
transcribe: {
|
|
494
476
|
transcribing: activate
|
|
@@ -510,12 +492,9 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
510
492
|
(0, _defineProperty2.default)(_this, "toggleManualCaption", function (enable) {
|
|
511
493
|
if (_this.toggleManualCaptionStatus === _constants.TOGGLE_MANUAL_CAPTION_STATUS.SENDING) return undefined;
|
|
512
494
|
_this.toggleManualCaptionStatus = _constants.TOGGLE_MANUAL_CAPTION_STATUS.SENDING;
|
|
513
|
-
|
|
514
|
-
// @ts-ignore
|
|
515
495
|
return _this.request({
|
|
516
496
|
method: 'PUT',
|
|
517
|
-
|
|
518
|
-
url: "".concat(_this.webex.internal.llm.getLocusUrl(), "/controls/"),
|
|
497
|
+
url: "".concat(_this.requireLLMChannel().getLocusUrl(), "/controls/"),
|
|
519
498
|
body: {
|
|
520
499
|
manualCaption: {
|
|
521
500
|
enable: enable
|
|
@@ -536,8 +515,7 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
536
515
|
* @returns {void}
|
|
537
516
|
*/
|
|
538
517
|
(0, _defineProperty2.default)(_this, "onSpokenLanguageUpdate", function (languageCode, meetingId) {
|
|
539
|
-
|
|
540
|
-
_this.trigger(_constants.EVENT_TRIGGERS.SPOKEN_LANGUAGE_UPDATE, {
|
|
518
|
+
_this.emit(_constants.EVENT_TRIGGERS.SPOKEN_LANGUAGE_UPDATE, {
|
|
541
519
|
languageCode: languageCode,
|
|
542
520
|
meetingId: meetingId
|
|
543
521
|
});
|
|
@@ -554,7 +532,6 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
554
532
|
}
|
|
555
533
|
if (_this.captionServiceId !== serviceId) {
|
|
556
534
|
_this.captionServiceId = serviceId;
|
|
557
|
-
// if service id value has changed and the translation language has been set, client needs to resend the translator language message to the LLM.
|
|
558
535
|
if (_this.currentCaptionLanguage) {
|
|
559
536
|
_this.requestLanguage(_this.currentCaptionLanguage);
|
|
560
537
|
}
|
|
@@ -577,9 +554,6 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
577
554
|
/**
|
|
578
555
|
* update LLM sub‑channel subscriptions.
|
|
579
556
|
*
|
|
580
|
-
* sends a single `subchannelSubscriptionRequest` to LLM,
|
|
581
|
-
* allowing subscribe and unsubscribe subchannel.
|
|
582
|
-
*
|
|
583
557
|
* @param {string[]} options.subscribe Sub‑channels to subscribe to.
|
|
584
558
|
* @param {string[]} options.unsubscribe Sub‑channels to unsubscribe from.
|
|
585
559
|
* @returns {Promise}
|
|
@@ -590,8 +564,8 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
590
564
|
subscribe,
|
|
591
565
|
_ref3$unsubscribe,
|
|
592
566
|
unsubscribe,
|
|
567
|
+
llm,
|
|
593
568
|
isDataChannelTokenEnabled,
|
|
594
|
-
_this$getPublishTrans4,
|
|
595
569
|
socket,
|
|
596
570
|
datachannelUrl,
|
|
597
571
|
_args2 = arguments;
|
|
@@ -599,22 +573,29 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
599
573
|
while (1) switch (_context2.prev = _context2.next) {
|
|
600
574
|
case 0:
|
|
601
575
|
_ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref3$subscribe = _ref3.subscribe, subscribe = _ref3$subscribe === void 0 ? [] : _ref3$subscribe, _ref3$unsubscribe = _ref3.unsubscribe, unsubscribe = _ref3$unsubscribe === void 0 ? [] : _ref3$unsubscribe;
|
|
602
|
-
|
|
603
|
-
|
|
576
|
+
if (_this.isLLMConnected()) {
|
|
577
|
+
_context2.next = 1;
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
return _context2.abrupt("return");
|
|
604
581
|
case 1:
|
|
582
|
+
llm = _this.requireLLMChannel();
|
|
583
|
+
_context2.next = 2;
|
|
584
|
+
return llm.isDataChannelTokenEnabled();
|
|
585
|
+
case 2:
|
|
605
586
|
isDataChannelTokenEnabled = _context2.sent;
|
|
606
|
-
if (
|
|
607
|
-
_context2.next =
|
|
587
|
+
if (isDataChannelTokenEnabled) {
|
|
588
|
+
_context2.next = 3;
|
|
608
589
|
break;
|
|
609
590
|
}
|
|
610
591
|
return _context2.abrupt("return");
|
|
611
|
-
case
|
|
612
|
-
|
|
592
|
+
case 3:
|
|
593
|
+
socket = llm.getSocket();
|
|
594
|
+
datachannelUrl = llm.getDatachannelUrl();
|
|
613
595
|
socket.send({
|
|
614
596
|
id: "".concat(_this.seqNum),
|
|
615
597
|
type: 'subchannelSubscriptionRequest',
|
|
616
598
|
data: {
|
|
617
|
-
// @ts-ignore
|
|
618
599
|
datachannelUri: datachannelUrl,
|
|
619
600
|
subscribe: subscribe,
|
|
620
601
|
unsubscribe: unsubscribe
|
|
@@ -622,29 +603,32 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
622
603
|
trackingId: "".concat(_webexCore.config.trackingIdPrefix, "_").concat(_uuid.default.v4().toString())
|
|
623
604
|
});
|
|
624
605
|
_this.seqNum += 1;
|
|
625
|
-
case
|
|
606
|
+
case 4:
|
|
626
607
|
case "end":
|
|
627
608
|
return _context2.stop();
|
|
628
609
|
}
|
|
629
610
|
}, _callee2);
|
|
630
611
|
})));
|
|
631
612
|
/**
|
|
632
|
-
*
|
|
633
|
-
*
|
|
613
|
+
* Updates transcription subchannel subscriptions and records whether the
|
|
614
|
+
* transcription subscription should be kept (and restored on reconnect).
|
|
634
615
|
*
|
|
635
616
|
* @param {Object} [options] - Subscription options.
|
|
636
617
|
* @param {string[]} [options.subscribe] - Subchannels to subscribe to.
|
|
637
618
|
* @param {string[]} [options.unsubscribe] - Subchannels to unsubscribe from.
|
|
638
|
-
* @param {boolean} [
|
|
619
|
+
* @param {boolean} [keepSubscribed=false] - Whether the transcription
|
|
620
|
+
* subscription should be kept and restored on reconnect.
|
|
639
621
|
*
|
|
640
622
|
* @returns {Promise<void>}
|
|
641
623
|
*/
|
|
642
624
|
(0, _defineProperty2.default)(_this, "updateSubchannelSubscriptionsAndSyncCaptionState", function () {
|
|
643
625
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
644
|
-
var
|
|
645
|
-
_this.
|
|
626
|
+
var keepSubscribed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
627
|
+
_this.keepTranscriptionSubscribed = keepSubscribed;
|
|
646
628
|
return _this.updateSubchannelSubscriptions(options);
|
|
647
629
|
});
|
|
630
|
+
_this.llmChannel = llmChannel;
|
|
631
|
+
_this.request = request;
|
|
648
632
|
_this.seqNum = 1;
|
|
649
633
|
_this.areCaptionsEnabled = false;
|
|
650
634
|
_this.captionServiceId = undefined;
|
|
@@ -653,48 +637,164 @@ var VoiceaChannel = exports.VoiceaChannel = /*#__PURE__*/function (_WebexPlugin)
|
|
|
653
637
|
_this.toggleManualCaptionStatus = _constants.TOGGLE_MANUAL_CAPTION_STATUS.IDLE;
|
|
654
638
|
_this.currentSpokenLanguage = _constants.DEFAULT_SPOKEN_LANGUAGE;
|
|
655
639
|
_this.currentCaptionLanguage = undefined;
|
|
640
|
+
_this.keepTranscriptionSubscribed = false;
|
|
641
|
+
|
|
642
|
+
// Subscribe to relay events from the LLM channel if provided
|
|
643
|
+
if (_this.llmChannel) {
|
|
644
|
+
_this.llmChannel.on('event:relay.event', _this.eventProcessor);
|
|
645
|
+
_this.hasSubscribedToEvents = true;
|
|
646
|
+
}
|
|
656
647
|
return _this;
|
|
657
648
|
}
|
|
658
|
-
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Returns the LLM channel, throwing if not available.
|
|
652
|
+
* @private
|
|
653
|
+
* @returns {LLMChannel}
|
|
654
|
+
* @throws {Error} If LLM channel is not available
|
|
655
|
+
*/
|
|
656
|
+
(0, _inherits2.default)(VoiceaChannel, _EventEmitter);
|
|
659
657
|
return (0, _createClass2.default)(VoiceaChannel, [{
|
|
660
|
-
key: "
|
|
661
|
-
value:
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
* @returns {undefined}
|
|
665
|
-
*/
|
|
666
|
-
function listenToEvents() {
|
|
667
|
-
if (!this.hasSubscribedToEvents) {
|
|
668
|
-
// @ts-ignore
|
|
669
|
-
this.webex.internal.llm.on('event:relay.event', this.eventProcessor);
|
|
670
|
-
// @ts-ignore
|
|
671
|
-
this.webex.internal.llm.on("event:relay.event:".concat(_constants.LLM_PRACTICE_SESSION), this.eventProcessor);
|
|
672
|
-
this.hasSubscribedToEvents = true;
|
|
658
|
+
key: "requireLLMChannel",
|
|
659
|
+
value: function requireLLMChannel() {
|
|
660
|
+
if (!this.llmChannel) {
|
|
661
|
+
throw new Error('VoiceaChannel: LLM channel not available');
|
|
673
662
|
}
|
|
663
|
+
return this.llmChannel;
|
|
674
664
|
}
|
|
675
|
-
|
|
665
|
+
}, {
|
|
666
|
+
key: "deregisterEvents",
|
|
667
|
+
value:
|
|
676
668
|
/**
|
|
677
|
-
*
|
|
669
|
+
* Deregister events and clean up
|
|
678
670
|
* @returns {void}
|
|
679
671
|
*/
|
|
680
|
-
|
|
681
|
-
key: "deregisterEvents",
|
|
682
|
-
value: function deregisterEvents() {
|
|
672
|
+
function deregisterEvents() {
|
|
683
673
|
this.areCaptionsEnabled = false;
|
|
684
|
-
this.
|
|
674
|
+
this.keepTranscriptionSubscribed = false;
|
|
685
675
|
this.captionServiceId = undefined;
|
|
686
|
-
|
|
687
|
-
this.
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
this.
|
|
676
|
+
this.targetLLMChannel = undefined;
|
|
677
|
+
this._pendingCaptionRestore = false;
|
|
678
|
+
|
|
679
|
+
// Remove any pending online listener
|
|
680
|
+
this.detachPendingOnline();
|
|
681
|
+
if (this.hasSubscribedToEvents) {
|
|
682
|
+
var _this$llmChannel2;
|
|
683
|
+
(_this$llmChannel2 = this.llmChannel) === null || _this$llmChannel2 === void 0 ? void 0 : _this$llmChannel2.off('event:relay.event', this.eventProcessor);
|
|
684
|
+
this.hasSubscribedToEvents = false;
|
|
685
|
+
}
|
|
691
686
|
this.announceStatus = _constants.ANNOUNCE_STATUS.IDLE;
|
|
692
687
|
this.captionStatus = _constants.TURN_ON_CAPTION_STATUS.IDLE;
|
|
693
688
|
this.toggleManualCaptionStatus = _constants.TOGGLE_MANUAL_CAPTION_STATUS.IDLE;
|
|
694
689
|
this.currentSpokenLanguage = undefined;
|
|
695
690
|
this.currentCaptionLanguage = undefined;
|
|
696
691
|
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Attach a pending 'online' listener to a channel for deferred reconciliation.
|
|
695
|
+
* Detaches any existing listener first.
|
|
696
|
+
* @param {LLMChannel} channel - The channel to attach to
|
|
697
|
+
* @param {Function} callback - The callback to run when 'online' fires
|
|
698
|
+
* @private
|
|
699
|
+
* @returns {void}
|
|
700
|
+
*/
|
|
701
|
+
}, {
|
|
702
|
+
key: "attachPendingOnline",
|
|
703
|
+
value: function attachPendingOnline(channel, callback) {
|
|
704
|
+
this.detachPendingOnline();
|
|
705
|
+
this._pendingOnlineListener = callback;
|
|
706
|
+
channel.once('online', this._pendingOnlineListener);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Detach any pending 'online' listener.
|
|
711
|
+
* @private
|
|
712
|
+
* @returns {void}
|
|
713
|
+
*/
|
|
714
|
+
}, {
|
|
715
|
+
key: "detachPendingOnline",
|
|
716
|
+
value: function detachPendingOnline() {
|
|
717
|
+
if (this._pendingOnlineListener && this.llmChannel) {
|
|
718
|
+
this.llmChannel.off('online', this._pendingOnlineListener);
|
|
719
|
+
}
|
|
720
|
+
this._pendingOnlineListener = undefined;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Reset announcement state for a new connection.
|
|
725
|
+
* @private
|
|
726
|
+
* @returns {void}
|
|
727
|
+
*/
|
|
728
|
+
}, {
|
|
729
|
+
key: "resetAnnounceState",
|
|
730
|
+
value: function resetAnnounceState() {
|
|
731
|
+
this.announceStatus = _constants.ANNOUNCE_STATUS.IDLE;
|
|
732
|
+
this.captionStatus = _constants.TURN_ON_CAPTION_STATUS.IDLE;
|
|
733
|
+
this.captionServiceId = undefined;
|
|
734
|
+
this.areCaptionsEnabled = false;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Reconcile voicea binding and caption state to match the desired target.
|
|
739
|
+
* This is idempotent - always re-reads targetLLMChannel and current state.
|
|
740
|
+
* A deferred 'online' callback that fires late self-corrects automatically.
|
|
741
|
+
* @private
|
|
742
|
+
* @returns {Promise<void>}
|
|
743
|
+
*/
|
|
744
|
+
}, {
|
|
745
|
+
key: "reconcile",
|
|
746
|
+
value: function reconcile() {
|
|
747
|
+
var _this2 = this;
|
|
748
|
+
var target = this.targetLLMChannel;
|
|
749
|
+
if (!target) return _promise.default.resolve();
|
|
750
|
+
|
|
751
|
+
// 1. Rebind relay-event subscription if actual != desired
|
|
752
|
+
if (this.llmChannel !== target) {
|
|
753
|
+
if (this.hasSubscribedToEvents && this.llmChannel) {
|
|
754
|
+
this.llmChannel.off('event:relay.event', this.eventProcessor);
|
|
755
|
+
}
|
|
756
|
+
this.detachPendingOnline();
|
|
757
|
+
this.llmChannel = target;
|
|
758
|
+
this.llmChannel.on('event:relay.event', this.eventProcessor);
|
|
759
|
+
this.hasSubscribedToEvents = true;
|
|
760
|
+
this.resetAnnounceState();
|
|
761
|
+
// Mark caption restoration as pending if captions were subscribed
|
|
762
|
+
this._pendingCaptionRestore = this.keepTranscriptionSubscribed;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// 2. Restore captions if pending
|
|
766
|
+
if (!this._pendingCaptionRestore) return _promise.default.resolve();
|
|
767
|
+
if (this.isLLMConnected()) {
|
|
768
|
+
// Channel is connected, restore captions immediately
|
|
769
|
+
this._pendingCaptionRestore = false;
|
|
770
|
+
return this.turnOnCaptions(this.currentSpokenLanguage).then(function () {
|
|
771
|
+
return undefined;
|
|
772
|
+
}).catch(function () {
|
|
773
|
+
// Best-effort restoration
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
// Channel not yet connected - defer until 'online' then re-reconcile.
|
|
777
|
+
// If target changes meanwhile, reconcile() self-corrects.
|
|
778
|
+
this.attachPendingOnline(target, function () {
|
|
779
|
+
_this2.reconcile();
|
|
780
|
+
});
|
|
781
|
+
return _promise.default.resolve();
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Switch to a different LLM channel while preserving caption state.
|
|
786
|
+
* Used when transitioning between main meeting and practice session.
|
|
787
|
+
* This is a thin intent-setter - actual binding happens in reconcile().
|
|
788
|
+
* @param {LLMChannel} newLLMChannel - The new LLM channel to switch to
|
|
789
|
+
* @returns {Promise<void>}
|
|
790
|
+
*/
|
|
791
|
+
}, {
|
|
792
|
+
key: "switchLLMChannel",
|
|
793
|
+
value: function switchLLMChannel(newLLMChannel) {
|
|
794
|
+
this.targetLLMChannel = newLLMChannel;
|
|
795
|
+
return this.reconcile();
|
|
796
|
+
}
|
|
697
797
|
}]);
|
|
698
|
-
}(
|
|
798
|
+
}(_events.default);
|
|
699
799
|
var _default = exports.default = VoiceaChannel;
|
|
700
800
|
//# sourceMappingURL=voicea.js.map
|