aws / amazon-chime-sdk-js

A JavaScript client library for integrating multi-party communications powered by the Amazon Chime service.
Apache License 2.0
709 stars 477 forks source link

Ability to turn on VoiceFocus by default #1755

Open nmonasterio opened 2 years ago

nmonasterio commented 2 years ago

What are you trying to do?

I'm trying to enable Voice Focus on by default, as it appears to be the only way to prevent echo on some Android devices.

For example: I'm trying to start a meeting session with audio.

How can the documentation be improved to help your use case?

I'd like to see how one could enable VoiceFocus for all devices, upon joining the meeting and/or switching devices.

I am able to create a transformed device with VoiceFocus using VoiceFocusDeviceTransformer.create() and subsequently passing the device ID of the device I want to apply it to, but it does not seem to apply it when provided.

My approach so far:

const enableVoiceFocus = async (device?: string) => {
    const transformer = await VoiceFocusDeviceTransformer.create();
    const isVoiceFocusSupported = transformer.isSupported();
    logger.info("Voice Focus support for audio device", {
      isVoiceFocusSupported,
    });

    logger.info(`Device info while toggling audio device`, { device, isVoiceFocusSupported, selectedDevice: audioInputs.selectedDevice });
    if (isVoiceFocusSupported && device) {
      logger.info("Enabling voice focus for audio device.", { device });
      const transformedDevice = await voiceFocus.addVoiceFocus(audioInputs.selectedDevice);
      logger.debug("TransformedDevice", { transformedDevice });
      if (transformedDevice) {
          const response = await meetingManager.audioVideo?.chooseAudioInputDevice(transformedDevice);
          logger.info("Voice focus enabled for audio device.", { device, response });
      }
    }
  };

For example: Include a section on how to configure the meeting session.

What documentation have you looked at so far?

These docs, the the developer guide as well as the React SDK.

*For example: README.md, Amazon Chime SDK Developer Guide, etc.

xuesichao commented 2 years ago

@nmonasterio Thanks for submitting this request. There are multiple users requesting for the guide on how to enable Voice Focus by default. I need to confirm with the team whether SDK is able to support it or not. For now I know that before joining the meeting, SDK supports enabling the Voice Focus in the device setup process. But users have to enable it manually. We implemented this process in our JS SDK meeting demo. Could you please check this demo first to see if it helps? We will post the update later.

nmonasterio commented 2 years ago

Thanks, @xuesichao! Checking into the JS demo right now. I've tested out the React App demo and, while you can specify whether to enable webAudio, it still does not support enabling it by default. I'll pull down this and run/deploy just for good measure and let you know.

nmonasterio commented 2 years ago

@xuesichao Yes, it seems the JS demo does support enabling it by default, which is great. Let me see if I can follow the code path and see how it could also be applied to the React component library. I'm glad I'm not the only one wondering about how to implement such a feature.

xuesichao commented 2 years ago

@nmonasterio Good to hear that! You must already know that recently we added VoiceFocusProvider, useVoiceFocus hook and AudioInputVFControl to React Component Library to help you quickly enable the Amazon Voice Focus.

In Amazon Chime React Component Library, for now we only support enabling Amazon Voice Focus via MeetingControls - AudioInputVFControl after user join a meeting. The logic of device selection in device setup process (MicSelection component) is similar to the audio device selection in MeetingControls. They both use useAudioInputs hook to get the device list and select a device.

For AudioInputVFControl, I checked the implementation, the key logic here is:

  1. User selects an audio input device from drop down menu
  2. If then user enables the Amazon Voice Focus, AudioInputVFControl uses addVoiceFocus function exposed by useVoiceFocus hook to transform the selected audio device to Amazon Voice Focus device.

Check the code of main logic here and here.

I would highly recommend you to check the implementation of AudioInputVFcontrol. I think you have to implement your own MicSelection component, which follows the similar logic of AudioInputVFControl. I haven't tried this myself, but most likely it should work.

I will bring this up to the team next Monday, to see if we can do something to help the users quickly enable Amazon Voice Focus by default, as well as the Android device echo issue, since you can not reproduce it in the WebRTC sample.

nmonasterio commented 2 years ago

Thank you, @xuesichao. Yes, a normalized API for auto-enabling would be great, especially given the fact that, without it, the state of the VF component might get stale (i.e., the checkbox/label could get out of sync with the actual state of the VF setup) but I'll take a peek at your code paths as well and see where that might lead.

And thank you as well for looking at the Android echo issue. Much appreciated!

xuesichao commented 2 years ago

@nmonasterio I'm trying to find some action items for this issue. Since you are using the React Component Library, would you like to submit a feature request there about the feature you need? This would help us tracking the user need.

For JS SDK repo, do you think a FAQ or how-to doc on how to enable Voice Focus for all devices upon joining the meeting and/or switching devices would help you?

nmonasterio commented 2 years ago

@xuesichao That sounds like a plan. I'll open up a feature request there.

And yes, a how-to on how to do from the JS SDK would suffice for the time being.

Thanks!

kodai305 commented 2 years ago

Am I correct in understanding that the only way to enable VoiceFocus by default is to use the JS SDK? Is manual switching the only way to do this in ReactComponent?