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

Hi guys,

The following very basic script crashes on PsychoPy 1.85.2:

from psychopy import microphone
mic = microphone.AdvAudioCapture(stereo=False)

The console output is:

pyo version 0.8.0 (uses single precision)
Traceback (most recent call last):
  File "P:\combined\", line 4, in <module>
    mic = microphone.AdvAudioCapture(stereo=False)
  File "P:\PsychoPy2\lib\site-packages\psychopy\", line 357, in __i
  File "P:\PsychoPy2\lib\site-packages\psychopy\", line 402, in set
    sampleRate = sound.pyoSndServer.getSamplingRate()
AttributeError: 'NoneType' object has no attribute 'getSamplingRate'
portaudio error in Pa_AbortStream: Unanticipated host error

Any idea what I’m doing wrong?

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?

No, I’m on Windows 7 x64. But thanks for checking into this! I did recently find this workaround, in case it helps you: Voice capture crashes, which basically suggests replacing these calls with the actual sampling rate.

The strange thing is, it seems that the pyo server has been created successfully, because it prints its hello message at the top of the traceback, and after patching out the calls to this one specific function, recording works fine. Well, in any case, I guess this is a bug in PsychoPy, then…

Hi @LostLinguist,

Has your problem solved? I am having the same problem as well. Not sure if it’s the software or the audio interface.

Unfortunately, our lab computers were upgraded and pyo (and hence PsychoPy) stopped working altogether, which meant I had to move to ePrime. I have not been able to solve this problem beyond the workaround mentioned in the previous post.

@LostLinguist I see. Thank you!