31 lines
798 B
Python
31 lines
798 B
Python
import pyaudio
|
|
|
|
p = pyaudio.PyAudio()
|
|
|
|
# List devices to find the correct index for your AUX port
|
|
for i in range(p.get_device_count()):
|
|
dev_info = p.get_device_info_by_index(i)
|
|
print(f"Index: {i}, Name: {dev_info['name']}, Input Channels: {dev_info['maxInputChannels']}")
|
|
|
|
## Open stream with the specific device index
|
|
#device_index = 1 # Replace with your AUX port's index
|
|
#stream = p.open(
|
|
# format=pyaudio.paInt16,
|
|
# channels=1,
|
|
# rate=44100,
|
|
# input=True,
|
|
# input_device_index=device_index,
|
|
# frames_per_buffer=1024
|
|
#)
|
|
#
|
|
#print("Recording...")
|
|
#frames = []
|
|
#for _ in range(0, int(44100 / 1024 * 5)): # Record for 5 seconds
|
|
# data = stream.read(1024)
|
|
# frames.append(data)
|
|
#
|
|
#stream.stop_stream()
|
|
#stream.close()
|
|
#p.terminate()
|
|
#print("Recording finished.")
|