@irisaudiotechnologies/iris-web-sdk
    Preparing search index...

    @irisaudiotechnologies/iris-web-sdk

    IRIS Web SDK

    • Set your IRIS token
    export IRIS_SDK_TOKEN=<INSERT YOUR TOKEN HERE>
    
    • Install the IRIS Web SDK
    npm install https://sdk.iris.audio/assets/iris-web-sdk/1.2.5/irisaudiotechnologies-iris-web-sdk-1.2.5.tgz\?token\=$IRIS_SDK_TOKEN
    

    Make sure you have obtained a valid licence and key.

    Do your best to keep the licence and key safe. We recommend fetching them from a server after a user has logged in.

    Do not publish these files to the public.

    Before you use the SDK there needs to be a small amount of setup. Unlike other implementations of the IRIS SDK, when running on the web we need to load certain js files at runtime in accordance with this pattern. This means that these files need to be accessible from the frontend and should live in the public directory.

    The steps are summarised below but we also have a script to make it simpler.

    The simplest way to get up-and-running in your frontend projects is to use our Setup Wizard. If you have installed with NPM you should be able to call the following:

    npx @irisaudiotechnologies/iris-web-sdk setup-wizard
    

    Alternatively, the wizard can be found in the scripts directory of the installed package. Usually: ./node_modules/@irisaudiotechnologies/iris-web-sdk/dist/scripts/setup-wizard.mjs

    1. Move the iris-awp directory from the installed dir (usually ./node_modules/@irisaudiotechnologies/iris-web-sdk/iris-awp to the public folder. The files in this directory need to be accessible from the frontend at runtime. It follows this pattern
      mv ./node_modules/@irisaudiotechnologies/iris-web-sdk/dist/iris-awp ./public/iris-awp
      
    2. Download the core SDK using the following command.
      curl -O https://sdk.iris.audio/assets/js/iris-sdk-1.2.5.tgz?token=$IRIS_SDK_TOKEN
      
    3. Unzip the downloaded tarball.
      tar -xvzf iris-sdk-*.tgz
      
    4. Move the unzipped folder package to the iris-awp dir, renaming it to iris-sdk-wasm, e.g. ./public/iris-awp/iris-sdk-wasm.
      mv ./package ./public/iris-awp/iris-sdk-wasm
      
    5. The resulting file tree should look like this:
      public/
      └── iris-awp/
      ├── iris-awp.js
      ├── iris-base-awp.js
      ├── iris-sdk-wasm/
      │   └── dist/
      └── utils/
    const config = {
    audioWorkletPath: 'PATH/TO/iris-awp/iris-awp.js', // REQUIRED
    company: '<COMPANY_ID>', // REQUIRED
    key: '<IRIS_SDK_KEY>', // REQUIRED
    license: '<IRIS_SDK_LICENCE>', // REQUIRED
    team: '<TEAM_ID>', // REQUIRED
    user: '<USER_ID>', // REQUIRED
    model: 'clarity',
    };

    const iris = new IrisSetup(config);

    This has to be done with a click event, usually at login.

    const audioCtx = new AudioContext();
    await iris.init(audioCtx);

    iris.connectSendStream returns a new MediaStream which you can connect anywhere.

    const processedLocalStream = iris.connectSendStream(localStream);
    

    iris.connectReceiveStream returns a new MediaStream which you can connect anywhere.

    const processedRemoteStream = iris.connectReceiveStream(remoteStream);
    

    The IRIS Web SDK is initialised asynchronously in the audio worklet thread. We have two ways to know when it has succeeded.

    1. Set a callback function.
    iris.options.onReady = () => {
    // Do something here
    console.log('iris activated');
    };
    1. Set up an event listener.
    document.addEventListener(
    'iris-activated',
    (event: CustomEvent<IrisActiveEvent>) => {
    const { irisLoaded } = event.detail;
    if (irisLoaded) {
    // Do something here
    console.log('iris activated');
    }
    }
    );
    iris.start();
    
    • 0 = IRIS processing OFF
    • 1 = IRIS processing ON
    iris.crossFade(1, 'send'); // turn processing on for the send (mic) stream
    iris.crossFade(0, 'receive'); // turn processing on for the receive (speaker) stream
    • 0 = Allow all sounds through (equivalent of processing OFF).
    • 1 = Allow only voice through (equivalent of processing ON).
    iris.setMixLevelMic(0.5); // mic
    iris.setMixLevelSpeaker(0.5); // speaker
    iris.stop();
    

    Return the setup options. Settable. Full list of options is [below](### Setup Options)

    iris.options;
    

    Return the processor options.

    iris.parameters;
    

    Return the latest noise analytics data.

    iris.analyticsData;
    
    Option Required Default Type Description
    audioWorkletPath yes N/A string The path to iris-awp/iris-awp.js relative to the public dir.
    key yes N/A string The contents of your .key file as a string.
    license yes N/A string The contents of your .lic file as a string.
    company yes N/A string The name of the company/organisation that purchased a licence.
    team yes N/A string The name of the team or client under the company.
    user yes N/A string The name of the individual user.
    audioAnalytics no false boolean Enable realtime audio analytics. Potentially increases CPU.
    analyticsReportingInterval no 200 number // value in milliseconds If enabled, how often should audio analytics be reported.
    eventDetection no false boolean If you have SED in your licence and are using a 48k model, do you want to detect audio events?
    loggingLevel no 1 number How much information do you want the SDK to log? 0=none, 1=minimal, 2=verbose, 3=verbose with timestamps.
    logger no (...message: Parameters<typeof console.log>) => console.log(...message) function Provide a function to control how messages from the SDK are logged.
    mic no false boolean Startup state for processing on the mic, ie send stream.
    micMix no 0.9 number // 0.0 - 1.0 Startup wet/dry mix of the mic.
    model no 'clarity' string The IRIS model to use.
    numStreams no 1 number The number of instances of IRIS to use.
    sampleRate no 48000 number The default sample rate
    speaker no false boolean Startup state for processing on the speaker, ie receive stream. Only used if numStreams > 1.
    speakerMix no 0.7 number // 0.0 - 1.0 Startup wet/dry mix of the speaker. Only used if numStreams > 1.
    onReady no (success: boolean) => console.log(IRIS Web SDK: activated, success); function The callback function that returns true after the SDK has been successfully initialised, false if there is another error.