From 66295f5177d8e30c134e72141cbffddbcba84c0b Mon Sep 17 00:00:00 2001 From: egg Date: Wed, 17 Dec 2025 17:34:34 +0800 Subject: [PATCH] fix: Filter out Stereo Mix and select real microphone device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Filter out "立體聲混音" (Stereo Mix) devices which are not real microphones - Skip the "default" device which may point to Stereo Mix - Prefer "communications" device or devices with "麥克風/microphone" in label - Use exact deviceId constraint for better device selection - Add fallback to preferred constraint if exact fails - Add more detailed console logging for debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitignore | 1 + client/src/pages/meeting-detail.html | 37 +++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 839a464..a1a4bf3 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ backend/record/ openspec/ AGENTS.md CLAUDE.md +.running_pids diff --git a/client/src/pages/meeting-detail.html b/client/src/pages/meeting-detail.html index 1fe6157..2699fb5 100644 --- a/client/src/pages/meeting-detail.html +++ b/client/src/pages/meeting-detail.html @@ -415,14 +415,39 @@ return; } - // Try with simple constraints first, fall back to more specific ones + // Filter out Stereo Mix (立體聲混音) - it's not a real microphone + const realMicrophones = audioInputs.filter(d => + !d.label.includes('立體聲混音') && + !d.label.toLowerCase().includes('stereo mix') && + d.deviceId !== 'default' // Skip default which might be Stereo Mix + ); + + // Prefer communications device or actual microphone + let selectedMic = realMicrophones.find(d => + d.deviceId === 'communications' || + d.label.includes('麥克風') || + d.label.toLowerCase().includes('microphone') + ) || realMicrophones[0]; + + console.log('Real microphones found:', realMicrophones.length); + console.log('Selected microphone:', selectedMic); + + if (!selectedMic) { + alert('No real microphone found. Only Stereo Mix detected. Please connect a microphone.'); + return; + } + + // Try with the selected microphone try { - mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true }); - } catch (simpleErr) { - console.warn('Simple audio constraints failed, trying with device ID:', simpleErr); - // Try with explicit device ID mediaStream = await navigator.mediaDevices.getUserMedia({ - audio: { deviceId: audioInputs[0].deviceId } + audio: { deviceId: { exact: selectedMic.deviceId } } + }); + console.log('Successfully connected to:', selectedMic.label); + } catch (exactErr) { + console.warn('Exact device ID failed, trying preferred:', exactErr); + // Fallback: try with preferred instead of exact + mediaStream = await navigator.mediaDevices.getUserMedia({ + audio: { deviceId: selectedMic.deviceId } }); }