Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kishiyamat/e5aa680615340396f3c89104aae18228 to your computer and use it in GitHub Desktop.
Save kishiyamat/e5aa680615340396f3c89104aae18228 to your computer and use it in GitHub Desktop.
minimal-audio-exp.js
var timeline = [];
// 実験リストは "JSON" 形式で記述する。Pythonを使うとcsv形式を埋め込める。
// ランダマイズなどもできるが、その際は情報を渡さないと面倒になる。
var practice_prod_list = [
{type: "production", item_id: -1, read: "銀河", },
{type: "production", item_id: -2, read: "アップル"},
];
var instructions_prod = {
type: "html-keyboard-response",
stimulus: `
<p>キーを押すと練習課題に移ってしまうので、<br>
以下のお願いを全て読んでからキーを押してください。<br><br>
最初の産出実験では、一番上に表示される単語を<br>
標準語で2回ずつ読み上げていただきます。<br> <br>
キーを押すと2セットの練習課題に移ります。<br>
必要に応じてマイクの許可をお願いいたします。</p>
`,
};
timeline.push(instructions_prod);
// record というタスクを定義する。typeには参照するjsファイルを指定する。
// data には記録するデータを記述し、音声は「base64」で保存される。
var record = {
type: 'html-audio-response_modified',
stimulus: jsPsych.timelineVariable('read'),
prompt: `<br>
標準語で上の単語を2回読み上げたらspaceキーを押してください。<br>
再生ボタンを押して確認し、上手く録音できた場合は Sounds good! で次に進み、<br>
上手く録音できなかった場合は Retry を押してください。<br>
※丸が赤で満たされている時、録音しています。
`,
buffer_length: 60000,
manually_end_recording_key: ['space'],
data: {
type: jsPsych.timelineVariable('type'),
item_id: jsPsych.timelineVariable('item_id'),
read: jsPsych.timelineVariable('read'),
},
};
// timeline をリストの分だけ繰り返す。
var practice_prod = {
timeline: [record],
timeline_variables: practice_prod_list
}
timeline.push(practice_prod);
var finish_prod = {
type: "html-keyboard-response",
stimulus: `
<p>
産出課題はこれで終了となります。
お好きなキーを押して次に進んでください。
(空白が出れば保存OK)
</p>
`,
};
timeline.push(finish_prod);
jsPsych.init({
timeline: timeline,
on_finish: function(){
jsPsych.data.displayData();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment