Any way to interrupt an audio recording?

262 views
Skip to first unread message

Tara

unread,
Aug 28, 2012, 7:05:39 PM8/28/12
to psychop...@googlegroups.com
Hello,

I'm creating a language production experiment to be tested on two year olds and am having trouble with the sound recording component. During a single trial I'd like a video to play and then have the microphone record any possible productions the children use to describe it. I have no problem playing the video or starting the recording, but am puzzled on how to end the recording. The thing is that I don't know exactly how long the kids are going to take to make the productions, as well as variances between subjects. It may take ten seconds, it may take two minutes.

There seems to be no way to record sound indefinitely as the program will not run at all if no time length is specified. Is it possible to specify an arbitrary amount of time to record and then stop the recording with a key press when the subject is done?

As of now I have tried calling ".reset()" after the check for key presses as well as setting the .status=FINISHED, but none of these seem to interrupt the recording. Key presses will not cause an advance to the next trial until the time that I have specified for the recording is finished.

I am using the 1.74.03 standalone for windows. I am running Windows XP. I built the basic structure (a video, sound recording and key press all in a loop) with the builder and then have switched over to the coder for customizing. Any advice would be most welcome!

~Tara

Jeremy Gray

unread,
Aug 28, 2012, 7:53:38 PM8/28/12
to psychop...@googlegroups.com
Hi Tara,

At present there is not a way to stop a recording that is in progress.
I'll look into trying to add that, it seems handy.

--Jeremy
> --
> You received this message because you are subscribed to the Google Groups
> "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to
> psychopy-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/psychopy-users/-/GpeMijZS-vcJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

He Jibo

unread,
Aug 28, 2012, 9:00:37 PM8/28/12
to psychop...@googlegroups.com
I would live this feature too (a pause for sound recording). I am not sure how audio recording is implemented in psychopy. The pyvnc2swf has an record_sound.py file. This file is attached. It depends on pymedia. This may help.

---------------------------
He Jibo
Assistant Professor
Department of Psychology,
Wichita State University
website: www.hejibo.info
record_sound.py

Jeremy Gray

unread,
Aug 29, 2012, 6:40:28 AM8/29/12
to psychop...@googlegroups.com
> I would live this feature too (a pause for sound recording). I am not sure
> how audio recording is implemented in psychopy. The pyvnc2swf has an
> record_sound.py file. This file is attached. It depends on pymedia.

thanks He. in psychopy the sound recording is done using pyo. the plan
is that eventually all sounds will be handled with pyo. but of course
anyone can use whatever they want alongside that.

--Jeremy

Jeremy Gray

unread,
Aug 30, 2012, 10:19:54 AM8/30/12
to psychop...@googlegroups.com
Its now possible to stop a sound recording part-way through, but only
if you are using code. There's no Builder support yet, and there is no
support for pausing and resuming a recording (just start a new one).

The new code is on github,
https://github.com/jeremygray/psychopy/blob/ec866dfd14c28a0effd4abd508c984556531a93c/psychopy/microphone.py

download the whole file microphone.py, and replace your copy with the new one.

You have to use a non-blocking call to mic.record(..., block=False),
and you can then call mic.stop() whenever you want, e.g., after a
key-press has been detected.

I think this is working, but its possible that there may be a few
issues. Just let me know.

--Jeremy


On Tue, Aug 28, 2012 at 7:05 PM, Tara <tsta...@u.rochester.edu> wrote:

Jeremy Gray

unread,
Aug 30, 2012, 11:32:25 AM8/30/12
to psychop...@googlegroups.com
Here's a very slightly better version to use:
https://github.com/jeremygray/psychopy/blob/cebac340acb1585372fd242d90b8a6915ad333ef/psychopy/microphone.py

To stop a recording based on a keyboard event, you need a
visual.Window() to get the key-board events, and can then do things
like this:
mic.record(60, block=False) # block=False is crucial
while mic.recorder.running:
if 'q' in event.getKeys():
mic.stop()

This will record for 60 seconds, unless key 'q' is pressed at which
point it will stop recording.

--Jeremy

Jeremy Gray

unread,
Sep 1, 2012, 12:13:11 PM9/1/12
to psychop...@googlegroups.com
a quick update: being able to stop a recording in progress is
scheduled to be released as part of the next update, for both coder
and builder experiments. I'm not sure the exact timing but likely
fairly soon. if you want / need this before the update, its available
on github.

--Jeremy
Reply all
Reply to author
Forward
0 new messages