Add microphone picker and device management features
- Implement `list_input_devices` to retrieve and filter input-capable audio devices. - Create `MicPickerDialog` for selecting and saving microphone settings. - Add `set_env_value` function to update .env file with selected microphone index. - Update UI components to integrate microphone selection functionality. - Enhance tests for microphone device handling and environment variable management.
This commit is contained in:
@@ -100,6 +100,32 @@ def test_returns_none_when_should_continue_stops_before_speech():
|
||||
assert result is None
|
||||
|
||||
|
||||
def test_list_input_devices_filters_to_input_capable(monkeypatch):
|
||||
fake_devices = [
|
||||
{"name": "Speakers", "max_input_channels": 0, "hostapi": 0},
|
||||
{"name": "USB Mic", "max_input_channels": 2, "hostapi": 0},
|
||||
{"name": "Line In", "max_input_channels": 1, "hostapi": 1},
|
||||
]
|
||||
fake_hostapis = [{"name": "MME"}, {"name": "WASAPI"}]
|
||||
|
||||
class _FakeSoundDevice:
|
||||
@staticmethod
|
||||
def query_devices():
|
||||
return fake_devices
|
||||
|
||||
@staticmethod
|
||||
def query_hostapis(index):
|
||||
return fake_hostapis[index]
|
||||
|
||||
monkeypatch.setitem(sys.modules, "sounddevice", _FakeSoundDevice())
|
||||
|
||||
devices = mic.list_input_devices()
|
||||
assert devices == [
|
||||
{"index": 1, "name": "USB Mic", "hostapi": "MME"},
|
||||
{"index": 2, "name": "Line In", "hostapi": "WASAPI"},
|
||||
]
|
||||
|
||||
|
||||
def test_pcm_to_wav_bytes_round_trips_via_wave_module():
|
||||
import wave
|
||||
import io
|
||||
|
||||
Reference in New Issue
Block a user