Python.exe has stopped working during recording

I’m currently working on an experiment that has either no recordings and plays sound or plays sound and sometimes sound is recorded. The experiment works just fine without the microphone (and I’ve replicated using other experiments) but it crashes every time, at varying points throughout the experiment. It seems to be related to how long the recordings have been going on for.

I am using Psychopy 3.2.3 on Windows 10 with the following hardware specifications:

audio library: ['pygame'] (anything else led to horrible echoes in the audio stims)
audio driver: ['pyo']
audio device: Primary Sound Driver

Currently the microphone is called with the following code:

microphone.switchOn(sampleRate=16000)
mic_ = microphone.AudioCapture()
mic_.record(360, recname, block=False)
while mic_.recorder_running:
    if 'return' in event.getKeys():
        reaction = timer2.getTime()
        core.wait(1)
        mic_.stop()
mic_.reset()

Any ideas? I think it must be related to the buffer but am really unsure how to clear it or what to do with the mic_ object to allow recording until a keypress.

ETA: I played around a bit with importing things in the shell and found out that the microphone is returning NoneType? So I tried making changes to microphone.py from here: https://github.com/psychopy/psychopy/commit/68df98967d491a70f2c002ba372bdf1419e1fc86

ETA2: Commenting out all the microphone-related code keeps the experiment from crashing. I will try another microphone.

It turns out that this crashing behavior happens on both PsychoPy2 and PsychoPy3. I’m using Windows 10 (1903) and I think it’s a pyo Windows 10 interaction, but I’m really not sure. I’ve confirmed that the crashing happens any time audio is playing or whenever audio is being saved. I’m really at a loss. The code worked in Windows 7 on PsychoPy2 and all the rest of the experiment – except when the microphone is loaded – works just fine. What’s even worse is I get literally no errors when python crashes.

One final update. The sad solution was reverting to PsychoPy 1.83.04, where the original code was developed. It’s something very specific to portaudio and Windows 10 and we don’t have the time to fix Windows yet :frowning:

We have a new audio engine in PsychoPy 3.2 (Psychtoolbox) with much better timing and I hope this will eventually replace all the other audio options. I haven’t looked at the mic recordings yet but it does support that and should also have better performance there. This won’t solve your problem right now but in the future we can hopefully do better!