Microphone error - 'Python stopped working'

OS (e.g. Win10): Windows 7
PsychoPy version (e.g. 1.84.x): 3.0.7
Standard Standalone? (y/n) If not then what?: Y
Link https://gitlab.pavlovia.org/juliankl/audioexperiment

At most run-throughs (though not all), I get the uninformative error message “Python has stopped working”
error_builder_1

The error started occurring after I activated my microphone. I.e., as soon as I put a duration (3 sec) for my mic component, this error message started popping up. It always occurs in the transition from the loop which uses the mic to the following loop that doesn’t, and it occurs almost every time I run it. I had someone else run it on their computer (Win 10), and the same problem occurred.

Important to note is that the microphone component otherwise seems to be working fine under these conditions. That is, it records when it is supposed to and stores it.

The only “fix” I’ve found is to not set a duration for the mic. However, this means that the microphone doesn’t record. So it isn’t exactly a fix that works for me.

I have seen the same problem here on the forum, and the solution suggested is to change the audio library from [‘pyo’] to [‘pygame’,‘pyo’]. However, this recreates the problem of “pyo server not created” which I struggled with for some time. Similarly I’ve tried using [‘sounddevice’,‘pyo’] and [‘pyo’,‘sounddevice’] without any success.

Any suggestions is greatly appreciated.

If anyone else encounters a similar problem, what ended up working for me was setting the duration of the recording to a shorter duration (2 sec) than the duration of the visual stimuli (3 sec). I do not know why this worked.