Specifying stop duration value with mic component causes Psychopy to crash with no error message

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): MacBook Pro macOs Mojave version 10.14.5
PsychoPy version (e.g. 1.84.x): 3.1.5
**Standard Standalone? yes

Hi all,

I know there are some bugs with the mic component and pyo integration. For me, Psychpy is crashing when I specify a stop duration value with the mic component. Interestingly, when I do not specify a stop duration value, Psychopy does not crash. But, when I do not specify a stop duration for the mic component, the experiment produces an empty .wav file (as designed I think). Therefore, I add a stop duration and I am able to stop the recording once it is finished by adding a code component to each frame. Pyo is also listed first in preferences.

This actually works for the first few trials (it produces .wav files that have the recordings in them)! But after a few trials, psychopy crashes and does NOT produce an error. All I get it:

Running: /Users/mayarose/Dropbox/MAYA Turkish Project/TurkishExperiments/TestRunFolder_P3/TurkishExp_071519_lastrun.py
pyo version 0.8.8 (uses single precision)
Unknown audio type. Using Portaudio
2019-07-15 12:16:17.395 python[872:21542] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)

This is what i have done to further investigate:

  1. Left stop duration field blank on mic component and did not crash and therefore stop duration specification is most likely contributing to crash
  2. Updated to Psychopy 3.1.5 and still crashed (I did this because i know there have been some fixes to the microphone component)
  3. I am using a MacbBook Pro 10.14.5 and am testing the experiment using the built-in microphone which is mono. I set the mic component to default channel = 0 (not stereo). When i change the channel value to 1 or 2, it does not change anything and it still crashes.
  4. Removing and re-adding mic components did not help
  5. Specifying stop duration in mic component but getting ride of code component did not change anything either.
  6. Adding ‘directsound’ to audio driver in Psychopy preferences with stop duration specified and experiment crashed again on the 5th trial (and again produced no error message)

I really appreciate your help and let me know if you have any questions. I have attached the script to this post as well. Thanks!

TurkishExp_071519.psyexp (100.5 KB)

It looks like I have resolved this problem. I think the issue stemmed from the fact that I was using a .key component to force end the microphone component AND move onto the next routine. Therefore, the system crashed because the .wav file did not have enough time to wrap and conclude before the next routine.

The way I have prevented this crash is by first specifying the start and stop duration for the mic component (I did this before). In this case, the stop duration would be something like 4 seconds. I still have the .key component in case the recording is finished before 4 seconds. Then I have another mouse component (could be another key component too) in place to end the routine. The important thing though is that this component does not start at the same time the microphone component ends. I have made it so the mouse component (to end the routine) starts a second after the mic component ends. This gives the .wav file enough time to wrap and end. I think it could be .5 seconds but just as long as you have some time between the end of the mic component and the component that force ends the routine. See screenshot of the routine below.

Overall, I think it is important to not have the same component to end the mic component and end the routine. It is better to have two separate components for this.

I’m having the same problem (plus some additional issues with my external mic), and I’m trying to figure out how to adapt your solution to my experimental needs. I tried making the mic component duration shorter, and if I run the experiment without pressing the key to end the routine until after the recording is finished, it runs fine and doesn’t crash. However, for the purposes of this experiment, I want participants to be able to end the recording as soon as they’re finished speaking, since there is a wide range of stimuli lengths.

You said you have separate key components to end the recording and to end the routine. I’m pretty new to this, and I can’t quite figure out how to get a key component to end the recording and not the routine. How did you do this in the Builder? An alternative configuration that would work for me would be a key component ending the recording immediately and then automatically ending the routine a second later (the same key component), but I don’t know if this is possible or if it would still solve the problem.

Do you have any suggestions about how I could adapt this solution?

On your .key component that you use to end the recording, UNCLICK the “force end of Routine” option within the component. Then add another component like a mouse for the purpose of force ending the routine. So the participant would:

  1. Record
  2. press something like ‘q’ when they finish
  3. click the mouse to move to next routine.

Let me know if that works. i know it is sort of clunky but that’s how i am getting it to work…for the time being at least!

How do I specify which component the key component is ending? If I uncheck “force end of Routine”, then the key component does nothing. It seems like the only options for the key component is to record a key-press response or the end the whole routine. I’m not sure how you got two different keys to end two different parts of the same routine.

Apologies if the answer is something obvious that I missed!

Good question. For the key response, or any response to end the mic component, you actually have to include a code component (each frame). You can see that I have that in the picture I added above. Psychopy actually details this nicely on their website: http://www.psychopy.org/builder/components/microphone.html

So then you have a key component to end the .mic and then another component to move onto next routine. Hope this makes sense.

Hello

I would like to report a similar issue, originally posted as “Mic does not record the first few trials, then it does record the rest ok” (full details there)

As far as I can tell, the issue I observe is not solved by the suggestions above .

I my script,

I have noted that int the first few trials, an empty wave file of the right duration is generated. After a few trials (between 3 and 5 in various tests), the recording starts to work properly midway during the 2 sec window. From there on, all the trials (~15 in the test) are perfectly recorded.

I have added an “empty padding” after the end of the fixed mic recording duration, as suggested, followed by another stimulus (empty picture) that terminates the trial:

The “bug” (i.e. empty recording for the first few trials) occurs for gap duration that I have changed between .1 and 1 second (longer duration would be too long for the experimental protocol)

Thanks in advance for any advice, Xavier