Accessing data file of currently running experiment in builder view

OS (e.g. Win10): win 7
PsychoPy version (e.g. 1.84.x): 1.90.1
Standard Standalone? (y/n):yes
I am trying to analyse the results of stroop experiment. For this I need to read resp.corr column of the excel data file being created at time of running of experiment , do some calculations and then output the result on the screen.
I don’t know how to access the results of currently running experiment ?
Can anyone help?

Hi @Aishwarya, you could add a code component to your experiment, and either every frame, or at the end of every routine, you can check whether or not the correct response was given via the keyboard. For example, if your keybaord is called “resp”, add the following to a code component in the End Routine tab. Note, the print functions are just to demonstrate the output, you could instead assign a variable with a value for correct, or incorrect e.g.,

if resp.corr: # If response was correct
    print("Your answer is correct, Your RT was {}".format(resp.rt))
    accuracy = 1
else:
    print("Oops!")
    accuracy = 0

I am getting an error that resp is undefined.
Although my keyboard response name is responsible only.

David,
Thanks for your valuable reply. It worked.

Now , I want to use microphone component but getting the following error:

Attribute error : Pyo server not created.

Can you help me?

Thanking you

Yours faithfully

Aishwarya

No problem. This is probably a case of setting pyo as your default audio library in your Experiment Preferences in Builder (The spanner and screwdriver icon). Set audio library to ['pyo', ]

Thank you. It worked.

David,

I want to write text in hindi in python. I added a code for the same but getting Unicode Decode Error.

Can you tell me that how can I type Hindi text in psychopy? Can I do itself in the builder view or not?

@Aishwarya, where are you attempting to add Hindi text? Is it in a text component?

Yes

Ok, would you please paste the whole error that you receive?

Ya sure, David.
this is the code which I am running for hindi speech recognition.

import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone(1) as source:

print(“Say Something”);

r.adjust_for_ambient_noise(source, duration=1)

audio = r.listen(source)

print(“Audio captured!”)

print(“Time Over, Thanks”)

try:

str=r.recognize_google(audio, language=‘hi-In’)

print("Text: "+ str);

except sr.UnknownValueError:

print(“Google Speech Recognition could not understand audio”)

except sr.RequestError as e:

print(“Could not request results from Google Speech Recognition service; {0}”.format(e))

print(‘Recognition Ended’)

And the error which I am getting is as follows:-

Say Something

Audio captured!

Time Over, Thanks

Traceback (most recent call last):

File “D:\psychoexp\SpeechRecog.py”, line 12, in

print("Text: "+ str);

File “C:\Program Files\PsychoPy2_PY3\lib\encodings\cp1252.py”, line 19, in encode

return codecs.charmap_encode(input,self.errors,encoding_table)[0]

UnicodeEncodeError: ‘charmap’ codec can’t encode characters in position 6-12: character maps to

David,
Did you find any solution?