ここでは、いくつかの文章を単語ごとに再生し、定期的に質問するスクリプトです。これは、スクリプトと同じフォルダ内に単語として名前が付けられたwaveサウンドファイルがあると想定します。 I.wav
、want.wav
など。'.wav'
を目的のサウンドフォーマットに置き換えるだけで他のサウンドフォーマットも使用できます。終了したら
full = 'I/want/to/go/to/the/theater/with/my/friends'
partial = 'I/want/to/go/to/theater/with/my/friends'
question_frequency = 5 # How often to ask questions
ISI = 0.5 # Inter-word-interval
import random
from psychopy import visual, sound, event, core
win = visual.Window()
word_sound = sound.Sound()
instruction = visual.TextStim(win)
trials = [{
'sentence': random.choice((full, partial)),
'ask_comprehension': int(i % question_frequency == 0),
'comprehension_answer': ''} for i in range(10)]
print trials
for trial in trials:
for word in trial['sentence'].split('/'):
#word_sound.setSound(word + '.wav')
word_sound.play()
core.wait(ISI)
if trial['ask_comprehension']:
instruction.text = 'Did you understand this sentence?'
instruction.draw()
win.flip()
trial['comprehension_answer'] = event.waitKeys()[0]
win.flip() # Blank screen
、あなたはCSVファイルにtrials
を保存することができます。