# Experiment crashes due to audio stream not started

**URL:** https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157
**Category:** Builder
**Created:** [November 24, 2021, 10:47am UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157 "2021-11-24T10:47:10Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Sol1](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@Sol1](https://discourse.psychopy.org/u/Sol1)
#### Post date: [November 24, 2021, 10:47am UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157/1 "2021-11-24T10:47:10Z")

</div>

**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   
mic.stop()  
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.  
Best,

Solveig

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [November 24, 2021, 12:35pm UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157/2 "2021-11-24T12:35:44Z")

</div>

> [@Sol1](#):
>
> mic.stop()

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

---

<div class="post-metadata">

### Author: ![Sol1](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@Sol1](https://discourse.psychopy.org/u/Sol1)
#### Post date: [November 24, 2021, 12:52pm UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157/3 "2021-11-24T12:52:07Z")

</div>

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.start()
            mic.status = STARTED
        if mic.status == STARTED:
            # update recorded clip for mic
            mic.poll()
        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.stop()
                mic.status = FINISHED

```

Or should I look for this elsewhere?

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [November 24, 2021, 1:33pm UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157/4 "2021-11-24T13:33:00Z")

</div>

Does mic appear in any custom code components?

---

<div class="post-metadata">

### Author: ![Sol1](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@Sol1](https://discourse.psychopy.org/u/Sol1)
#### Post date: [November 24, 2021, 1:43pm UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157/5 "2021-11-24T13:43:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josejperez](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/josejperez/32/32084_2.png) [@josejperez](https://discourse.psychopy.org/u/josejperez)
#### Post date: [December 20, 2021, 2:25pm UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157/6 "2021-12-20T14:25:37Z")

</div>

Hi there!

did you find any solution to this issue?

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

---

<div class="post-metadata">

### Author: ![Sol1](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@Sol1](https://discourse.psychopy.org/u/Sol1)
#### Post date: [December 21, 2021, 7:47am UTC](https://discourse.psychopy.org/t/experiment-crashes-due-to-audio-stream-not-started/26157/7 "2021-12-21T07:47:22Z")

</div>

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