URL of experiment: https://pavlovia.org/foleyt/crmtest
Description of the problem:
I am building an online experiment where participants have to listen for a target sentence and make a response, additionally they press a button whenever they hear a tone beep. I have the tone beep (detection of the beep is the main goal of the experiment), being read in from a conditions file within a loop no problems there. As such I would like the target sentences to be read in via a code component. I have been following this thread on using code component to read in stimulus onset times.
I have applied this to my problem with the following python code.
if Tones.thisN == 0: # only on the first trial
targets = ['stimuli/Baron/070001.wav','stimuli/Baron/070006.wav']*54 # create the list
shuffle(targets) # randomise its order
current_target = targets.pop() # extract one entry on each trial
thisExp.addData('target_phrase', current_target)
Which converts to the following JS code
if ((Tones.thisN === 0)) {
targets = (["stimuli/Baron/070001.wav", "stimuli/Baron/070006.wav"] * 54);
shuffle(targets);
}
current_target = targets.pop();
thisExp.addData("target_phrase", current_target);
Then in the sound component I have $current_target.
Any help would be appreciated.