diff --git a/mic_hat_examples/recording_examples/get_device_index.py b/mic_hat_examples/recording_examples/get_device_index.py index d74eed4..71eb9e9 100644 --- a/mic_hat_examples/recording_examples/get_device_index.py +++ b/mic_hat_examples/recording_examples/get_device_index.py @@ -5,7 +5,8 @@ info = p.get_host_api_info_by_index(0) numdevices = info.get('deviceCount') for i in range(0, numdevices): - if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0: - print("Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name')) + currDeviceInfo = p.get_device_info_by_host_api_device_index(0, i) + if (currDeviceInfo.get('maxInputChannels')) > 0: + print("Input Device id ", i, " - ", currDeviceInfo.get('name')) else: - print("Output Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name')) + print("Output Device id ", i, " - ", currDeviceInfo.get('name'))