Where and what to save audio files as to use in PsychoPy?

990 views
Skip to first unread message

Bombshell Molotov

unread,
Jun 21, 2015, 8:56:07 PM6/21/15
to psychop...@googlegroups.com
I have googled this hard and even similar questions dont have the info I need and assume more prior knowledge than I have! If I have a sound file such as an mp3, where should I save it and in what format so that I can insert it into the builder? I am using the latest version of PsycoPy on a windows computer.
I have attached pictures to show the filename and output. I'm sorry this is such a basic queston but I am at my wits end trying to find a simple explanation for how to insert audio with the builder!
audio code error psychopy filename.jpg
audio code error psychopy.jpg

Jonathan Peirce

unread,
Jun 22, 2015, 1:42:58 PM6/22/15
to psychop...@googlegroups.com
wav files are the most basic format
You can put them anywhere you like as long as you tell PsychoPy where they are correctly, but I would recommend something like a folder (called 'stimuli'?) next to your experiment file:

   \
    -myExperiment.psyexp
    -conditions.xlsx
    -stimuli
       \
        -sound1.wav
        -sound2.wav

Then your sounds can be referred to relative to your experiment file so that if everything moves to a new location (together) your experiment still works. So put something like this in your conditions file:

    stimuli/sound1.wav

       
On 20/06/15 13:46, Bombshell Molotov wrote:
I have googled this hard and even similar questions dont have the info I need and assume more prior knowledge than I have! If I have a sound file such as an mp3, where should I save it and in what format so that I can insert it into the builder? I am using the latest version of PsycoPy on a windows computer.
I have attached pictures to show the filename and output. I'm sorry this is such a basic queston but I am at my wits end trying to find a simple explanation for how to insert audio with the builder!
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/d6ebe23f-6ea2-4546-95c1-6c7b391748db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jonathan Peirce
University of Nottingham

http://www.peirce.org.uk


This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.

Bombshell Molotov

unread,
Jun 30, 2015, 8:58:58 AM6/30/15
to psychop...@googlegroups.com

Thanks Jon, I got it going -I am now having difficulty getting any audio to play via a Loop.
I have the stimuli saved in the C drive under Python/ExperimentPilot/Stimuli.
I want to setup the experiment so that it loops and plays a selection of 8s long audio stimuli at random. I currently have just one stimulus in the csv as a test (although I have tried running it with several stimuli too).
I have attached the setup of the trial routine, the loop and the audio object.
Loop setup.jpg
csv example for google group.jpg
trial setup example for gg.jpg
File Pathway for gg.jpg

Michael MacAskill

unread,
Jun 30, 2015, 10:08:40 PM6/30/15
to <psychopy-users@googlegroups.com>

> On 1/07/2015, at 00:58, Bombshell Molotov <bombshel...@gmail.com> wrote:
>
>
> Thanks Jon, I got it going -I am now having difficulty getting any audio to play via a Loop.
You don't tell us exactly what the problem is, so hard to give you any guidance…

> I have the stimuli saved in the C drive under Python/ExperimentPilot/Stimuli.
> I want to setup the experiment so that it loops and plays a selection of 8s long audio stimuli at random. I currently have just one stimulus in the csv as a test (although I have tried running it with several stimuli too).
> I have attached the setup of the trial routine, the loop and the audio object.

Although you don't say what the problem is, the screenshot of your conditions file shows that it contains only the first part of the filename and not its extension (.wav). Python will need the full name of the files in order to be able to find them.

Regards,

Michael




Bombshell Molotov

unread,
Jul 1, 2015, 10:00:52 AM7/1/15
to psychop...@googlegroups.com
Hi Michael, sorry it's not clear enough - I have tried it with the dot wav file extension in the conditions file (see screenshot) but it comes up with an error message (other shot). It gives me this message whether I use Excel or the LibreOffice equivalent.
I the audio files to play in a randomised loop as referenced in the csv consitions file. Currently it will not play any audio (the rest of the routine such as the text plays fine). I can get it to play single audio files as objects in a trial, but not from the csv doc. I guess it has something to do with this error message or not being able to add the full dot wav name?
many thanks
J
conditions file with dot wav.png
CSV error message.jpg

Jeremy Gray

unread,
Jul 1, 2015, 2:11:24 PM7/1/15
to psychop...@googlegroups.com

Hi Michael, sorry it's not clear enough - I have tried it with the dot wav file extension in the conditions file (see screenshot) but it comes up with an error message (other shot). It gives me this message whether I use Excel or the LibreOffice equivalent.

That error message is not a PsychoPy error message. Its from the spreadsheet program, warning you that not everything will get saved into the .csv file. Just go ahead and save it anyway, as text .csv, and see whether it works when that new .csv file is used from within PsychoPy as a conditions file.
 
I the audio files to play in a randomised loop as referenced in the csv consitions file. Currently it will not play any audio (the rest of the routine such as the text plays fine). I can get it to play single audio files as objects in a trial, but not from the csv doc. I guess it has something to do with this error message or not being able to add the full dot wav name?

