Refactor microphone selection handling in voice components
- Rename `setSelectedDeviceId` to `selectDevice` in `DebugVoicePanel` and `VoiceSessionControls` for clarity and consistency. - Update `useVoicePreview` hook to implement the `selectDevice` function, enabling dynamic microphone switching during voice sessions. - Enhance device selection logic to support real-time audio track replacement without requiring session reconnection.
This commit is contained in:
@@ -1838,7 +1838,7 @@ function DebugVoicePanel({
|
||||
messages,
|
||||
audioInputs,
|
||||
selectedDeviceId,
|
||||
setSelectedDeviceId,
|
||||
selectDevice,
|
||||
sendText,
|
||||
connect,
|
||||
disconnect,
|
||||
@@ -1868,7 +1868,7 @@ function DebugVoicePanel({
|
||||
assistantId={assistantId}
|
||||
audioInputs={audioInputs}
|
||||
selectedDeviceId={selectedDeviceId}
|
||||
setSelectedDeviceId={setSelectedDeviceId}
|
||||
selectDevice={selectDevice}
|
||||
connect={connect}
|
||||
disconnect={disconnect}
|
||||
/>
|
||||
@@ -1941,9 +1941,8 @@ function DebugVoicePanel({
|
||||
<Select
|
||||
value={selectedDeviceId || "default"}
|
||||
onValueChange={(value) =>
|
||||
setSelectedDeviceId(value === "default" ? "" : value)
|
||||
selectDevice(value === "default" ? "" : value)
|
||||
}
|
||||
disabled={recording}
|
||||
>
|
||||
<SelectTrigger
|
||||
size="sm"
|
||||
@@ -2044,7 +2043,7 @@ function VoiceSessionControls({
|
||||
assistantId,
|
||||
audioInputs,
|
||||
selectedDeviceId,
|
||||
setSelectedDeviceId,
|
||||
selectDevice,
|
||||
connect,
|
||||
disconnect,
|
||||
}: {
|
||||
@@ -2054,7 +2053,7 @@ function VoiceSessionControls({
|
||||
assistantId: string | null;
|
||||
audioInputs: MediaDeviceInfo[];
|
||||
selectedDeviceId: string;
|
||||
setSelectedDeviceId: (deviceId: string) => void;
|
||||
selectDevice: (deviceId: string) => void;
|
||||
connect: () => Promise<void>;
|
||||
disconnect: () => void;
|
||||
}) {
|
||||
@@ -2096,9 +2095,8 @@ function VoiceSessionControls({
|
||||
<Select
|
||||
value={selectedDeviceId || "default"}
|
||||
onValueChange={(value) =>
|
||||
setSelectedDeviceId(value === "default" ? "" : value)
|
||||
selectDevice(value === "default" ? "" : value)
|
||||
}
|
||||
disabled={recording}
|
||||
>
|
||||
<SelectTrigger
|
||||
size="sm"
|
||||
|
||||
Reference in New Issue
Block a user