Experiment crashes due to audio stream not started

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2021.2.3
Standard Standalone? (y/n) : Y
What are you trying to achieve?:
I have a routine that shows participants first a word printed on the screen and then an image. The microphone is supposed to start when the image appears (frameN 69) and record participants responses for a duration of 6seconds.
However, the experiment keeps crashing after the first trial and gives the following error:

Traceback (most recent call last):
File “C:\Exp1\Exp1_lastrun.py”, line 2050, in
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\microphone.py”, line 803, in stop
“Cannot stop a stream that has not been started.”)
psychopy.sound.exceptions.AudioStreamError: Cannot stop a stream that has not been started.

What did you try to make it work?:
I have tried changing the starting frame for the recording and looked at the lastrun python file to see if anything is missing but I am afraid I have no idea where the issue is coming from and I would not know what needs fixing. I also looked at the code components of the naming and voice key demos but it is not helping (it does not change the outcome and I am not sure what their code components actually do).

Has anyone run into the same issue? Should I be adding a code component to the builder view to start the stream? I am really not familiar with coding so any help is appreciated.


Is mic.stop() being run before frameN 69?

I don’t think so. This is what I see in the lastrun file:

mic updates

        if mic.status == NOT_STARTED and frameN >= 69:
            # keep track of start time/frame for later
            mic.frameNStart = frameN  # exact frame index
            mic.tStart = t  # local t and not account for scr refresh
            mic.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(mic, 'tStartRefresh')  # time at next scr refresh
            # start recording with mic
            mic.status = STARTED
        if mic.status == STARTED:
            # update recorded clip for mic
        if mic.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > mic.tStartRefresh + 6.0-frameTolerance:
                # keep track of stop time/frame for later
                mic.tStop = t  # not accounting for scr refresh
                mic.frameNStop = frameN  # exact frame index
                win.timeOnFlip(mic, 'tStopRefresh')  # time at next scr refresh
                # stop recording with mic
                mic.status = FINISHED

Or should I look for this elsewhere?

Does mic appear in any custom code components?

No I have not used any custom code in the experiment builder.

Hi there!

did you find any solution to this issue?

I am getting the same “Cannot stop a stream that has not been started.”

Hi! Unfortunately, I have not been able to figure out what the issue is or how to fix it yet.