Creating audio loop with different duratio

heyy,
I’m using Win10 with the 2023.1.2 builder Standard Standalone.

I’m creating an experiment that plays different audio files with different duration to the subjects, after each audio file the subject is asked a question, and then the next audio starts.

I made a loop with 2 routines inside it, It works great when I’m forcing the audio to stop at a const time, (in the “stop” line in the sound component).

But when I’m trying to sound the whole audio file ( between 40s-150s) the experiment window closes right after the audio finishes playing.

Hello,
What error do you receive?

Chen

hey again!

Running: Z:\Lab-Shared\Experiments\audiobook_MW\pilot\stimuli\GalChenLab\SpotiPsy\groundPilot\untitled_lastrun.py

pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Traceback (most recent call last):
Hello from the pygame community. Contribute - pygame wiki
4.6009 WARNING User requested fullscreen with size [1024 768], but screen is actually [1920, 1080]. Using actual size
File “Z:\Lab-Shared\Experiments\audiobook_MW\pilot\stimuli\GalChenLab\SpotiPsy\groundPilot\untitled_lastrun.py”, line 172, in
elif sound_1.isFinished:
AttributeError: ‘SoundPTB’ object has no attribute ‘isFinished’
################# Experiment ended with exit code 1 [pid:8796] #################

the thing is I don’t have any code component, and now I tried making a small experiment to check if the problem is just with my experiment, in the new small experiment it behaves the same and has the same error.

Please take a look at the following:

thank you so much!!

but now i have another problem, the sound has finished playing but the experiment does’not continue to the next routine…

Can you please show us your routine?

Chen

sure! this is the whole loop:
image
and the chapter routine:


the $chap_names connects to a cvs file with all the audio paths.

Hey,
You don’t have a stop condition, so PsychoPy doesn’t know when to stop the routine.
You can put the audio file’s duration in the Stop input.

If you have different durations for the different sounds, you can create a new column in your CSV file stating the length of the sound as the following:

condition chatp_names chap_duration
1 one.mp3 5
2 two.mp3 12
3 three.mp3 7

Chen

1 Like

for future generations:

if chap_audio.status == FINISHED:
    continueRoutine = False

like that, there is no need to get the durations of the audio files manually :smiley:

1 Like