Make sure to save the file as text .csv; .odt and other formats will not work, except for .xlsx. You should be able to add .wav into the file name in the cell within the spreadsheet.

--Jeremy

 
many thanks
J

On Wednesday, 1 July 2015 03:08:40 UTC+1, Michael MacAskill wrote:

> On 1/07/2015, at 00:58, Bombshell Molotov <bombshel...@gmail.com> wrote:
>
>
> Thanks Jon, I got it going -I am now having difficulty getting any audio to play via a Loop.
You don't tell us exactly what the problem is, so hard to give you any guidance…

> I have the stimuli saved in the C drive under Python/ExperimentPilot/Stimuli.
> I want to setup the experiment so that it loops and plays a selection of 8s long audio stimuli at random. I currently have just one stimulus in the csv as a test (although I have tried running it with several stimuli too).
> I have attached the setup of the trial routine, the loop and the audio object.

Although you don't say what the problem is, the screenshot of your conditions file shows that it contains only the first part of the filename and not its extension (.wav). Python will need the full name of the files in order to be able to find them.

Regards,

Michael


                                

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Bombshell Molotov

unread,
Jul 2, 2015, 3:27:19 PM7/2/15
to psychop...@googlegroups.com
I've saved as CSV with the .wav extensions set up- still no sound! :( Sound does play if I just have a single trial without the loop


On Monday, 22 June 2015 01:56:07 UTC+1, Bombshell Molotov wrote:

Michael MacAskill

unread,
Jul 2, 2015, 5:23:53 PM7/2/15
to psychop...@googlegroups.com

> On 3/07/2015, at 07:27, Bombshell Molotov <bombshel...@gmail.com> wrote:
>
> I've saved as CSV with the .wav extensions set up- still no sound!

We can't help without a detailed description of the actual error. "No sound" doesn't tell us enough to help you.

Regards,

Michael

Jon Peirce

unread,
Jul 3, 2015, 5:06:56 AM7/3/15
to psychop...@googlegroups.com
Based on the screenshots I'm thinking your paths aren't correct still,
but then you should be getting an error message (which you would have
told us, right?)

From your screenshots:
- your conditions file is at "ExperimentPilot/ExpPilotLoop.csv" and
the fact that it says that suggests that your experiment file (.psyexp
with the diagonal grating) is in the outer folder called Python. Correct?
- your excel file give no path at all for your stimulus so psychopy
is looking for it next to your experiment file (in Python folder?)
- your sound file is currently set to a filename. If you want it to
be accessed from the conditions file you need to use the variable $wav
instead of the filename. And then you still need the filenames in the
conditions file to give the path *relative to the experiment file*. If
your experiment file is in folder Python then the wav entries in your
condtions file should be ExperimentPilot/Stimuli/FolktronicFIFO8s.wav

You really need to look carefully at where things are and you want their
locations always *relative tot he experiment file (psyexp).

Jon
--
Jon Peirce
http://www.peirce.org.uk

Bombshell Molotov

unread,
Jul 5, 2015, 12:37:41 PM7/5/15
to psychop...@googlegroups.com

 From your screenshots:
     - your conditions file is at "ExperimentPilot/ExpPilotLoop.csv" and
the fact that it says that suggests that your experiment file (.psyexp
with the diagonal grating) is in the outer folder called Python. Correct?
   

The psyexp file I’m using is now at Python/ExperimentPilot/ (highlighted in screen grab)

 

 

 - your excel file give no path at all for your stimulus so psychopy
is looking for it next to your experiment file (in Python folder?)
     

I have put a file path into the excel file (hoping this was what you meant!) – see screen grab

 

your sound file is currently set to a filename. If you want it to
be accessed from the conditions file you need to use the variable $wav
instead of the filename. And then you still need the filenames in the
conditions file to give the path *relative to the experiment file*. If
your experiment file is in folder Python then the wav entries in your
condtions file should be ExperimentPilot/Stimuli/FolktronicFIFO8s.wav

 

Changed to the variable $wav instead of the file name.

I’ve run it and NOW I get an error message , so at least that’s something to go on! See attached


Again, many thanks for your help!
J
Error message July 5.jpg
File Pathway July 5.jpg
File pathway to wavs.jpg
Variable changed.jpg

Bombshell Molotov

unread,
Jul 5, 2015, 1:40:23 PM7/5/15
to psychop...@googlegroups.com
SOLVED!

It was a combination of 3 issues:
-I needed to have the audio box as 'set every repeat' (this is when it was playing no sound but not generating an error message)
-One of the soundfiles wouldnt play in psychopy (previous issue possibly re codec - other wavs would play but not the one I had been using, even though it would play in other programmes/software)
-I needed the $wav (I had fixed this but not the above 2 issues but they were all contributing to the lack of audio so it was hard to untangle which one)

Thanks once again for being patient and helping out a complete newbie!


On Monday, 22 June 2015 01:56:07 UTC+1, Bombshell Molotov wrote:
Reply all
Reply to author
Forward
0 new messages