Two demos: Online microphone/recording, headphone check

I’m sharing two demos that I’ve recently developed. More documentation for both are provided at the respective code links below.

Online microphone recording: code | try it

This demo shows how to create an experiment that records audio via a participant’s microphone online. It also checks whether the participant has granted microphone access, and if they have not, prompts them to do so.

Headphone check: code | try it

This demo, based on the headphone screener made by @sijiazhao—it uses the audio files for the Huggins Pitch task available from that project’s github. It differs from that project in that (1) it was made in the Builder (with a few JS code components), so you don’t need to modify the auto-generated JS file from the Builder, and (2) it saves the results to the participant’s data file, rather than terminating the experiment upon failure of the check.

2 Likes

Hi Abraver,

I tried your first online microphone recording. However, I indeed made a copy of the code, and delete the “never-end-routine” routine at the end. Then I re-created a JS file and uploaded the experiment folder to my own Pavlovia and ran it. The test went smoothly, but after the whole test, I cannot find any audio files that recorded my speech for each trial. I thought the word-naming speech was recorded trial by trial. Do I miss anything critical?

Thanks,

Hi @Su_Wang ,

On the experiment page on Pavlovia, do you see anything in the “Sessions” section? I believe you should get the recordings from the “Download results” button.

Gotcha. Thank you! So actually the recording files are in somewhere else? Because I didn’t see them in the data folder on Pavlovia until I download the results.
I have one more question. I saw in the javascrip coding, if I would like to get the recording, the code is

mic.lastClip = await mic.getRecording({tag, flush: false})

And I search the source code of getRecording() function on PsychJS. I was wondering if I changed “flush: false” to “flush:true”, will the recording be saved immediately?

I am looking for an approach that allow me to obtain the trial-level recording immediately after that trial and replay the recording in an online experiment. I know we can do this in a local experiment. Would it be possible online?

Thank you!

Unfortunately, I don’t know whether the flush: true trick will work, but perhaps someone else does. Or, if you try it out, please let us know!

I tried. It doesn’t work at all. Then I went back to the psychoJS source code and found “flush:false” is a fake argument in that function. There’s no further definition for this argument.

Thank you for checking! Now my study works online.

And one more question. I realized the audio files are not saved on Pavlovia, but where they are stored, and how large the storage space is? (I’d like to run the test online and collect audio data from hundreds of participants, so I assumed the data set will be huge.)

Thanks!

Hello Abraver. Thank you so much for making these demos.

I am right now trying to run your headphone check but I am running into an error both locally and online. Once I run the headphone check locally, I am able to start the experiment, but it soon ends with an error. AttributeError: ‘_MasterStream’ object has no attribute ‘handle’

When I try to pilot the experiment online via pavlovia, I get another error: Uncaught SyntaxError: Unexpected token '}

I believe I followed the instructions to get it to run (i.e., deleted the never_ending_routine), but I am still able to run your headphone check. Do you have any thoughts on what might be going on?

Hmm, I’m not sure, but I would try adjusting the “Use PsychoPy version” option in the properties tab—try 2023.2.3.