Tuning.py is not working with current versions of python

richhyde@HWD-LT-RHyde usb_4_mic_array % python3 tuning.py -r
name value

array(‘B’, [0, 0, 0, 0, 229, 63, 219, 33])
Traceback (most recent call last):
File “/Users/richhyde/Documents/Seeed/usb_4_mic_array/tuning.py”, line 197, in
main()
File “/Users/richhyde/Documents/Seeed/usb_4_mic_array/tuning.py”, line 181, in main
print(’{:24} {}’.format(name, dev.read(name)))
File “/Users/richhyde/Documents/Seeed/usb_4_mic_array/tuning.py”, line 110, in read
response = struct.unpack(b’ii’, response.tostring())
AttributeError: ‘array.array’ object has no attribute ‘tostring’
richhyde@HWD-LT-RHyde usb_4_mic_array % python3 --version
Python 3.9.1

usb_4_mic_array % python3 tuning.py AGCGAIN
array(‘B’, [212, 55, 165, 84, 227, 255, 255, 255])
Traceback (most recent call last):
File “/Users/richhyde/Documents/Seeed/usb_4_mic_array/tuning.py”, line 197, in
main()
File “/Users/richhyde/Documents/Seeed/usb_4_mic_array/tuning.py”, line 188, in main
print(’{}: {}’.format(name, dev.read(name)))
File “/Users/richhyde/Documents/Seeed/usb_4_mic_array/tuning.py”, line 110, in read
response = struct.unpack(b’ii’, response.tostring())
AttributeError: ‘array.array’ object has no attribute ‘tostring’
richhyde@HWD-LT-RHyde usb_4_mic_array %

Hey Rich,

have a look here there is just one line that python 3.9 does not like.

Just replace the .tostring() with .tobytes() in line 110. See if that works.

Best
David

Hi David,
THANK YOU VERY MUCH for your great work!
This little but important fix ist GREAT!
Now I am able to talk on my Mac with python3 with the ReSpeaker Mic Array v2.0
All the best
Florian

I fixed this and a couple of other small issues and made a pull request a while ago but not sure if they accepted it!