Re: [psychopy-users] Experiment crash with microphone capture

697 views
Skip to first unread message

Jeremy Gray

unread,
Apr 8, 2013, 7:41:28 PM4/8/13
to psychop...@googlegroups.com
Hi Alain,

I am not sure what is happening, but it sounds frustrating. I don't
think its the mere number of recordings -- I've done several thousand
before. These were very short recordings, for testing purposes.

Can you tell us more about how you are trying to do the recording
(Builder or Coder? version of PsychoPy, operating system?) The error
messages you posted are non-specific, and so are not at all helpful
(through no fault of yours).

--Jeremy


On Mon, Apr 8, 2013 at 3:01 PM, alain parra <alain...@gmail.com> wrote:
> Hi my name's Alain,
> I'm french. I'm working for the psychology department in Marseille
> University.
>
> I need your help... Because I'm a begginer in psycholgy experiment
> programing.
>
> I need to build up a Stroop Task exp with sound recording (arround 170
> trials).
> PsychoPy is great for that : very simple and powerfull.
>
> But I have a problem, when I run my experience every things ok until a
> sudden crash.
> It always appears between the trial 15 and 30, and give me tihs message :
>
> ### Running: /Users/alainparra/Desktop/stroopExtended/STROOPclic_lastrun.py
> ####
> pyo version 0.6.1 (uses single precision)
> PortMidi warning: No midi device found!
> Portmidi closed
> 2013-04-08 20:47:45.225 python[2050:707] PyObjCPointer created: at
> 0xac1beda8 of type {__CFBoolean=}
> 2013-04-08 20:47:45.226 python[2050:707] PyObjCPointer created: at
> 0xac1beda0 of type {__CFBoolean=}
> 2013-04-08 20:47:45.227 python[2050:707] PyObjCPointer created: at
> 0xac1bedb0 of type {__CFNumber=}
> 2013-04-08 20:47:45.228 python[2050:707] PyObjCPointer created: at
> 0xac1bedc0 of type {__CFNumber=}
> 2013-04-08 20:47:45.228 python[2050:707] PyObjCPointer created: at
> 0xac1bedd0 of type {__CFNumber=}
> Fatal Python error: (pygame parachute) Bus Error
>
>
> Really I don't understand... Because the few ".wav files" recorded are ok
> (there is sound in it...).
> I have the feelings it's because it represents a too many extract files for
> PsychoPy.
> How can I do to solve my problem.
>
> Thanks by advance.
> Best regards
>
> Alain
>
> --
> You received this message because you are subscribed to the Google Groups
> "psychopy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to psychopy-user...@googlegroups.com.
> To post to this group, send email to psychop...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/psychopy-users/-/m_eTbAqYPZoJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

alain parra

unread,
Apr 10, 2013, 6:14:55 PM4/10/13
to psychop...@googlegroups.com
Hi Jeremy,

thanks for your fast answer. You're right... I'm frustrated !!! :)
Mainly because I'm not good at progamming

Ok, I'll try to give you more details (I joint to the mail all my experiment files. I don't know if it can help you... just in case).
First, I use psychoPy2 1.75.01 (I tried 1.76 version, but I couldn't even run my expriment because it gives me an error system with the microphone. I can't tell you the right message because I uninstalled this version).
I'm working on a MacBook Pro (end of 2010) with 8Go RAM.
And I can only use this soft with Bulder part (I'm not able to do that with the Coder).

So, I want to pass a Stroop task experiment, but instead of recording reaction time by keyboard, I want recording voice reponse.
To do that, I want that the microphone strats to record at the time of stimulus emergences and stays open for 1 sec.
To finish the loop and passe to next trial, we use keyboard or mouse (Force end of routine). This "option" becomes available at the end of this second of recording.

Like I said, apparently, everything run... but after 20-22 trials, big crush appears.

I hope I was understable and gave you enough details.
Thanks by advance for your help.

Alain
STROOPclic.psyexp
STROOPclic.py
STROOPclic_lastrun.py

Jeremy Gray

unread,
Apr 10, 2013, 7:39:19 PM4/10/13
to psychop...@googlegroups.com
Hi Alain,

This may be even more frustrating: I ran 100 trials and your script
was fine for me. This is on a macbook pro retina 2012, OS 10.8.3, with
PsychoPy 1.76 + recent fixes, pyo 0.6.4 (for sound recording). I had
to make a conditions file, Item.xlsx, with one trial type (red red),
should be good enough to test this out. So I think your programming is
good :-)

