Skip to content

Commit 16d1ac7

Browse files
authored
update 6
1 parent b58010f commit 16d1ac7

File tree

1 file changed

+51
-29
lines changed
  • articles/communication-services/tutorials/audio-quality-enhancements/includes

1 file changed

+51
-29
lines changed

articles/communication-services/tutorials/audio-quality-enhancements/includes/web.md

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Use the `npm install` command to install the Azure Communication Services Audio
4949
@azure/communication-calling-effects/v/latest
5050
```
5151

52-
If you use the **public preview** of the Calling SDK, you must use the [beta version](https://www.npmjs.com/package/@azure/communication-calling-effects/v/next) of the Calling Effects SDK.
52+
If you use the **public preview** of the Calling SDK, you must use the [beta version](https://www.npmjs.com/package/@azure/communication-calling-effects/v/next) of the Calling Effects SDK. Use the `npm install` command to install the Azure Communication Services Audio Effects SDK for JavaScript.
5353

5454
```console
5555
@azure/communication-calling-effects/v/next
@@ -60,25 +60,35 @@ For information on the interface that details audio effects properties and metho
6060

6161

6262
### Initialize the Audio Effects Feature
63-
To use noise suppression audio effects within the Azure Communication Services Calling SDK, you need the `LocalAudioStream` property that's currently in the call. You need access to the `AudioEffects` API of the `LocalAudioStream` property to start and stop audio effects.
64-
```js
65-
import { createAzureCommunicationCallingWithAudioEffects } from '@azure/communication-calling-effects';
66-
67-
const callClient = createAzureCommunicationCallingWithAudioEffects();
68-
```
69-
This wraps the standard CallClient with audio effects capabilities.
63+
To use audio effects within the Azure Communication Services Calling SDK, you need the `LocalAudioStream` property that's currently in the call. You need access to the `AudioEffects` API of the `LocalAudioStream` property to start and stop audio effects.
7064

7165
### Enable Noise Suppression
7266
The following code snippet shows an example on how to enable **noise suppression** from within the Webjs environment.
7367
```js
74-
const deviceManager = await callClient.getDeviceManager();
75-
await deviceManager.askDevicePermission({ audio: true });
68+
import * as AzureCommunicationCallingSDK from '@azure/communication-calling';
69+
import { DeepNoiseSuppressionEffect } from '@azure/communication-calling-effects';
7670

77-
const selectedMicrophone = (await deviceManager.getMicrophones())[0];
78-
const audioEffects = await deviceManager.createAudioEffects(selectedMicrophone);
71+
// Get LocalAudioStream from the localAudioStream collection on the call object.
72+
// 'call' here represents the call object.
73+
const localAudioStreamInCall = call.localAudioStreams[0];
74+
75+
// Get the audio effects feature API from LocalAudioStream
76+
const audioEffectsFeatureApi = localAudioStreamInCall.feature(AzureCommunicationCallingSDK.Features.AudioEffects);
7977

80-
// Enable noise suppression
81-
await audioEffects.setFeature({ featureName: 'noiseSuppression', enabled: true });
78+
// Subscribe to useful events that show audio effects status
79+
audioEffectsFeatureApi.on('effectsStarted', (activeEffects: ActiveAudioEffects) => {
80+
console.log(`Current status audio effects: ${activeEffects}`);
81+
});
82+
83+
84+
audioEffectsFeatureApi.on('effectsStopped', (activeEffects: ActiveAudioEffects) => {
85+
console.log(`Current status audio effects: ${activeEffects}`);
86+
});
87+
88+
89+
audioEffectsFeatureApi.on('effectsError', (error: AudioEffectErrorPayload) => {
90+
console.log(`Error with audio effects: ${error.message}`);
91+
});
8292
```
8393
### Enable Echo Cancellation
8494
The following code snippet shows an example on how to enable **echo cancellation** from within the Webjs environment.
@@ -170,29 +180,31 @@ await audioEffectsFeatureApi.stopEffects({
170180
noiseSuppression: true
171181
});
172182
```
173-
### To start or stop audio effects packages during a call
174-
To start Azure Communication Services Deep Noise Suppression
183+
### To start or stop audio effects packages during an active call
184+
You might start a call and not have noise suppression turned on. The end users room might get noisy so that they would need to turn on noise suppression. To turn on noise suppression, you can use the `audioEffectsFeatureApi.startEffects` AP
185+
186+
#### To start Azure Communication Services Noise Suppression
175187
```js
176188
await audioEffectsFeatureApi.startEffects({
177189
noiseSuppression: deepNoiseSuppression
178190
});
179191
```
180192

181-
To stop Azure Communication Services Deep Noise Suppression
193+
#### To stop Azure Communication Services Deep Noise Suppression
182194
```js
183195
await audioEffectsFeatureApi.stopEffects({
184196
noiseSuppression: true
185197
});
186198
```
187199

188-
To start Azure Communication Services echo cancelation
200+
#### To start Azure Communication Services echo cancelation
189201
```js
190202
await audioEffectsFeatureApi.startEffects({
191203
noiseSuppression: echoCancellation
192204
});
193205
```
194206

195-
To stop Azure Communication Services echo cancelation
207+
#### To stop Azure Communication Services echo cancelation
196208
```js
197209
await audioEffectsFeatureApi.stopEffects({
198210
echoCancellation: true
@@ -203,18 +215,28 @@ await audioEffectsFeatureApi.stopEffects({
203215
To check what noise suppression effects are currently active, you can use the `activeEffects` property. The `activeEffects` property returns an object with the names of the current active effects.
204216

205217
```js
206-
// Use the audio effects feature API.
207-
const currentActiveEffects = audioEffectsFeatureApi.activeEffects;
218+
import { EchoCancellationEffect, DeepNoiseSuppressionEffect } from '@azure/communication-calling-effects';
219+
// Get LocalAudioStream from the localAudioStream collection on the call object.
220+
// 'call' here represents the call object.
221+
const localAudioStreamInCall = call.localAudioStreams[0];
208222

209-
// Create the noise suppression instance.
210-
const deepNoiseSuppression = new DeepNoiseSuppressionEffect();
211-
// We recommend that you check support for the effect in the current environment by using the isSupported API
212-
// method. Remember that noise suppression is only supported on desktop browsers for Chrome and Edge.
223+
// Get the audio effects feature API from LocalAudioStream
224+
const audioEffectsFeatureApi = localAudioStreamInCall.feature(AzureCommunicationCallingSDK.Features.AudioEffects);
213225

214-
const isDeepNoiseSuppressionSupported = await audioEffectsFeatureApi.isSupported(deepNoiseSuppression);
215-
if (isDeepNoiseSuppressionSupported) {
216-
console.log('Noise suppression is supported in local browser environment');
217-
}
226+
// Subscribe to useful events that show audio effects status
227+
audioEffectsFeatureApi.on('effectsStarted', (activeEffects: ActiveAudioEffects) => {
228+
console.log(`Current status audio effects: ${activeEffects}`);
229+
});
230+
231+
232+
audioEffectsFeatureApi.on('effectsStopped', (activeEffects: ActiveAudioEffects) => {
233+
console.log(`Current status audio effects: ${activeEffects}`);
234+
});
235+
236+
237+
audioEffectsFeatureApi.on('effectsError', (error: AudioEffectErrorPayload) => {
238+
console.log(`Error with audio effects: ${error.message}`);
239+
});
218240
```
219241
## Best Practices
220242
The Azure Communication Services WebJS audio effects package provides tools for reducing unwanted sounds. Other measures can be taken to improve audio quality, such as:

0 commit comments

Comments
 (0)