Microphone AttributeError only in the second half of an experiment

Hi Everyone,

I am working on a speech repetition task where a person hears a sentence played through the speakers and repeats that sentence aloud while being recorded by the microphone.

The experiment works fine during the first set of speech repetition trials (Points 1 to 6 in the image below) accompanied by instruction text.

Then, when the same repetition trial comes back a second time (under “ERROR” in the image below), I get the error AttributeError: ‘Stream’ object has no attribute ‘handle’.

It’s the same recording trial that is working on the first half of the experiment, and then gives an error. I don’t undertand why.

I have tried the following two audio settings, both gives the same error.

(1) Error with this setting

9_27_2022_psychopy_setting1

(2) Error with this setting as well

9_27_2022_psychopy_setting2

I am attaching the output I get:

Running: C:\Users\dl942\Documents\exps\2022_exps\2022_4_rnor_pilot\rnor_pilot_01_09_en_exp_lastrun.py

1006.1637 EXP Imported rnor_en_cond.xlsx as conditions, 12 conditions, 1 params
1006.1650 INFO Loaded monitor calibration from [‘2021_10_29 13:19’]
1006.1966 EXP Imported rnor_en_cond.xlsx as conditions, 12 conditions, 1 params
pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. Contribute - pygame wiki
PTB-ERROR: Failed to open audio device 7. PortAudio reports this error: Invalid device
Traceback (most recent call last):
File “C:\Users\dl942\Documents\exps\2022_exps\2022_4_rnor_pilot\rnor_pilot_01_09_en_exp_lastrun.py”, line 186, in
stim_mic = sound.microphone.Microphone(
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\sound\microphone.py”, line 478, in init
self._stream = audio.Stream(
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 97, in init
self.handle = PsychPortAudio(‘Open’, device_id, mode,
Exception: Failed to open PortAudio audio device due to unsupported combination of audio parameters.
Exception ignored in: <function Stream.del at 0x000002E173FA4160>
Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 236, in del
self.close()
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 146, in close
raise err
File “C:\Program Files\PsychoPy\lib\site-packages\psychtoolbox\audio.py”, line 139, in close
PsychPortAudio(‘Close’, self.handle)
AttributeError: ‘Stream’ object has no attribute ‘handle’
################# Experiment ended with exit code 1 [pid:2720] #################

Any help would be much appreciated.
Thank you.
Dan