I don't really know what to suggest at this point, other than trying
to upgrade to 1.7.6. Your mac sounds a bit older for a laptop but
should be fine.

Be aware that the start of the recording is not perfectly syncronized
to the time at which the word is shown on the screen and the recording
is started (if you care about exact RT-from-voice). I am working on a
way to get more accurate RT from recordings like this.

--Jeremy
> https://groups.google.com/d/msg/psychopy-users/-/qRsEPf-DtQ0J.

Joseph

unread,
Apr 10, 2013, 9:37:44 PM4/10/13
to psychop...@googlegroups.com
Im also getting an error after updating. This is what it looks like:

 Running: /Users/casillas/Desktop/120228_experiments/1_english_production/english_production_lastrun.py 
pyo version 0.6.1 (uses single precision)
Traceback (most recent call last):
  File "/Users/casillas/Desktop/120228_experiments/1_english_production/english_production_lastrun.py", line 45, in <module>
    microphone.switchOn()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.6/psychopy/microphone.py", line 636, in switchOn
    sound.initPyo(rate=sampleRate) #will automatically use duplex=1 and stereo if poss
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.6/psychopy/sound.py", line 515, in initPyo
    class Server(pyo.Server):
NameError: global name 'pyo' is not defined

Any ideas? Thanks. 

Jeremy Gray

unread,
Apr 10, 2013, 10:26:26 PM4/10/13
to psychop...@googlegroups.com
I get an error like this. An easy work-around (works for me at least)
is to set your preferences > general > audioLib to be u'pyo' as the
first thing in the list (instead of pygame first).

--Jeremy
> https://groups.google.com/d/msg/psychopy-users/-/3g9UftpWFhEJ.

Jeremy Gray

unread,
Apr 18, 2013, 11:42:42 AM4/18/13
to psychop...@googlegroups.com
Hi David,

Its great to have a phonetician interested in PsychoPy. Your feedback
will be very useful. There are likely to be some rough edges here and
there, especially with sound, which is under active development. I am
personally interested in recording speech for my own research.

Unfortunately I don't know how to help with that error. I am pretty
sure that the character 0xe9 is the character "é", and its in one or
more of your system's names for sound settings, somehow. The PsychoPy
code that has trouble appears to be "prefDriver in devString". When I
try this construction on my mac using the "é" character, everything is
fine. So I don't really have a way to test or debug this, even in the
abstract. If its possible for you to check your system settings (and
psychopy settings) and remove any of those characters, its worth a
try.

--Jeremy


