-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
18 lines (16 loc) · 791 Bytes
/
test.py
File metadata and controls
18 lines (16 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
self.device_index = None
for i in range(self.p.get_device_count()):
dev = self.p.get_device_info_by_index(i)
if 'pulse' in dev['name'].lower(): # Check for PulseAudio device
self.device_index = i
print(f"Using PulseAudio device: {dev['name']}")
break
if self.device_index is None:
raise ValueError("No PulseAudio device found.") # Ensure PulseAudio is found
# Open the stream using the PulseAudio device index
self.inStream = self.p.open(format=pyaudio.paInt16,
channels=1,
rate=self.RATE,
input=True,
input_device_index=self.device_index, # Use PulseAudio device index
frames_per_buffer=self.BUFFERSIZE)