Skip to content

Commit cd4999e

Browse files
authored
docs: better Noise Cancellation example (#1502)
Adds concise noise cancellation integration code sample.
1 parent 3f219b2 commit cd4999e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/client/docusaurus/docs/javascript/02-guides/04-noise-cancellation.mdx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ npm install @stream-io/audio-filters-web
2727

2828
## Integration
2929

30-
In the following code snippet, we show how to check if platform is supported, initialize the plugin and enable/disable it.
30+
In the following code snippet, we show how to check if а platform is supported, initialize the plugin, and enable/disable it.
3131

3232
```typescript
3333
import { NoiseCancellation } from '@stream-io/audio-filters-web';
@@ -61,3 +61,19 @@ const off = noiseCancellation.on('change', (v) => {
6161
console.log(`Noise Cancellation is ${v ? 'enabled' : 'disabled'}`);
6262
});
6363
```
64+
65+
In action, the most straight-forward integration should look like this:
66+
67+
```typescript
68+
import { NoiseCancellation } from '@stream-io/audio-filters-web';
69+
70+
const call = client.call(type, id);
71+
await call.get(); // or call.getOrCreate()
72+
73+
const noiseCancellation = new NoiseCancellation();
74+
const isSupported = await noiseCancellation.isSupported();
75+
if (isSupported) {
76+
await noiseCancellation.init();
77+
await call.microphone.enableNoiseCancellation(noiseCancellation);
78+
}
79+
```

0 commit comments

Comments
 (0)