On Thu, Apr 18, 2013 at 9:30 AM, David Le Gac <david....@gmail.com> wrote:
> Hi,
>
> Thanks Alain, Joseph and Jeremy for the messages.
> I am a phonetician and (crucially) need to run experiments with sound
> recording.
> I am using PsychoPy 1.76.00 on a PC (Dell) with windows 7
> I also got the same error message as Joseph ("NameError: global name 'pyo'
> is not defined") and then changed the settings in my preferences as
> indicated by Jeremy.
> But now, I get the following error message when running the voicecpature
> demo (I'm beginning with Psychopy and programming...):
> Thank for the help !!
>
> *********************
> Running: C:\Users\DAVIDLEGAC\Documents\PsychoPy2
> Demos\voiceCapture\voiceCapture_lastrun.py
> pyo version 0.6.2 (uses single precision)
> Traceback (most recent call last):
> File "C:\Users\DAVIDLEGAC\Documents\PsychoPy2
> Demos\voiceCapture\voiceCapture_lastrun.py", line 45, in <module>
> microphone.switchOn()
> File "C:\Program Files
> (x86)\PsychoPy2\lib\site-packages\psychopy-1.76.00-py2.7.egg\psychopy\microphone.py",
> line 636, in switchOn
> sound.initPyo(rate=sampleRate) #will automatically use duplex=1 and
> stereo if poss
> File "C:\Program Files
> (x86)\PsychoPy2\lib\site-packages\psychopy-1.76.00-py2.7.egg\psychopy\sound.py",
> line 538, in initPyo
> audioDriver,outputID=_bestDriver(devNames, devIDs)
> File "C:\Program Files
> (x86)\PsychoPy2\lib\site-packages\psychopy-1.76.00-py2.7.egg\psychopy\sound.py",
> line 504, in _bestDriver
> if prefDriver in devString:
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1:
> ordinal not in range(128)
>
> *********************
> https://groups.google.com/d/msg/psychopy-users/-/CvRjXQdKFZQJ.

David Le Gac

unread,
Apr 18, 2013, 1:18:24 PM4/18/13
to psychop...@googlegroups.com
Hi Jeremy, 

Thanks for your very fast answer !
Yes, phoneticians need to carry out speech production and/or perception experiments and I am happy to have found psychopy for my research. It's great that the sound device is under development !
The voicecapture demo actually worked on my computer with psychopy 1.74 but i have upgraded it this morning.
I have tried to find these "é" but without success until now. What does "prefDriver in devString" mean? Where can I find those system settings ? 

Thank you !

David

Jeremy Gray

unread,
Apr 18, 2013, 5:12:19 PM4/18/13
to psychop...@googlegroups.com
Hi David,

I am not sure what it should look like. "prefDriver in devString" is
trying to find the preferred driver from a list of available devices.
To see these:

1. From a python shell (see Coder window), type (no quotes) "import
pyo; print pyo.pa_get_output_devices()" and then also
"pyo.pa_get_input_devices()". what does it report? my guess is that
somewhere here will be an "é".

2. Also, in the preferences dialog, there is now a box for audioDriver
-- what does it say there?

--Jeremy
> https://groups.google.com/d/msg/psychopy-users/-/UWmiYm-Xg10J.

David Le Gac

unread,
Apr 18, 2013, 5:59:21 PM4/18/13
to psychop...@googlegroups.com
Hi,

Thanks, 

2) in the preferences dialog, the box for audioDriver says : "[u'Primary Sound', u'ASIO', u'Audigy']" 

1) here is the output in the shell : 
>>> import pyo; print pyo.pa_get_output_devices()
(['Mappeur de sons Microsoft - Output', 'Haut-parleurs (Realtek High Def', 'P\xe9riph\xe9rique audio principal', 'Haut-parleurs (Realtek High Definition Audio)'], [2, 3, 6, 7])
>>> pyo.pa_get_input_devices()
(['Mappeur de sons Microsoft - Input', 'Microphone (Realtek High Defini', 'Pilote de capture audio principal', 'Microphone (Realtek High Definition Audio)'], [0, 1, 4, 5])

there are no "é" but the hieroglyphic codes (for me) indeed ! In French, 'P\xe9riph\xe9rique' is normally written with "é" ('périphérique'). is there any relation ? 
What do I have to do ? (i am a real beginner in programing and wouldn't like to do something wrong...)

thanks !

David 

Jeremy Gray

unread,
Apr 18, 2013, 7:06:51 PM4/18/13
to psychop...@googlegroups.com
> 2) in the preferences dialog, the box for audioDriver says : "[u'Primary
> Sound', u'ASIO', u'Audigy']"

ok, I think it looks ok

