## Documentation Index

Fetch the complete documentation index at: [/llms.txt](https://docs.cognigy.com/llms.txt)

Use this file to discover all available pages before exploring further.

Emitted when the SDK receives a remote audio stream and audio playback begins. This event exposes the raw `MediaStream` for advanced audio processing such as visualization, recording, or custom routing. This event is opt-in. To enable it, set `captureAudio: true` in the client configuration.

The SDK plays remote audio automatically via an internal `Audio` element. You don’t need to handle the `captureAudio` event for basic playback — it’s only needed for advanced use cases.

## Category

Audio

## Callback Parameters

| Parameter | Type | Description |  
| --- | --- | --- |  
| `stream` | `MediaStream` | The remote audio stream. |

## Example

```
const client = await createWebRTCClient({
  endpointUrl: 'https://your-cognigy-environment.com/token',
  userId: 'user-123',
  captureAudio: true,
});

client.on('captureAudio', (stream) => {
  console.log('Audio stream available:', stream.getAudioTracks());
});
```

### Advanced: Audio Processing with Web Audio API

```
client.on('captureAudio', (stream) => {
  const audioContext = new AudioContext();
  const source = audioContext.createMediaStreamSource(stream);

const analyser = audioContext.createAnalyser();
  source.connect(analyser);
  // Don't connect to destination — the SDK already handles playback
});
```

## More Information

- [audioEnded](https://docs.cognigy.com/click-to-call/sdk/event-reference/audio-ended)
- [Custom Audio Handling](https://docs.cognigy.com/click-to-call/sdk/custom-audio)
- [Troubleshooting — No Audio](https://docs.cognigy.com/click-to-call/sdk/troubleshooting#no-audio)

Last modified on April 21, 2026
