Options
All
  • Public
  • Public/Protected
  • All
Menu

Class VoiceFocusDeviceTransformer

VoiceFocusDeviceTransformer is used to create transform devices that apply Amazon Voice Focus noise suppression to audio input.

This transformer captures relevant configuration. You should check for support, initialize, and then create a device as follows:

const deviceID = null;

// This check for support is cheap and quick, and should be used to gate use
// of this feature.
if (!(await VoiceFocusDeviceTransformer.isSupported()) {
  console.log('Amazon Voice Focus not supported in this browser.');
  return deviceID;
}

let transformer: VoiceFocusDeviceTransformer;
try {
  // This operation can fail in ways that do not indicate no support,
  // but do indicate an inability to apply Amazon Voice Focus. Trying again
  // might succeed.
  transformer = await VoiceFocusDeviceTransformer.create({});
} catch (e) {
  // Something went wrong.
  console.log('Unable to instantiate Amazon Voice Focus.');
  return deviceID;
}

if (!transformer.isSupported()) {
  // The transformer will fall through, but your UI might care.
  console.log('Amazon Voice Focus not supported in this browser.');
}

return await transformer.createTransformDevice(deviceID);

Hierarchy

  • VoiceFocusDeviceTransformer

Index

Constructors

Private constructor

  • new VoiceFocusDeviceTransformer(spec: VoiceFocusSpec, __namedParameters: { fetchBehavior: VoiceFocusFetchBehavior; logger: Logger; preload: boolean }, config: VoiceFocusConfig | undefined): VoiceFocusDeviceTransformer

Properties

Private configuration

configuration: Promise<VoiceFocusConfig>

Private fetchBehavior

fetchBehavior: VoiceFocusFetchBehavior

Private logger

logger: Logger

Private pendingVoiceFocus

pendingVoiceFocus: Promise<[VoiceFocus, VoiceFocusTransformDeviceDelegate]>

Private preload

preload: boolean

Private spec

spec: VoiceFocusSpec

Private supported

supported: boolean = true

Private vfLogger

vfLogger: VoiceFocusLogger

Methods

Private allocateVoiceFocus

  • allocateVoiceFocus(preload: boolean): Promise<[VoiceFocus, VoiceFocusTransformDeviceDelegate]>

Private configure

  • configure(preResolve?: boolean): Promise<VoiceFocusConfig>

createTransformDevice

  • Apply Amazon Voice Focus to the selected Device.

    If this is a stream, it should be one that does not include other noise suppression features, and you should consider whether to disable automatic gain control (AGC) on the stream, because it can interact with noise suppression.

    Parameters

    • device: Device
    • Optional nodeOptions: NodeArguments

    Returns Promise<VoiceFocusTransformDevice | undefined>

    a device promise. This will always resolve to either a VoiceFocusTransformDevice or undefined; it will never reject.

Private createVoiceFocus

  • createVoiceFocus(config: VoiceFocusConfig, preload: boolean): Promise<[VoiceFocus, VoiceFocusTransformDeviceDelegate]>

getConfiguration

  • getConfiguration(): Promise<VoiceFocusConfig>

Private init

  • init(): Promise<void>

isSupported

  • isSupported(): boolean

Static Private augmentSpec

  • augmentSpec(spec: VoiceFocusSpec): VoiceFocusSpec

Static configure

  • Given a spec and options, perform the configuration work that is ordinarily performed during creation of a transformer.

    The computed configuration is not portable between devices or sessions, but is useful for 'moving' transformers between windows.

    Pass the returned configuration as the third argument to a call to VoiceFocusDeviceTransformer.create with the matching spec.

    Parameters

    Returns Promise<VoiceFocusConfig>

Static create

  • Create a transformer that can apply Amazon Voice Focus noise suppression to a device.

    This method will reject if the provided spec is invalid, or if the process of checking for support or estimating fails (e.g., because the network is unreachable).

    If Amazon Voice Focus is not supported on this device, this call will not reject and isSupported() will return false on the returned instance. That instance will pass through devices unmodified.

    Parameters

    • Default value spec: VoiceFocusSpec = {}

      A definition of how you want Amazon Voice Focus to behave. See the declaration of {@link VoiceFocusSpec}` for details.

    • Default value options: VoiceFocusDeviceOptions = {}

      Additional named arguments, including logger and preload.

    • Optional config: VoiceFocusConfig

    Returns Promise<VoiceFocusDeviceTransformer>

Static Private currentSDKAssetGroup

  • currentSDKAssetGroup(): string

Static Private defaultFetchBehavior

  • defaultFetchBehavior(): VoiceFocusFetchBehavior

Static isSupported

  • isSupported(spec?: AssetSpec & { paths?: VoiceFocusPaths }, options?: { logger?: Logger }): Promise<boolean>
  • Quickly check whether Amazon Voice Focus is supported on this platform.

    This will return false if key technologies are absent. A value of true does not necessarily mean that adding Amazon Voice Focus will succeed: it is still possible that the configuration of the page or the CPU speed of the device are limiting factors.

    VoiceFocusDeviceTransformer.create will return an instance whose isSupported() method more accurately reflects whether Amazon Voice Focus is supported in the current environment.

    This method will only reject if you provide invalid inputs.

    Parameters

    • Optional spec: AssetSpec & { paths?: VoiceFocusPaths }

      An optional asset group and URL paths to use when fetching. You can pass a complete VoiceFocusSpec here for convenience, matching the signature of create.

    • Optional options: { logger?: Logger }

      Additional named arguments, including logger.

    Returns Promise<boolean>

Static Private majorMinorVersion

  • majorMinorVersion(): string

Static Private majorVersion

  • majorVersion(): string

Generated using TypeDoc