If this template helps then use it. If not then just delete and start from scratch.
OS (e.g. Win10): MacOS updated
PsychoPy version (e.g. 1.84.x): v2024.14
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:
I have an experiment that shows a variety of different words on the screen with a corresponding sound of someone reading the word. The words are shown from a set of images that were created rather than manually creating them on PsychoPy. The first image ends when the sound ends, and a second image is portrayed-- this second image is the exact same as the first, except the word “start” is portrayed under the word instructing the participant to say the phrase 5 times. I want to insert a photodiode component so that whenever the second image (or when the “start” instruction is shown) a little black rectangle is shown in the corner of the screen. I have tried manually inserting a black rectangle where the start time is condition set to when the sound ends, and the duration is 0.1 and it is in the top right corner, yet the rectangle does not show. I have also used the following code:
Begin Routine:
black_rect.opacity = 0
flash_start_time = None
flash_duration = 0.5 # Duration to flash the rectangle in seconds
soundMSWSpeak_finished = False
Each frame:
Check if the sound has finished playing
if not soundMSWSpeak_finished and not soundMSWSpeak.status == PLAYING:
soundMSWSpeak_finished = True
flash_start_time = t # Record the time when the sound finished
If the sound has finished, flash the black rectangle
if soundMSWSpeak_finished and flash_start_time is not None:
if t - flash_start_time < flash_duration:
black_rect.opacity = 1 # Show the black rectangle
else:
black_rect.opacity = 0 # Hide the black rectangle after the flash duration
Despite this, the rectangle doesn’t show. The components are also listed in this order:
- sound
- image1
- image2
- rectangle
- code
- keyboard press to advance to next word
I’m new to coding so I don’t know exactly how to use any code to achieve this. Please help urgently if you can! Thank you!