> 1) here is the output in the shell :
>>>> import pyo; print pyo.pa_get_output_devices()
> (['Mappeur de sons Microsoft - Output', 'Haut-parleurs (Realtek High Def',
> 'P\xe9riph\xe9rique audio principal', 'Haut-parleurs (Realtek High
> Definition Audio)'], [2, 3, 6, 7])

ah ha!

>>>> pyo.pa_get_input_devices()
> (['Mappeur de sons Microsoft - Input', 'Microphone (Realtek High Defini',
> 'Pilote de capture audio principal', 'Microphone (Realtek High Definition
> Audio)'], [0, 1, 4, 5])
>
> there are no "é" but the hieroglyphic codes (for me) indeed ! In French,
> 'P\xe9riph\xe9rique' is normally written with "é" ('périphérique'). is there
> any relation ?

I think this it it! Now we have to figure out how to work with it.

What happens if you paste these lines into the python shell (do
include the single quotes):
'P\xe9riph\xe9rique audio principal' in 'abc'

'périphérique audio principal' in 'abc'

Both should say False.

--Jeremy
> https://groups.google.com/d/msg/psychopy-users/-/gaDicoh_YZwJ.

Jeremy Gray

unread,
Apr 18, 2013, 10:35:32 PM4/18/13
to psychop...@googlegroups.com
Here's one thing to try: Add a code component somewhere in your
experiment, and in the "Begin experiment" box put this code:

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

This seems to be a trick that can sometimes work, not the ideal solution.

David Le Gac

unread,
Apr 19, 2013, 3:10:20 AM4/19/13
to psychop...@googlegroups.com
Hello , 

I pasted the two lines in question ('P\xe9riph\xe9rique audio principal' in 'abc'  / 'périphérique audio principal' in 'abc' ) and yes, both say 'false'

as for the code to put in the "begin experiment" box, it doesn't work...i have the same error message (in the voicecapture demo experiment and in my own test experiment):
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1: ordinal not in range(128)"
  
David

Jeremy Gray

unread,
Apr 19, 2013, 6:58:20 AM4/19/13
to psychop...@googlegroups.com
Hmmm, interesting. I'm not sure what to make of that. I did not expect
it to work (!)

Here's what is hopefully an easy way to work around the problem, as a
temporary solution. It might not give you the output device you want,
but its easy to try. Set preferences > audioDriver to include one of
these strings *as the first item* in the list. (The [ ] makes it a
list.)

u'Mappeur de sons Microsoft - Output'
u'Haut-parleurs (Realtek High Def'

My hope is that one of these two will succeed, and so it will never
even try to do the one that is causing problems.

--Jeremy
> https://groups.google.com/d/msg/psychopy-users/-/7uJoA0S7fqAJ.

David Le Gac

unread,
Apr 19, 2013, 9:00:54 AM4/19/13
to psychop...@googlegroups.com
Here is what I get when I include these strings, it's the same error message for these two : 

 Running: C:\Users\DAVIDLEGAC\Documents\PsychoPy2 Demos\voiceCapture\voiceCapture_lastrun.py 
pyo version 0.6.2 (uses single precision)
Traceback (most recent call last):
  File "C:\Users\DAVIDLEGAC\Documents\PsychoPy2 Demos\voiceCapture\voiceCapture_lastrun.py", line 45, in <module>
    microphone.switchOn()
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.76.00-py2.7.egg\psychopy\microphone.py", line 636, in switchOn
    sound.initPyo(rate=sampleRate) #will automatically use duplex=1 and stereo if poss
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy-1.76.00-py2.7.egg\psychopy\sound.py", line 546, in initPyo
    junk, inputID=_bestDriver(devNames, devIDs)
TypeError: 'NoneType' object is not iterable




2013/4/19 Jeremy Gray <jrg...@gmail.com>
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/1jSw2v_82PE/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.

To post to this group, send email to psychop...@googlegroups.com.



--
David Le Gac
Maître de conférences
Université de Rouen - Laboratoire DySoLa
IRED - 7, rue Thomas Becket
76821 Mont Saint Aignan Cedex - France
http://www.univ-rouen.fr/10597/0/fiche_annuaire/
Tél: 02 35 14 60 58
Fax: 02 35 14 69 40

Jeremy Gray

unread,
Apr 19, 2013, 9:13:05 AM4/19/13
to psychop...@googlegroups.com
well, I think this is progress -- its getting past the output speaker
selection, and now crashing on the microphone input selection.

try adding your favorite (or all) of the following strings to that
same list, in preferences > audioDriver

'Mappeur de sons Microsoft - Input', 'Microphone (Realtek High
Defini', 'Pilote de capture audio principal', 'Microphone (Realtek
High Definition Audio)'

David Le Gac

unread,
Apr 19, 2013, 9:49:14 AM4/19/13
to psychop...@googlegroups.com
it almost works ! 
I put all the strings first and then the first one only ('mappeur de sons Microsoft - Input')
there were no more crashes, two sound files have been saved each time (I ran the voiceCapture demo) but no sound in it...
The output window appears with this message: 
"Running: C:\... path to the demo... \voiceCapture_lastrun.py
pyo version 0.6.2 (uses single precision)"



2013/4/19 Jeremy Gray <jrg...@gmail.com>

Jeremy Gray

unread,
Apr 19, 2013, 10:19:53 AM4/19/13
to psychop...@googlegroups.com
cool! It looks like it can find 4 different hardware sound input
devices to choose from. Is it possible that the one PsychoPy is
choosing is not activated somehow, e.g., not selected in you system
settings (in Windows, not PsychOpy), or not turned on, etc?

Jeremy Gray

unread,
Apr 19, 2013, 10:32:11 AM4/19/13
to psychop...@googlegroups.com
PsychoPy will use the first device in the audioDriver list (the list =
"requested" drivers) that also appears to be valid on the system (=
"available" drivers). So the one you want to use needs to come first
in the list.

David Le Gac

unread,
Apr 19, 2013, 11:04:00 AM4/19/13
to psychop...@googlegroups.com
It works ! 
with this string in the audiodriver box :
[u'Mappeur de sons Microsoft - Output', 'Microphone (Realtek High Defini', 'Pilote de capture audio principal', 'Microphone (Realtek High Definition Audio)', u'Primary Sound', u'ASIO', u'Audigy']

but it didn't work when I put "'Mappeur de sons Microsoft - Input' " first (I don't know what this exactly means...) 

The "Realtek High Definition Audio" microphone is the "by default peripheric" (as indicated in the configuration pannel > sound)

Thanks a lot for your help !!



2013/4/19 Jeremy Gray <jrg...@gmail.com>

alain parra

unread,
Apr 23, 2013, 4:47:56 PM4/23/13
to psychop...@googlegroups.com
Hi Jeremy,

excuse me for the delay of my answer... I was traveling.
So I did what you suggest me and updated psychopy to 1.76
I fix the microphone problem like you suggested us (audiolib trick...).
and change one PsychoPy preference : winType "pyglet" to "pygame".
And now it works...

So thank you very much for your help !!!
bye

alain

Jeremy Gray

unread,
May 8, 2013, 3:26:10 PM5/8/13
to psychop...@googlegroups.com
Hi Nastya,

There will be a new version of PsychoPy, maybe next week. Hopefully this will be fixed in that version.

In the meantime, you might try taking one of the outputs from  this:
>>>pyo.pa_get_input_devices()
(['\xcf\xe5\xf0\xe5\xed\xe0\xe7\xed\xe0\xf7\xe5\xed\xe8\xe5 \xe7\xe2\xf3\xea\xee\xe2\xfb\xf5 \xf3\xf1\xf2\xf0. - Input', '\xcc\xe8\xea\xf0\xee\xf4\xee\xed (Realtek High Definiti', '\xcf\xe5\xf0\xe2\xe8\xf7\xed\xfb\xe9 \xe4\xf0\xe0\xe9\xe2\xe5\xf0 \xe7\xe0\xef\xe8\xf1\xe8 \xe7\xe2\xf3\xea\xe0', '\xcc\xe8\xea\xf0\xee\xf4\xee\xed (Realtek High Definition Audio)'], [0, 1, 5, 6])

such as:  '\xcc\xe8\xea\xf0\xee\xf4\xee\xed (Realtek High Definiti'

and enter it as an audio driver. also try it with a 'u' in front (for unicode), like this:  u'\xcc\xe8\xea\xf0\xee\xf4\xee\xed (Realtek High Definiti'

Could you please tell me, what audiodriver should I put in the audioDriver preference box to make it work? I tried this [u'Realtek Digital Output (Realtek High Definition Audio)', u''Realtek Digital Output (Realtek', u'Primary Sound', u'ASIO', u'Audigy'] but it didn't work and keeps giving me the same error message.

yes, these were from David's machine, not available on yours.

--Jeremy

Nastya Fedorova

unread,
May 8, 2013, 11:56:50 PM5/8/13
to psychop...@googlegroups.com
Hello, Jeremy,

I've tried all outputs (with and without 'u' before output), but unfortunately it doesn't work. I will wait for a new version.

Thank you for a quick answer and your help!

Nastya


--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/1jSw2v_82PE/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.

To post to this group, send email to psychop...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages