Cannot play audio file as variable (sound component)

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2023.2.2
Standard Standalone? y
What are you trying to achieve?:
I’m building an experiment that displays two images along with an audio for one trial. The images are displayed as expected but the audio does not play when it is set as a variable. It does play normally when a specific file is selected as a constant.

What did you try to make it work?:
I tried changing the audio library and it gave the same error. Older versions of PsychoPy are the same.

What specifically went wrong when you tried that?:
When I run the experiment, the mesage “Attempting to measure frame rate of screen, please wait…” pops up in fullscreen and the fullscreen exits on its own not long after; the experiment itself does not start. The error message shown in the runner is attached below:

C:\Program Files\PsychoPy\lib\site-packages\scipy\__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.24.4
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: '_MasterStream' object has no attribute 'handle'
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
1.8902     WARNING     Monitor specification not found. Creating a temporary one...
ioHub Server Process Completed With Code:  0
################ Experiment ended with exit code 1 [pid:11628] #################

Here is the experiment file with the stimuli: experiment.zip (2.3 MB)

Any help would be appreciated. Thank you!

Hey,
Your experiment works fine on my machine, Windows 10, PsychoPy v2023.2.2.
Is the experiment you have sent the correct, not working version?

Chen

That is weird. I re-downloaded and ran the attached experiment and it still doesn’t work.