Audio problem: " 'Stream' object has no attribute 'handle' "

win10
PsychoPy version 2021.2.1
Standard Standalone
**What are you trying to achieve?: use some audio and recording function

What specifically went wrong when you tried that?:
there seems some problem with psychopy, not my building program. It says like this:
PsychPortAudio(‘close’, self.handle)
AttributeError: ‘Stream’ object has no attribute 'handle’

thanks a lot if you can give me your help !!!

I actually have the same problem when I run my experiment locally with the PsychoPy Builder but it works when I run it online on Pavlovia. So if that is an option for you, you might want to try that. But unfortunately, not all the PsychoPy features are supported online.
I think this “‘Stream’ object has no attribute 'handle’” is only a part of the error message. If you scroll up, you can maybe find more helpful information. For me, for example, it says something about “unsupported combination of audio parameters”.

Thank you for your reply!
But I still can’t fix this problem when I try to run it online on Pavlovia.
Because it will show more problems such as downloading resources, so weired!

I actually managed to fix the microphone problem in my experiment also when running it offline in PsychoPy by doing two things:

  • changing the sample rate from 16kHz to 44.1kHz (click on microphone component and then change the sample rate under the tab “Hardware”)
  • disabling all microphone components except for one (only relevant if you have more than one microphone component in your experiment)

Maybe these changes will help you too.

I think the problem with the resources is not caused by the microphone component but by e.g. image files, csv files or other files that your experiment is using. I’ve also seen this error before and, if I remember correctly, I solved it by adding the file paths under experiment settings (the gear icon in PsychoPy Builder) > online > additional resources.

Thank you very much! It helps me a lot. Now I can run my experiment offline after chaging the sample rate.

By the way, I still encounter “unable to download resourse” problem after doing what you have said, and the error is an image(.png), it’s in one of my experiment loops. So I still do not know what’s the matter. Glad if you can answer me again~

Thanks a lot!!!

Plus, just as you said, I can only run my experiment ‘disabling all microphone components except for one’, but it is not an ideal solution to me, because I have to use more than one microphone component.

So I was wondering if there are better solutions so that I can use many microphone component in one experiment. :face_with_raised_eyebrow:

Thank you!

There are probably a lot of things that could cause the problem with the resources. Have you checked if the image was correctly uploaded to your repository on Pavlovia and that the path is correct? I think the path should be relative to the “resources” sub-directory in your experiment repository. I’ve already seen some other forum threads that deal with that issue. Have you tried to search the forum for the error message? If you don’t find any answers there, it might be best to start a new forum thread for that since the problem is not related to the topic of this thread.

1 Like

Yeah, I’m also not happy with using only one microphone, so I’m going to stick with the online version of my experiment. Unfortunately, I don’t know what causes that problem or how to fix it :confused: Maybe someone else can help here.

1 Like

Yeah, I have been reading other forum threads too, maybe I should try more solutions.

Just as you said. Let’s just focus on this audio problem aha :smiley:

Thank you!

Sorry to bother again! You mean that you can use more than one mircrophone online? It is good news for me if I can finally run my experiment on Pavlovia~

Also, waiting for someone else to find a solution to use more than one mircrophone offline!

Thanks a lot for your kind reply.

I think so, at least my experiment is working online and I’m using two microphones. Maybe you can deactivate the image component that is causing the resource problem temporarily to check if the microphones are working online in your case too :thinking:

Good idea! Thank you for your help!

Hi,

I have the same error popping up while trying to run an object naming task. I tried both your solutions, but unfortunately they haven’t worked for me.
Any suggestions?