Difference between revisions of "Web-based perception experiments"

From Phonlab
Jump to navigationJump to search
Line 11: Line 11:
   
   
Your html code must have three features:
+
Your html code must have four features:
   
* source a javascript file that defines
+
* (1) after loading audexp.js, load a javascript file that defines
 
** an array (or two arrays) of filenames that will be presented.
 
** an array (or two arrays) of filenames that will be presented.
 
** a variable called 'block'
 
** a variable called 'block'
Line 20: Line 20:
 
** the html header contains these two lines to get the audexp.js library and the experiment-specific list of sound files.
 
** the html header contains these two lines to get the audexp.js library and the experiment-specific list of sound files.
   
::<script src="js/blocktest_list.js"></script>
+
::<script src="js/audexp.js"></script>
 
::<script src="js/blocktest_list.js"></script>
 
::<script src="js/blocktest_list.js"></script>
   
* a call to load the experiment when the page is loaded
+
* (2) a call to load the experiment when the page is loaded
 
::<body onload="load('id',false,500,2000);">
 
 
 
** this call specifies the type of experiment (in this case 'id')
 
** this call specifies the type of experiment (in this case 'id')
 
** whether to randomize the order of presentation of the list of sound files
 
** whether to randomize the order of presentation of the list of sound files
 
** the interstimulus interval for 'ax' and 'cr' types
 
** the interstimulus interval for 'ax' and 'cr' types
 
** and the intertrial interval for all experiments.
 
** and the intertrial interval for all experiments.
  +
  +
 
::<body onload="load('id',false,500,2000);">
  +
  +
* (3) Three or for <span...> elements that will be used to give feedback to listeners.
  +
** <span id="wr"></span> is used to show warnings
  +
** <span id="f1">sound 1</span> is used to indicate that an audio file is playing
  +
** <span id="f2">sound 2</span> is used to indicate that an audio file is playing
  +
** <span id="key">#</span> is used to indicate which key the listener pressed
  +
  +
* (4) A <form ...> element
  +
  +
  +
<!-- the order of these items determines the column order in the output file -->
  +
<form method="POST" id="dataform" action="process.php?p=id&n=1">
  +
<input type="hidden" name="subject" value=<?php echo $subj; ?> />
  +
<input type="hidden" name="trial" />
  +
<input type="hidden" name="list" />
  +
<input type="hidden" name="file1" />
  +
<input type="hidden" name="filedur" />
  +
<input type="hidden" name="mystatus" />
  +
<input type="hidden" name="loadtime" />
  +
<input type="hidden" name="response" />
  +
<input type="hidden" name="rt" />
  +
</form>

Revision as of 18:31, 8 February 2018

Experiments can be hosted on the Department of Linguistics server, and then distributed to listeners by email link, or via Amazon Mechanical Turk.

An example is here: example experiment

A Javascript library audexp.js makes it realatively easy to implement the following four kinds of typical experiment:

  • Identification (id) - a single audio file is played, and a two-alternative forced choice (2AFC) is given.
  • Discrimination (ax) - two audio files are played, and a 2AFC is given.
  • Rating (r) - a single audio file is played, and a rating number (from 1 to 7) is given.
  • Contrast Rating (cr) - two audio files are played, and a rating number is given.


Your html code must have four features:

  • (1) after loading audexp.js, load a javascript file that defines
    • an array (or two arrays) of filenames that will be presented.
    • a variable called 'block'
    • here's an example of such a file
    • this .js file was created with a small perl script from a .csv spreadsheet.
    • the html header contains these two lines to get the audexp.js library and the experiment-specific list of sound files.
<script src="js/audexp.js"></script>
<script src="js/blocktest_list.js"></script>
  • (2) a call to load the experiment when the page is loaded
    • this call specifies the type of experiment (in this case 'id')
    • whether to randomize the order of presentation of the list of sound files
    • the interstimulus interval for 'ax' and 'cr' types
    • and the intertrial interval for all experiments.


<body onload="load('id',false,500,2000);">
  • (3) Three or for <span...> elements that will be used to give feedback to listeners.
    • is used to show warnings
    • sound 1 is used to indicate that an audio file is playing
    • sound 2 is used to indicate that an audio file is playing
    • # is used to indicate which key the listener pressed
  • (4) A <form ...> element


<form method="POST" id="dataform" action="process.php?p=id&n=1">

     <input type="hidden" name="subject" value=<?php echo $subj; ?> />
     <input type="hidden" name="trial" />
     <input type="hidden" name="list" />
     <input type="hidden" name="file1" />
     <input type="hidden" name="filedur" />
     <input type="hidden" name="mystatus" />
     <input type="hidden" name="loadtime" />
     <input type="hidden" name="response" />
     <input type="hidden" name="rt" />

</form>