AttributeError: 'NoneType' object has no attribute 'getSamplingRate'

I get the same error. Did some digging, and the short version is that it’s an issue with psychopy’s microphone class, not your code.

The microphone code is trying to create a pyo server and silently failing, even though it’s successfully importing pyo. Basically “switchOn” tries to create a pyo server using sound.init(), and that server never actually gets created. I don’t know enough about pyo or how this class is put together to recommend a fix.

It could possibly be an OS issue. I’m on MacOS Sierra, are you also on Mac?