deviceId so ambient recording uses the mic your user picks. Your app lists devices, builds the picker UI, and keeps the selected id in app state.
Pass that deviceId through config.audio.deviceId on useAmbientSession, or through the same audio option on Platform Client start and resume. The Headless Web SDK opens capture on that device when you call start() or resume(), and does not list microphones, remember the last choice, or switch mics for you. When a session is paused, pass the same deviceId again on resume so capture continues on that microphone.
When you omit
deviceId, recording uses the browser default microphone.When you pass a deviceId
The selected microphone is applied only when audio capture starts:There is no option to switch the microphone mid-session. Pause, then resume with the new
deviceId.- Update your app state with the new
deviceIdsoconfig.audio.deviceIdis current. - Call
pause() - Call
resume()
Pass deviceId to the hook
Types
The following types show the options you can pass to the hook:deviceId is set, the recording uses getUserMedia with:
deviceId is omitted, the browser default microphone is used.
Enumerate devices and select a microphone
You own device enumeration and how you design and implement the microphone picker UI. Request microphone permission before you enumerate if you need readable device labels in Chromium. Changing the microphone while recording is active does not switch the microphone in use. First pause, then resume so the new device is applied. The following code example shows how to enumerate devices and select a microphone while using the Headless Web SDK.What your app handles
- List microphones in your app with
enumerateDevices(), and keep onlyaudioinputdevices. The SDK does not list them for you. - Ask for microphone permission before you list devices if you need the names to be readable.
- Save the chosen
deviceIdin your app. The SDK keeps it in memory only and does not save it to IndexedDB. Passconfig.audioagain after a page reload, an SDK remount, or session recovery. - If the user picks a new microphone while recording, the current microphone stays in use until you call
pause(), thenresume(). The hook may log a warning until thatresume()succeeds.
When the device is unavailable
When you pass an exactdeviceId and that device is missing, disconnected, or otherwise unavailable, getUserMedia fails. The Headless Web SDK does not automatically fall back to the browser default microphone.
Mic capture failures are not a top-level AudioRecorderFailure error. They are wrapped as session lifecycle errors:
Platform Client
You receive a structured error with
code, reason, and cause. cause is the browser microphone error from getUserMedia.React Hook
start() and resume() throw a string, not an object with error.code and error.reason.start() or resume() again. Starting a session and Resuming a session list the same code and reason.
Example code: Handle start failure
startAmbientSession / resumeAmbientSession) option retention, including { audio: undefined } to clear a previous in-memory selection, refer to Platform client and provider.
Partner checklist
See all the checklist items
See all the checklist items
- Enumerate
audioinputdevices in your app. - Store the selected
deviceIdin your app state. - Pass it through
useAmbientSessionconfig.audioor Platform start/resume options. - On mic change during an active recording, pause then resume.
- Re-supply
deviceIdafter remount or recovery. - Handle start/resume failures when the selected device is unavailable.
- Do not expect the microphone to change while recording is active, and do not expect a
switchMicrophoneAPI in this release.
Microphone FAQs
Does Changing the Dropdown While Recording Switch the Mic Immediately?
Does Changing the Dropdown While Recording Switch the Mic Immediately?
No. The microphone that is already recording does not change. Pause, then resume with the new
deviceId.Will the SDK Remember the Selected Mic After a Page Reload?
Will the SDK Remember the Selected Mic After a Page Reload?
No. Selection is in-memory only. Persist the preference in your app if needed, then pass it again on start/resume after remount.
What Happens If the Selected Device Is Unplugged?
What Happens If the Selected Device Is Unplugged?
Start or resume fails. The SDK does not fall back to another microphone automatically. The error uses
code: "StartSessionFailed" or code: "ResumeSessionFailed" with reason: "AudioRecorderFailure". On React, you may receive that information as a string from error.toString().Is Form Filling Covered?
Is Form Filling Covered?
No. Form filling
deviceId support is out of scope for this release.Is There a switchMicrophone API?
Is There a switchMicrophone API?
Not in this release. Use pause → resume with the new
deviceId.Limitations
- You cannot change the active microphone while recording is running. Pause, then resume with the new
deviceId. - There is no public
switchMicrophone(deviceId)API in this release. - The SDK does not enumerate microphones or persist the user’s last choice. Your app owns listing, picker UI, and storage.
- When an exact
deviceIdis missing or unavailable, the SDK does not fall back to the browser default microphone. - You cannot pass an external
MediaStreamas the audio source. - Form filling microphone selection is out of scope for this release.