Reference error : vk is not define

Hi all,

I met a problem about the referenceError when run my project on pavlovia.
And I tried using the Auto->JS, but it did’t work.

image

Thank you for reading my question. Appreciate your answer and help.

Please could you show the code where you define vk ?

It should be in a Begin Experiment block.

Best wishes,

Wakefield

Hi Wakefield

Many thanks for your help.


image

Sorry, I’m a beginner of Psychopy, I really appreciate for your time to help me.

Thanks again,

Eric

So a few things:

  1. I think you’re trying to refer to a VoiceKey object. I don’t know if those exist in Pavlovia at the moment (@jon?). I know you can’t get microphone input on Pavlovia right now, so if this is based on the assumption that you are recording the user, that’s flat not going to work regardless, but I’m also fairly certain it won’t work even if you’re feeding it another sound file.

  2. Your code looks like it’s starting from something that has the python code “from psychopy import voicekey as vk” in it, but that won’t work here for a bunch of reasons. First of all, you can’t do import statements in JS. Second, the way you’re defining vk at the moment, it’s just a blank string, not an object with the property OnsetVoiceKey. Third, Python doesn’t use semicolons like that, so it’s probably throwing error when you try to compile it in the first place (the auto->JS translator will add a semicolon if it is needed).

Depending what you are trying to do in this study it may not be possible to do it on Pavlovia right now, but if you aren’t trying to record from a microphone, please explain what you’re trying to do and we’ll see if there’s a way to do it.

1 Like

Hi jonathan,

For this project, I would like to create a voicekey to collect the RT of my participant.
However, this task require the microphone input to obtain the RT data.

Do you know how to defined the property OnsetVoiceKey? I know it can’t work in Pavlovia, but this problem is my first issue of Pavlovia, I wondering to learn. Maybe it might helpful to me when Pavlovia update in the future.

Many thanks for your time to help me.

Eric

It’s not really possible to know how it works until it’s added to Pavlovia. The thing to remember is that the code running on your computer and the code running on Pavolvia are two completely different things. The builder is just translating what you make in its graphical interface into each programming language (Python and JavaScript), but the Python and JavaScript are basically two completely separate programs that are carefully configured to do the same thing as much as possible. When Pavlovia gets sound recording and VoiceKey set up, it could look very different from how it works in Python.