How to record the voice of subject by Microphone

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): v2021.2.3
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?:
Hi, thank you for reading my post. I’m a beginner in Psychopy. I would be very grateful if you could offer a solution to my question
I’m compiling the naming experiment in which the participant sees a picture first and names it.
I would like to record the participant’s verbal response by the built-in microphone and the voice were stored.

What did you try to make it work?:
The participant will start the recording by pressing ‘s’ on the keybord and stop it by pressing ‘e’. I’m trying to achieve this in the Builder.
I added the Microphone component in the trial.

What specifically went wrong when you tried that?:
The error messenger show that:
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 236, in del
self.close()
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 146, in close
raise err
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 139, in close
PsychPortAudio(‘Close’, self.handle)
AttributeError: ‘Stream’ object has no attribute ‘handle’

Experiment ended.

Sorry for my poor English if this description makes you .And also sorry for my ignorance in Psychopy

Hi There!

I’de suggest a few things - first, please try to upgrade to the newest psychopy release - there will be a bunch of fixes that will make things easier!

Second, If you get that error - could you try changing the sampling rate of your mic component: Error 'Stream' object has no attribute 'handle' - #2 by wakecarter

Hi,Becca
I upgrade the last version( v2022.2.4 ) and it can record the voice of subject by Microphone.
Thank you.

Then, I would like to send a trigger to Emotivpro by microphone. it’s really hard to do that.
So, I think I can create two bottoms: first one, press"r" to Record and second, press"s" to Stop record, and psychopy send a trigger to Emotivpro when subjects press"r" bottom.

the Code Component in Each Frame:
#按下’s’開始錄音 and send the trigger
if repeat_key.getKeys([‘s’]):
start=Microphone.start()
#按下"e"結束錄音
if repeat_key.getKeys([‘e’]):
stop=Microphone.stop() #就結束

the Microphone Component:
Name:Microphone
Start: time(s): $start
Stop:duration(s):$stop

Psychopy can’t record when I press “r” button.

Hi There,

I’m pleased this resolved your initial problem - please could you mark the appropriate response as the solution and then use a different thread for a different topic?

In this case though, I don’t think you need a code component. Use the Emotiv components that are inbuilt you can have one marker sent at the start of your recording and then add a second routine after your routine with the microphone in it where you send another trigger to your emotiv to mark the end of the recording.

Thanks,
Becca