> For the complete documentation index, see [llms.txt](https://docs.digitalsamba.com/reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digitalsamba.com/reference/sdk/methods/toggleaudio.md).

# toggleAudio()

Toggles user's microphone state.

If the microphone is currently enabled, then it will be disabled. And vice-versa -> if the microphone is currently disabled, then it will be enabled. There is also an optional param to set a concrete target microphone state, but you may use [disableAudio()](/reference/sdk/methods/disableaudio.md) and [enableAudio()](/reference/sdk/methods/enableaudio.md) to achieve similar functionality.

```javascript
//This will toggle the microphone state
sambaFrame.toggleAudio();

//This will enable the microphone, equivalent to sambaFrame.enableAudio();
sambaFrame.toggleAudio(true); 

//This will disable the microphone, equivalent to sambaFrame.disableAudio();
sambaFrame.toggleAudio(false);
```

**Sample use case**: \
Have a custom toolbar in your integration and want user to control microphone from it.
