[solved] Record audio response with variable time span
Hi.
I was hoping someone here on the forum might have the knowledge and time to help me with a problem of mine.
I have an experiment where participants will be listening to some audio stimuli and afterwards describe them verbally. I want to record their response, but the recording phase will not have a set time span. Essentially, when the participant feel they have said what they want to say, they will click a button and progress to the next audio stimulus and recording phase.
Is there any way to accomplish such a thing in OpenSesame? I looked at the inline_script described in http://forum.cogsci.nl/index.php?p=/discussion/107/solved-recording-speech-response/p1, but it only allows for a fixed recording time. The audio plug-in essentially does what I want to accomplish, but it relies on Pymedia. Pymedia is not included in the Ubuntu 13.10 repositories, and I tried compiling Pymedia from source, but ran into all sorts of problems. Mainly that it required a lot of old audio libraries and gcc-3.4.
In the builder I image it would look something like this.
Sequence.
- Sampler (plays an audio file).
- Start audio recording.
- Feedback (wait for keypress)
- Stop audio recording and write to file.
Next sequence.
Any help is much appreciated
Njord
Comments
Hi Njord,
A little bit down in the same discussion that you're referring to, you will find a little code snippet that you can use to stop recording when a key is pressed. It sounds like this is exactly what you're looking for:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thank you very much for your help, Sebastiaan.
I got the script working and it is recording .wav files without a hitch, but I ran into another problem.
In the folder in which my OpenSesame experiment is saved, I want to create a sub-folder named after the "Participant ID". All the recorded sound files from one participant will then be saved in this folder.
In the script, I have these statements accomplishing this task:
This works well, except that the sub-directory is created in my $HOME folder on Ubuntu, and not in the folder where the experiment resides.
I know that this could easily be solved by specifying absolute paths, but I am going to move the experiment to a lab computer when it is finished. Therefore I want to use variable paths, so that I don't have to go back and change all the paths.
Do you know, or somebody else, how this can be accomplished?
Hi Njord,
You could determine the path of the directory in which your OpenSesame is placed by using the following piece of Python inline code:
Does that help?
Cheers,
Lotje
Did you like my answer? Feel free to
lvanderlinden, that was just the piece of code I needed.
I though I would share my finished inline script so that others that might have a similar problem can use and modify it to their needs.
I am using this script to collect open-ended responses to a stimulus. When the participant is done giving their response and press the space bar, the experiment continues. But I also wanted to insert a time out, so that if one participant doesn't press the key, falls asleep, is uncooperative, the experiment will not halt at this part.
It has to be inserted into an inline_script to work.