[solved] Recording speech response
Hi,
First off, thanks for all the efforts you're putting into this package. It looks and works amazing.
I want to do a sort of picture naming experiment; a picture appears on the screen and the participant has to describe it. In my case, recording for abour five seconds during the presentation of the picture would be ideal. I tried to build on the code of the voicekey trigger example, but I get stuck at the point where I need to write the data to a wave file. The only way I've seen this done is by using the wave library (import wave), but OpenSesame complains when I put that in the code..
Any help appreciated.
Martijn
Comments
Hi Martijn,
Thanks!
As luck would have it, the PyAudio documentation has an example that does exactly what you want to do, and it simply works (for me) if you paste it into an OpenSesame inline_script.
I changed it a tiny bit to use the subject_nr and count_inline_script to determine the output file name, but aside from that the example comes straight from: http://people.csail.mit.edu/hubert/pyaudio/
Good luck!
Sebastiaan
Hi Sebastiaan,
Thanks for the reply, I tried your script (and my own script that looks very much the same), but Opensesame complains it cannot find pyaudio (on my mac) and on windows it can't find the wave module:
Traceback (most recent call last):
File "libopensesame/inline_script.pyc", line 112, in run
File "", line 3, in
ImportError: No module named pyaudio
Traceback (most recent call last):
File "libopensesame/inline_script.pyc", line 112, in run
File "", line 3, in
ImportError: No module named wave
Do I need to install something separately?
Thanks again,
Martijn
Ah right, of course, the 'wave' module isn't included! You cannot really install additional packages when using the binary distribution, but you can when using the Python portable package. I haven't done this myself, but Edwin will probably be able to help you, if you ask him on the forum:
Alternatively: I'll also include the module in the next pre-release of OpenSesame, so you could wait until 0.26-pre7 (or later) appears and you could use that.
Thanks, I'll look into the portable package. Is the pyaudio package also not included in the mac version, because that is the point where OpenSesame stops on my mac.
Indeed, PyAudio is not included in the Mac OS package. I'll make a note of it, because I think it should be included by default.
That would be great, being able to record (chunks of) speech would, especially in combination with voicekey measurements, be very welcome to a lot of people in psycholinguistics and experimental linguistics.
Just to let you know; I tried this with 0.26 pre and it works in Ubuntu, but not in windows yet (probably because the wave module hasn't been included there yet). I haven't tested it on the mac yet.
You rang?
PyAudio is a single Python-file, right? Simply add it to this directory *\opensesameportable-0.25-1-win32\PortablePython_1.1_py2.6.1\App\Lib\site-packages of the portable 0.25 version (downloadable here: http://cogsci.nl/esdalmaijer/ ) and you should be ready to experiment! Same goes for the 0.26 (pre6) portable version, since I haven't included PyAudio in that one as well.
Please do let me know if it works, I do not have PortAudio installed, so I can't check.
Cheers!
Hi Edwin,
Sorry for the late reply. Work got in the way. That is a great suggestion and I will try it as soon as I get the change. On the other hand, I understand that the next version of Opensesame will support pyaudio and wave, so the problem might soon be solved by default. Nevertheless it is good to know that it is fairly easy to plugin additional python modules in portable Opensesame.
Thanks again for your reply, and I'll keep you posted,
Martijn
Hi All,
It's me again. I just tested speech recoding with EE. Works like a charm!
Martijn
Dear Sebastiaan, (and Edwin and goodbeem)
I have been playing around with OpenSesame for a while now: not a coding-savvy experimenter, I enjoy it immensely. Lovely job, thank you so much!
I am putting together a phonetics study and want to record the sentences read from dialogues of four lines. However, the utterances will vary in length, and so the recording should run until 'keypress', at which point the next line would be played back:
so, how would I include this keypress feature here?
regarding the multi-line display, I posted a question in the (inactive) "text which appears" thread.
Thanks again for the efforts with this great tool.
Hi Christerwi,
You can change the stop criterion to anything you like. Above it was a fixed duration, but the code below shows how you can stop recording after a key has been pressed. This script is just a snippet that you need to combine with the recording part of the full script posted above.
For more information on keyboard functions, see also http://osdoc.cogsci.nl/python-inline-code/keyboard-functions
Good luck!
Cheers,
Sebastiaan
Hi everyone, I tried to follow the instructions here using a Mac OS installation and encountered some problems, detailed in this thread:
http://forum.cogsci.nl/index.php?p=/discussion/comment/699#Comment_699
The relevant part is copied here:
"I installed PyAudio using the mpkg script provided on the PyAudio site, and then I went through the process again and did the manual installation with PortAudio. Either way I do it, I get the same error: "ImportError: No module named pyaudio".
I have gone through the process of copying the pyaudio installation to the directories listed in the prefs under Plug-In folders, a few of which had to be created because the installation doesn't seem to generate them, and even after a restart, opensesame.app cannot find the installation of pyaudio."