| Reference | Downloads | Github

How to repeat an audio stimuli when pressing certain key

System version: masOS Mojave Version:10.14

Hi all,
I’m using PsychoPy builder to build up an experiment like this: By pressing space, the participant can listen to the next audio stimuli. By pressing “r”, the participant can repeat the audio stimuli like as many as they like. My question is how to repeat the stimuli as described. I think this may require some coding, so if you could tell me put what codes at which position that will be great. Thank you so much!!!


You need a second loop inserted inside the trial loop, called say, repeats. De-select “is trials” in its loop dialog.

Insert a code component in sentetrial. In its “End Routine” tab, put something like this:

if key_resp_2.keys = ['space']:
    repeats.finished = True

Set your keyboard response to “force end of routine” and allow only 'space', 'r' keys.

PS Please don’t post multiple copies of a question in different places on the forum. It doesn’t help get an answer, it just wastes attention and time.

1 Like