Referencing sound files

Hi there,

I’m currently working on a categorization task where participants listen to a total of 120 words (60 living and 60 non-living) that they have to categorize to living (press “a”) or non-living (press “l”). Since it is a 120 individual sound files, I tried to use an excel sheet, where I have a column with the absolute path to the sound files, however my code does not run. The error I get is the following: soundfile.LibsndfileError: Error opening ‘words.xlsx’: Format not recognised.

Thank you in advance!

Hello,
Can you please share an image of your experiment folder as well as an image of your loop?

Thanks

Hi,

Yes, see attached. I am also attaching my excel file and the contents of the words folder (the individual sound clips).

experiment folder:

words folder:

the loop


word list file
words.xlsx (19.8 KB)

The error message is saying that the PsychoPy sound component is trying to load the excel file itself, rather than the sound files it references. In other words, rather than reading the excel file and trying to load one of the filenames in it, it thinks that ‘words.xlsx’ is an audio file and the error is saying that it doesn’t recognize .xlsx as a valid audio format (which makes sense, it isn’t).

Can you share the .psyexp file? I suspect this is something about how the loop or the sound component is set up in the builder.

Hi,

Thank you for the fast response. See the .pysexp attached.
accent_Pt1.psyexp (13.9 KB)

Ah, this is a misunderstanding of how condition files work. Here’s how to fix it:

  1. Click on the “word_rep” loop and click the folder icon next to the ‘conditions’ field. Select words.xlsx. It should look like this.
  2. Click the “allwords” sound component and change “sound” to “$wordfile”. It should look like this.

That will set the sound file to the file listed in column ‘wordfile’ in words.xlsx on every iteration of the loop. Similarly if you want to reference anything else in the excel file in a stimulus component, you just have to put the name of the column with a $ in front of it. For example, if you wanted to use ‘correct’ to have PsychoPy automatically record if each response is correct or not, in your keyboard component under “data” check the “Store correct” box and then put “$correct” in the “Correct answer” field.

Thank you! This definitely helped, now I have a soundfile randomly play (I ran it multiple times, so I know it’s random), but as soon as the first soundfile is played, the experiment ends (I don’t even have time to give a key response), and the thank you screen also does not come up.
This is the error message

AttributeError: ‘SoundPTB’ object has no attribute ‘isFinished’
################# Experiment ended with exit code 1 [pid:1118]

Edited .psyexp
accent_Pt1.psyexp (49.2 KB)

You don’t have any code components in your experiment so that error has to do with the code that PsychoPy is generating. What version of PsychoPy are you using? There are a few ways to fix this but I suspect this is going to come down to using a version of PsychoPy that’s either too old or too new.

I am using, what I think is the newest one, the 2023.1.2 version.

OK. Try going to your PsychoPy settings (not experiment settings) and checking the audio library, see if you can switch it from “ptb” to anything else. It might not work at all, but if the issue is with PTB specifically then that might be the quickest fix.

If not, can you share the full text of the error, not just the last bit? That might help me narrow down where exactly this “isFinished” property is being referenced.

The full error message

Running: /Users/ajnafannikertesz/Desktop/Accents /accent_Pt1_lastrun.py

57842.7877 INFO Loaded monitor calibration from [‘2022_10_05 21:31’]
2023-06-06 09:07:20.510 python[59088:7984267] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/c6/mjl_76ks1vg4k_9vgyl5mtpw0000gn/T/org.opensciencetools.psychopy.savedState
2023-06-06 09:07:24.700 python[59088:7984267] Warning: Expected min height of view: (<NSPopoverTouchBarItemButton: 0x7f8dd7116aa0>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
2023-06-06 09:07:24.700 python[59088:7984267] Warning: Expected min height of view: (<NSButton: 0x7f8e0375ff80>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
2023-06-06 09:07:24.701 python[59088:7984267] Warning: Expected min height of view: (<NSPopoverTouchBarItemButton: 0x7f8e03760230>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
2023-06-06 09:07:24.703 python[59088:7984267] Warning: Expected min height of view: (<NSPopoverTouchBarItemButton: 0x7f8e037628e0>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
Traceback (most recent call last):
6.5529 WARNING User requested fullscreen with size [1024 768], but screen is actually [1440, 900]. Using actual size
File “/Users/ajnafannikertesz/Desktop/Accents /accent_Pt1_lastrun.py”, line 333, in
elif allwords.isFinished:
AttributeError: ‘SoundPTB’ object has no attribute ‘isFinished’
################ Experiment ended with exit code 1 [pid:59088] #################

OK. Short-term fix do what I suggested above with the audio library in your PsychoPy settings.

@jon There seems to be an issue here with the code auto-generating a call to a property that shouldn’t exist. Is this a holdover from previous versions?

Ah, I can see this one. Will be in the next bugfix release (2023.1.4)

There’s no audio lib in the Psychopy preferences that I see (version 2023.1.3 on my MacBook Pro 2020) see screenshot attached.

I have been able to get around this in the code and edit the rest of the experiment in Python, but now pushing to Pavlovia I have 403 error issues, which can only be because I don’t have a builder component that generates the .exe and .html files (I have credits assigned and I tried the piloting a bunch of times on different browsers)… If there’s no way to fix the sound ref in builder, how can I use my python code to push and run on Pavlovia?