1.0.1 • Published 3 years ago

@wxsd/webex-transcription v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Requirements

In order for this module to function properly you must have the Webex Assistant enabled and have access to the active meeting object in your application which can be retrieved using the WebexJS SDK.

Installation

yarn add @wxsd/webex-transcription   |  npm i @wxsd/webex-transcription

Usage

Browser Environment

You can skip this section and start from the first step. Browser environment meets all the requirements for this module to be executed properly.

Node Environment

This module requires a meeting object that can be retrieved from the meeting plugin offered by WebexJS SDK. Webex Meeting plugin requires a window object that is not available in any node environment at the global level. Therefore, we can either use headless browser OR mock the whole window object and attach it globally to our node environment. Note that we don't need any extra webRTC related features from the meeting plugin for this use case. This is one way to mock the object and attach it globally:

import Window from "window";

class RTC {
  constructor() {}
}

class mockWindow {
  window: any;

  constructor() {
    this.window = new Window();
    this.window.RTCPeerConnection = RTC;
  }
}

const { window } = new mockWindow();

global.window = window;

Now you should be able to utilize the meeting plugin to get the meeting object and pass it to Voicea constructor!

Steps

  1. Import the library
    import Transcription from "@wxsd/webex-transcription";
  2. Create an instance from a given active meeting

    // all the active meetings that a user if part of
    const meetings = webex.meetings.meetingCollection.meetings;
    
    // targeted meeting object
    // const meeting = meetings["meetingID"];
    
    // first meeting object
    const meeting = Object.values(meetings)[0];
    
    // create an instance
    const transcription = new Transcription(token, meeting, webex.sessionID);
  3. Connect the application to the webex internal socket connection

    await transcription.connect();
  4. You now have access to the meeting transcription payload inside the closure

    transcription.getTranscription((trs) => {
      console.log(trs);
    
      /***
       * Transcription Object Model
       * {
       *    speaker: current speaker
       *    message: current message
       *    type: 'transcript_final_result' || ''transcript_interim_results'
       * }
       **/
    });
  5. This is how your final code should look like

    import Webex from "webex";
    import Transcription from "@wxsd/webex-transcription";
    
    const webex = new Webex(token);
    
    try {
      await webex.meetings.register();
      await webex.meetings.syncMeetings();
    
      // all the active meetings that a user if part of
      const meetings = webex.meetings.meetingCollection.meetings;
    
      // targeted meeting object
      // const meeting = meetings["meetingID"];
    
      // first meeting object
      const meeting = Object.values(meetings)[0];
    
      const transcription = new Transcription(token, meeting, webex.sessionID);
    
      await transcription.connect();
    
      transcription.getTranscription((trs) => {
        console.log(trs);
      });
    } catch (error) {
      console.log(error);
    }

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Arash Koushkebaghi - LinkedIn - Github