Howdy, Stranger!

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

Supported by

Text input form for spoken word recognition

Hi all! I'm new to OpenSesame and am hoping to use the platform to administer a spoken word recognition task (where listeners will hear an audio file and type in the word they heard). I'm able to get something like that working with an audio sampler followed by a form text input, such that participants can see what they're typing and press the enter key to advance to the next trial. The form successfully logs the responses; however, in looking at the .csv file, I notice that it doesn't log accuracy or response time or the other types of things that the keyboard logger would. Is there a way to have it log the same information as the keyboard logger? Thanks!

Comments

  • Hi,

    The reason why these variables are missing is that they are not clearly defined (at least I presume so). For example, what is used as a response time? The time until the first letter is typed, or until the entire phrase is written? Similar ambiguities hold for accuracy.

    There are probably ways to retrieve these kind of variables, but what you have to do depends a lot on what you want. So, if you give more information on how you want response time and accuracy be defined, we can help you in a more suitable way. Here, just one example of code that might help you.

    # put this code in an `inline_script` (run phase) after the `form_text_input`
    
    # I'm not sure whether var.time_from_text_input is the correct variable. It should be. 
    # But if it is not, you can put the code: `start_time = clock.time()` in another `inline_script`
    # right before the `form_text_input` and then compute response times with this variable
    # This code defines response time as the time until the text input is confirmed with Enter
    response_time = var.time_form_text_input - clock.time()
    
    # this requires that you specified the correct_response beforehand, e.g. in the `loop_table`
    # this code is case-sensitive, so if someone responded `Apple` instead apple, the response is false
    correct = var.response == var.correct_response
    

    Hope this helped.

    Good luck,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,
    Thanks! Yes, I was considering response time in this case to be the time until the first letter is typed. I have also specified correct responses in correct_response in the loop table and was considering accuracy to be an exact match.

    Angela

  • If it is the time until the first letter is typed, you won't be able to use the text_input_form, but have to use python scripting. It is certainly possible, but won't be very easy, especially if you want to have code that is flexible enough to deal with special cases, as corrections or uppercase letters.

    As a starting point, this code here does measure the time for the first stroke, and checks if the word matches the correct word:

    # open a keyboard
    kb = keyboard()
    # an arbitrary starting time to measure RTs
    # if you want it to be contingent on your audio playback, you need to know when I word was spoken
    t0 = clock.time()
    
    # define correct response
    correct_response = 'word'
    
    # makes sure that RT is only measured once
    RT_key = True
    # initialize response
    word = ''
    while True:
    
        # sample key strokes        
        k,t = kb.get_key(timeout = 10000)
        if k and RT_key:
            resp_time = t-t0
            # add letter to word
            word += k
        elif k:
            word+= k
        elif k == "ENTER":
            break
        # if participants is way to slow, abort the trial
        if clock.time()-t0 > 20000:
            break
    # was response correct?
    correct = word == correct_response
    

    I haven't tested the code, but something along these lines should be it. This code has to be placed in an inline_script and run while the audio is played back.

    Does this make sense?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.