Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

External file source

Hi there,

I am designing an experiment that will be running on JATOS and includes presenting participants a number of small audio files. These are (or should be) selected from a pool of roughly 50000 files, which of course exceeds the maximum file size for somewhat smoothly running it by a lot.

Is there a way to access the files from an "external" source from which OpenSesame only grabs the ones required for a session? E.g. by retrieving the required files from a folder uploaded to JATOS and adding them to the file pool in every session through some inline script?

Many thanks and best regards,

Tim

Comments

  • krikri
    edited April 2021

    Hi Tim,

    I can only speak from the JATOS side here. 50k files is a lot and although JATOS could probably handle them given a strong enough server, file serving is not what JATOS is specialised in. JATOS or JavaScript (and I hope OSWeb too) don't care where the files are loaded from - it's just a different URL. I'd suggest to use some professional file serving like AWS' S3 for this amount of files. Or if the cloud is not an option set up an Apache or Nginx (or any other file server) on your own machine.

    Edit: maybe even JATOS can handle this. What's the size of the 50k files altogether? And how much would you load per study run?

    Best

    Kristian

  • edited April 2021

    Hi Kristian,

    thanks for the fast reply. Well in that case the question narrows down to whether OSWeb allows fetching files from external sources (and maybe how to do that).

  • Hi @TOS21 ,

    In principle, in an inline_javascript you should be able to read an audio sample from a URL (using fetch() ) and play it (using an AudioContext ). However, this will take some figuring out (I have never done this myself), and you're also likely to run into the same-origin policy, which usually prevents you from reading data from other domains (i.e. server A cannot read from server B).

    You're saying that, for each participant, you want to randomly a subset of audio files from a larger set of 50,000 files, right? I'm assuming that this subset is small enough to fit in the file pool of OpenSesame. (A practical limit, imposed by the browser, seems to be around 1,000 files.) So a pragmatic solution might be to create a number of different versions of the experiment, only differing in the files that are included in the file pool.

    Whether that's an acceptable solution of course depends on the specifics of your experiment!

    — Sebastiaan

  • I might be mistaken but I think the Same Domain Policy doesn't stop you here, at least not if you are just playing the content (https://stackoverflow.com/a/27431853/1278769).

  • @kri Ah, it seems you're right. I don't think this is of much use @TOS21 right now (because it would still take a fair bit of programming to accomplish this), but this might open the possibility of allowing remote URLs for stimuli (sound and images) in OSWeb. Something to keep on the radar!

  • I'm assuming that this subset is small enough to fit in the file pool of OpenSesame. (A practical limit, imposed by the browser, seems to be around 1,000 files.) So a pragmatic solution might be to create a number of different versions of the experiment, only differing in the files that are included in the file pool.

    If fetching the audio files from our servers proves to be too complicated, this might indeed be the way to go. I was just hoping that I could avoid this option as it would not be optimal (and would also require a lot of thought).

    Many thanks for your advices - I will post here if fetching the files worked.


    Best,

    Tim

  • Update:

    I found a really easy solution that seems to work for our purposes. We uploaded the relevant files to our server and an inline_script with following content in the block loop did the job:

    vars.url = ###generated URL based on random selection###
    vars.audiosample = new Audio(vars.url);
    vars.audiosample.play();
    // also get sample duration to calculate RT
    vars.sample_duration = vars.audiosample.duration*1000
    

    We converted the files to .ogg, reducing their sizes to a few kbs and therefore taking absolutely no time to load.

    Hope this might help anyone facing the same task.


    Best,

    Tim

  • edited April 2021
Sign In or Register to comment.