> ## Documentation Index
> Fetch the complete documentation index at: https://docs-classic.cognigy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# captureAudio

> The captureAudio event exposes the raw MediaStream when a remote audio track arrives.

Emitted when the SDK receives a remote audio track. The event is emitted once for each remote audio track. 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.

> [!NOTE]
>
> 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

```typescript theme={null}
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

```typescript theme={null}
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-classic.cognigy.com/click-to-call/sdk/event-reference/audio-ended.md)
* [Custom Audio Handling](https://docs-classic.cognigy.com/click-to-call/sdk/custom-audio.md)
* [Troubleshooting — No Audio](https://docs-classic.cognigy.com/click-to-call/sdk/troubleshooting.md#no-audio)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.