Audio Feedback for Mouse Click Response

Hi!

I am new to Psychopy and do not have much Python and coding background, so I need some help. I am currently building a study in Builder view. I have a sequential loop (stories) that is attached to an excel conditions file. Within my loop, I have a routine (present) where I present two image stimuli (leftInformant2 and rightInformant2). Participants use a mouse component (key mouse) to click on one of those two image stimuli. Then, in a feedback routine (informantResponse) I want to give audio feedback based on which one they clicked. Specifically, if they clicked the leftInformant2 image component, I want the corresponding leftAudio from my excel file to play, while if they clicked the rightInformant2 image component, I want the corresponding rightAudio from my excel file to play.
Here are some images of what I am working with:




So, the problem is that I can’t figure out how to program the corresponding audio feedback.
I tried this in the begin routine of my feedback routine:

if keyMouse.isPressed(leftInformant2):
    playsound=leftAudio
elif keyMouse.isPressed(rightInformant2):
    playsound=rightAudio

And then entered this into my audio component (the “stimuli/” is a path to the folder with all the stimuli in this study):
image

But it is not working! When I run my study, psychopy shuts down when it gets to the informantResponse (feedback) routine. I think it has to do with my coding, cause when I delete the code, everything works fine but, of course, there is no feedback.

So if anyone could point out what I should be doing differently it would be greatly appreciated! Or if anyone has any guidelines for how to give audio feedback from an excel file based on participants’ mouse clicks that would be very helpful too! Thanks in advance!

More detail than this is necessary… Otherwise we are just kind of guessing where the issue is.

To be more specific, when I run my study and I get to the routine where the feedback is supposed to occur (informantResponse routine), psychopy shuts down. I think there is something wrong with my code component, cause when I remove it, everything else works fine (but obviously there’s no feedback).

Is an error message produced?

Unfortunately, no error message is produced