OS : MacOS Mojave
PsychoPy version : 2021 2.3
What are you trying to achieve?: In my experiment, I am hoping to collect verbal responses from participants. I am able to create .wav files, but the files are empty. Using other software on my computer (e.g. inquisit) I am able to get my microphone to work and have sound come through, however, using psychopy there does not seem to be a connection with my computer microphone
What did you try to make it work?:
I implemented the code below. This code opens the window and creates an empty .wav file. Specifically, I also downloaded psychtoolbox and changed my hardware preferences for audiolib as well. I also tried running several builder experiments using the microphone component, and also received blank .wav files.
import psychopy from psychopy import visual, core, event, data, gui from psychopy import visual, core, event, data, gui from psychopy import prefs psychopy.prefs.hardware['audioLib'] = ['PTB'] from psychopy import sound resolution = [1440, 900] win = visual.Window(resolution, monitor="testMonitor", fullscr=True, screen=0, units='pix') recordingDevicesList = sound.Microphone.getDevices() recordingDevice = recordingDevicesList # assume not empty inputLatencyLow, inputLatencyHigh = recordingDevice.inputLatency deviceName = recordingDevice.deviceName recordingDevicesList = sound.Microphone.getDevices() recordingDevice = recordingDevicesList mic = sound.Microphone(streamBufferSecs=10.0, device=recordingDevice, channels=1) mic.start() # start recording mic.poll() win.flip() # calling the window flip function core.wait(10.0) # wait 10 seconds mic.stop() # stop recording audioClip = mic.getRecording() print(audioClip.duration) # should be ~10 seconds audioClip.save('test.wav') # save the recorded audio as a 'wav' file
What specifically went wrong when you tried that?:
I receive no errors when I run this code, however, the .wav files are still empty. Any help would be appreciated as to why psychopy is not communicating with my microphone!