This package has been deprecated

Author message:

Effective December 5th, 2024, Twilio Video will End of Life (EOL) and will cease to function for all customers. https://support.twilio.com/hc/en-us/articles/20950630029595-Programmable-Video-End-of-Life-Notice

@twilio/krisp-audio-plugin

1.0.0 • Public • Published

@twilio/krisp-audio-plugin

This plugin can be used with twilio-video.js to add custom noise cancellation to LocalAudioTracks in Group Rooms. In Peer-to-Peer and Go Rooms, Krisp noise cancellation will not be enabled even when requested by the application code. Please follow the steps below to use the plugin in your application:

  1. Install the plugin as a dependency by running npm install @twilio/krisp-audio-plugin.
  2. Host the node_modules/@twilio/krisp-audio-plugin/dist/ folder on your application server. We recommend that you include the plugin's version in the path where the files are hosted in order to avoid browser caching issues when updating the plugin to a newer version.
  3. In your application code, you can now enable Krisp noise cancellation as shown below.
const { connect, createLocalAudioTrack } = require('twilio-video');

// Create a LocalAudioTrack with Krisp noise cancellation enabled.
const localAudioTrack = await createLocalAudioTrack({
  noiseCancellationOptions: {
    sdkAssetsPath: 'path/to/hosted/twilio/krisp/audio/plugin/1.0.0/dist',
    vendor: 'krisp'
  }
});

if (!localAudioTrack.noiseCancellation) {
  // If the Krisp audio plugin fails to load, then a warning message will be logged
  // in the browser console, and the "noiseCancellation" property will be set to null.
  // You can still use the LocalAudioTrack to join a Room. However, it will use the
  // browser's noise suppression instead of the Krisp noise cancellation. Make sure
  // the "sdkAssetsPath" provided in "noiseCancellationOptions" points to the correct
  // hosted path of the plugin assets. 
} else {
  // Join a Room with the LocalAudioTrack.
  const room = await connect('token', {
    name: 'my-cool-room',
    tracks: [localAudioTrack]
  });

  if (!localAudioTrack.noiseCancellation.isEnabled) {
    // Krisp noise cancellation is permanently disabled in Peer-to-Peer and Go Rooms.
  }
}

/**
 * Enable/disable noise cancellation.
 * @param {boolean} enable - whether noise cancellation should be enabled
 */
function setNoiseCancellation(enable) {
  const { noiseCancellation } = localAudioTrack;
  if (noiseCancellation) {
    if (enable) {
      // If enabled, then the LocalAudioTrack will use the Krisp noise
      // cancellation instead of the browser's noise suppression.
      noiseCancellation.enable();
    } else {
      // If disabled, then the LocalAudioTrack will use the browser's
      // noise suppression instead of the Krisp noise cancellation.
      noiseCancellation.disable();
    }
  }
}

Package Sidebar

Install

npm i @twilio/krisp-audio-plugin

Weekly Downloads

2,552

Version

1.0.0

License

SEE LICENSE IN LICENSE.md

Unpacked Size

13.2 MB

Total Files

10

Last publish

Collaborators

  • twilio-video-npm