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

# captureAudio

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.

<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.
</Note>

## 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](/click-to-call/sdk/event-reference/audio-ended)
* [Custom Audio Handling](/click-to-call/sdk/custom-audio)
* [Troubleshooting — No Audio](/click-to-call/sdk/troubleshooting#no-audio)
