Skip to content

Commit

Permalink
fix(plugin-meetings): listen to transcript for guests (#3405)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkesavan13 authored Feb 28, 2024
1 parent 19b8dee commit 3283de3
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 19 deletions.
14 changes: 12 additions & 2 deletions docs/samples/browser-plugin-meetings/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const voiceaTranscriptionFormattedDisplay = document.querySelector('#voicea-tran
const toggleUnifiedMeetings = document.getElementById('toggle-unified-meeting');
const currentMeetingInfoStatus = document.getElementById('current-meeting-info-status');

const enableLLM = document.getElementById('meetings-enable-llm');
const enableTranscript = document.getElementById('meetings-enable-transcription');

// Store and Grab `access-token` from localstorage
if (localStorage.getItem('date') > new Date().getTime()) {
tokenElm.value = localStorage.getItem('access-token');
Expand Down Expand Up @@ -114,7 +117,7 @@ function generateWebexConfig({credentials}) {
enableAdhocMeetings: true,
enableTcpReachability: tcpReachabilityConfigElm.checked,
},
enableAutomaticLLM: true,
enableAutomaticLLM: enableLLM.checked,
},
credentials,
// Any other sdk config we need
Expand Down Expand Up @@ -560,6 +563,13 @@ function doPostMediaSetup(meeting) {

async function joinMeeting({withMedia, withDevice} = {withMedia: false, withDevice: false}) {
const meeting = webex.meetings.getAllMeetings()[selectedMeetingId];

meeting.on('meeting:transcription:connected', () => {
if (enableTranscript.checked) {
toggleTranscription(true);
}
});

let resourceId = null;

if (!meeting) {
Expand Down Expand Up @@ -1096,7 +1106,7 @@ function setTranscriptEvents() {
});

meeting.on('meeting:receiveTranscription:stopped', () => {
generalToggleTranscription.innerText = "Stop Transcription";
generalToggleTranscription.innerText = "Start Transcription";
generalTranscriptionContent.innerHTML = 'Transcription Content: Webex Assistant must be enabled, check the console!';
});
}
Expand Down
9 changes: 7 additions & 2 deletions docs/samples/browser-plugin-meetings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ <h2 class="collapsible">
<legend>Meetings</legend>
<input type="checkbox" id="enable-tcp-reachability">
<label for="enable-tcp-reachability">Enable TCP reachability (experimental)</label>
<br/>
<input id="meetings-enable-llm" checked type="checkbox">
<label for="meetings-enable-llm-label">Enable LLM</label>
</div>
</div>

Expand Down Expand Up @@ -294,9 +297,9 @@ <h2 class="collapsible">
<fieldset>
<legend>Voicea Transcription</legend>
<div class="u-mv">
You will see the formatted transcription below if you have <b>did one of the below</b>,
You will see the formatted transcription below if you have did the following,
<ul>
<li>Set the <span class="inline-code">receiveTranscription</span> config to <span class="inline-code">true</span> before joining the meeting</li>
<li>Set the <span class="inline-code">enableAutomaticLLM</span> config to <span class="inline-code">true</span> before doing <span class="inline-code">webex.init()</span></li>
<li>Invoked <span class="inline-code">meeting.startTranscription()</span> after joining the meeting</li>
</ul>
<div id="voicea-transcription-formatted-display">
Expand Down Expand Up @@ -385,6 +388,8 @@ <h2 class="collapsible">
<label for="meetings-join-breakout-enabled">Support breakout sessions</label>
<input id="meetings-media-in-lobby-enabled" checked type="checkbox">
<label for="meetings-media-in-lobby-enabled">Support media in lobby</label>
<input id="meetings-enable-transcription" type="checkbox">
<label for="meetings-enable-transcription-label">Enable Transcription (Sample app only)</label>
<p id="password-captcha-status" class="status-par">Click verifyPassword for details</p>
</div>

Expand Down
1 change: 0 additions & 1 deletion packages/@webex/http-core/src/request/request.shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import {defaults, isArray, pick} from 'lodash';
import qs from 'qs';

import {Blob} from 'buffer';
import xhr from '../lib/xhr';
import detect from '../lib/detect';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {EventEmitter} from 'events';

describe('Request shim', () => {
describe('#setAuth()', () => {
beforeAll(() => {
global.Blob = function (content, options) {
return { content, options };
};
});
it('sets auth header', () => {

class DummyXMLHttpRequest {
Expand Down
2 changes: 2 additions & 0 deletions packages/@webex/plugin-meetings/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ export const EVENT_TRIGGERS = {
MEETING_LOCUS_URL_UPDATE: 'meeting:locus:locusUrl:update',
MEETING_STREAM_PUBLISH_STATE_CHANGED: 'meeting:streamPublishStateChanged',

MEETING_TRANSCRIPTION_CONNECTED: 'meeting:transcription:connected',
MEETING_STARTED_RECEIVING_TRANSCRIPTION: 'meeting:receiveTranscription:started',
MEETING_STOPPED_RECEIVING_TRANSCRIPTION: 'meeting:receiveTranscription:stopped',

Expand Down Expand Up @@ -968,6 +969,7 @@ export const SELF_ROLES = {
COHOST: 'COHOST',
MODERATOR: 'MODERATOR',
ATTENDEE: 'ATTENDEE',
PRESENTER: 'PRESENTER',
};

export const MEETING_STATE = {
Expand Down
55 changes: 41 additions & 14 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,9 @@ export default class Meeting extends StatelessWebexPlugin {
* @memberof Meeting
*/
private setUpVoiceaListeners() {
// @ts-ignore
this.webex.internal.voicea.listenToEvents();

// @ts-ignore
this.webex.internal.voicea.on(
VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
Expand Down Expand Up @@ -1994,6 +1997,8 @@ export default class Meeting extends StatelessWebexPlugin {
VOICEAEVENTS.HIGHLIGHT_CREATED,
this.voiceaListenerCallbacks[VOICEAEVENTS.HIGHLIGHT_CREATED]
);

this.areVoiceaEventsSetup = true;
}

/**
Expand Down Expand Up @@ -4587,13 +4592,11 @@ export default class Meeting extends StatelessWebexPlugin {
const {statusCode} = payload;

if (statusCode === 200) {
const currentCaptionLanguage =
this.transcription.languageOptions.requestedCaptionLanguage ?? LANGUAGE_ENGLISH;
this.transcription.languageOptions = {
...this.transcription.languageOptions,
currentCaptionLanguage,
currentCaptionLanguage: language,
};
resolve(currentCaptionLanguage);
resolve(language);
} else {
reject(payload);
}
Expand Down Expand Up @@ -4677,10 +4680,12 @@ export default class Meeting extends StatelessWebexPlugin {
try {
if (!this.areVoiceaEventsSetup) {
this.setUpVoiceaListeners();
this.areVoiceaEventsSetup = true;
}
// @ts-ignore
await this.webex.internal.voicea.toggleTranscribing(true, options?.spokenLanguage);

if (this.getCurUserType() === 'host') {
// @ts-ignore
await this.webex.internal.voicea.toggleTranscribing(true, options?.spokenLanguage);
}
} catch (error) {
LoggerProxy.logger.error(`Meeting:index#startTranscription --> ${error}`);
Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.RECEIVE_TRANSCRIPTION_FAILURE, {
Expand Down Expand Up @@ -4769,6 +4774,7 @@ export default class Meeting extends StatelessWebexPlugin {
VOICEAEVENTS.HIGHLIGHT_CREATED,
this.voiceaListenerCallbacks[VOICEAEVENTS.HIGHLIGHT_CREATED]
);

this.areVoiceaEventsSetup = false;
this.triggerStopReceivingTranscriptionEvent();
}
Expand Down Expand Up @@ -5014,15 +5020,33 @@ export default class Meeting extends StatelessWebexPlugin {
.then((join) => {
// @ts-ignore - config coming from registerPlugin
if (this.config.enableAutomaticLLM) {
this.updateLLMConnection().catch((error) => {
LoggerProxy.logger.error('Meeting:index#join --> Update LLM Connection Failed', error);
this.updateLLMConnection()
.catch((error) => {
LoggerProxy.logger.error(
'Meeting:index#join --> Transcription Socket Connection Failed',
error
);

Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LLM_CONNECTION_AFTER_JOIN_FAILURE, {
correlation_id: this.correlationId,
reason: error?.message,
stack: error.stack,
Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LLM_CONNECTION_AFTER_JOIN_FAILURE, {
correlation_id: this.correlationId,
reason: error?.message,
stack: error.stack,
});
})
.then(() => {
LoggerProxy.logger.info(
'Meeting:index#join --> Transcription Socket Connection Success'
);
Trigger.trigger(
this,
{
file: 'meeting/index',
function: 'join',
},
EVENT_TRIGGERS.MEETING_TRANSCRIPTION_CONNECTED,
undefined
);
});
});
}

return join;
Expand Down Expand Up @@ -7673,6 +7697,9 @@ export default class Meeting extends StatelessWebexPlugin {
if (roles.includes(SELF_ROLES.COHOST)) {
return 'cohost';
}
if (roles.includes(SELF_ROLES.PRESENTER)) {
return 'presenter';
}
if (roles.includes(SELF_ROLES.ATTENDEE)) {
return 'attendee';
}
Expand Down

0 comments on commit 3283de3

Please sign in to comment.