Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

browserMicrophones.ts

11 lines415 Bytes

1export type BrowserMicrophone = Pick<MediaDeviceInfo, "deviceId" | "label">;
2​
3export async function listBrowserMicrophones(): Promise<BrowserMicrophone[]> {
4 const devices = await navigator.mediaDevices.enumerateDevices();
5 return devices
6 .filter((device) => device.kind === "audioinput")
7 .map(({ deviceId, label }, index) => ({
8 deviceId,
9 label: label || `Microphone ${index + 1}`,
10 }));