Examples on ReSpeaker wiki page do not work

Regarding the wiki at ReSpeaker USB Mic Array | Seeed Studio Wiki, none of the python examples work. They all generate this error backtrace:

Traceback (most recent call last):
File “/home/m/usb_4_mic_array/tuning.py”, line 197, in
main()
File “/home/m/usb_4_mic_array/tuning.py”, line 188, in main
print(’{}: {}’.format(name, dev.read(name)))
^^^^^^^^^^^^^^
File “/home/m/usb_4_mic_array/tuning.py”, line 109, in read
response = struct.unpack(b’ii’, response.tostring())
^^^^^^^^^^^^^^^^^
AttributeError: ‘array.array’ object has no attribute ‘tostring’

Also, some of the examples use the print call as in:

print Mic_tuning.direction

I believe this needs to be:

print Mic_tuning.direction()

Any ideas?

Bump?
Has anyone else got this to work?
These errors seem to me to be show stoppers.

Hi there,
What version of Python?
have a look at the Libs from the maker…which versions of Mic_array are you using?
just saying the demo’s on the Wiki don’t work , really is not much to go by…
Have you preformed all the initialization steps in the WiKi?, i.e. Libusb driver install?
Can you provide more info as to what you have done and where the problems start?
Post up more info and others who have it working will reply, if you are using the examples exactly as posted then BE SURE to setup the device and environment the SAME in order to get them going first , after which you can upgrade the pieces and get where you need.
HTH
GL :slight_smile: PJ

Hi

This is caused by using a current version of python that no longer supports the tostring method

More details at Tuning.py (AttributeError: 'array.array' object has no attribute 'tostring') · Issue #49 · respeaker/usb_4_mic_array · GitHub

Basically you need to replace any mention of tostring to tobytes in the code you use then it will start working

1 Like