Windows-only CLI to list and switch audio input/output devices using the Core Audio APIs.
- Windows
- Go 1.22+
go build -o win-audio-cli.exeList devices as JSON (separate input/output lists):
./win-audio-cli.exe list --jsonSwitch the default output device (all roles):
./win-audio-cli.exe switch-output --id "{device-id}"
./win-audio-cli.exe switch-output --name "Speakers (Realtek(R) Audio)"Switch the default input device (all roles):
./win-audio-cli.exe switch-input --id "{device-id}"
./win-audio-cli.exe switch-input --name "Microphone (USB Audio Device)"Set the communication output device (communications role only):
./win-audio-cli.exe switch-output-communication --id "{device-id}"
./win-audio-cli.exe switch-output-communication --name "Headset (Bluetooth Hands-Free)"Set the communication input device (communications role only):
./win-audio-cli.exe switch-input-communication --id "{device-id}"
./win-audio-cli.exe switch-input-communication --name "Headset Microphone (Bluetooth Hands-Free)"If device names are not unique, use --id.
list --json returns:
{
"inputs": [
{
"id": "...",
"name": "...",
"isDefault": true,
"isDefaultCom": false
}
],
"outputs": [
{
"id": "...",
"name": "...",
"isDefault": false,
"isDefaultCom": true
}
]
}switch-output / switch-input returns:
{
"type": "output",
"device": {
"id": "...",
"name": "...",
"isDefault": true,
"isDefaultCom": true
}
}Built with:
MIT License - See LICENSE for details.