"Cannot stop a stream that has not been started.") psychopy.sound.exceptions.AudioStreamError: Cannot stop a stream that has not been started

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

PsychoPy version (e.g. ): 2021.2.3
Standard Standalone? (y/n) If not then what?:y
**What are you trying to achieve?:**I want to record the subjects’ recordings normally and keep them

**What did you try to make it work?:**I tried to modify the script, but no recording file was saved.
**I referred to this link:**Issues with microphone recordings: AudioStreamError: Cannot stop a stream that has not been started

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

My question is: how can the micphone work properly and save the recording file

I came across the same error. In my case, the routine, during which sound was recorded, was ended with a key stroke. There was no end time for the microphone component and it seems this was the problem.

My solution: I entered a very long end time for the microphone component, which was longer than the time the module could run. I guess this solved the issue because the mic component never had the chance to call mic.stop() so when the second mic.stop() is called (whereever this comes from), it still has a stream to stop and does not complain.

In my case, I set the mic component to a duration of 31 sec and added a code component with

if t >= 30:
continueRoutine = False
in the “Each frame” tab.

The audio files seem to be only saved if the entire task runs to the end. Not sure if this is related of not ever reaching the mic component’s end but that’s the best I could get to.