Implement microphone selection feature in voice preview
- Add audio input selection to DebugVoicePanel, allowing users to choose their microphone device. - Update useVoicePreview hook to manage available audio inputs and selected device state. - Enhance device enumeration and selection handling to ensure a seamless user experience during voice interactions.
This commit is contained in:
@@ -1857,6 +1857,9 @@ function DebugVoicePanel({
|
||||
micWarning,
|
||||
localStream,
|
||||
messages,
|
||||
audioInputs,
|
||||
selectedDeviceId,
|
||||
setSelectedDeviceId,
|
||||
sendText,
|
||||
connect,
|
||||
disconnect,
|
||||
@@ -1942,6 +1945,33 @@ function DebugVoicePanel({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="relative w-full max-w-xs">
|
||||
<Select
|
||||
value={selectedDeviceId || "default"}
|
||||
onValueChange={(value) =>
|
||||
setSelectedDeviceId(value === "default" ? "" : value)
|
||||
}
|
||||
disabled={recording}
|
||||
>
|
||||
<SelectTrigger
|
||||
size="sm"
|
||||
className="w-full justify-center gap-2 rounded-full border-hairline bg-canvas-soft text-xs text-muted-foreground"
|
||||
aria-label="选择麦克风"
|
||||
>
|
||||
<Mic size={13} className="shrink-0 text-muted-soft" />
|
||||
<SelectValue placeholder="默认麦克风" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="default">默认麦克风</SelectItem>
|
||||
{audioInputs.map((device, index) => (
|
||||
<SelectItem key={device.deviceId} value={device.deviceId}>
|
||||
{device.label || `麦克风 ${index + 1}`}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
disabled={!assistantId || status === "connecting"}
|
||||
onClick={() => {
|
||||
|
||||
Reference in New Issue
Block a user