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.