I’m very glad you wrote. You are not at all alone. Many kids are anxious when they have to talk in front of class. Sensitive teachers find ways to help their students become more comfortable. Sadly, not everyone gets such help.
They may believe they are motivating you by yelling but they are only making you feel worse. In response, you have added self-criticism to their criticism. You don’t believe in yourself so you don’t think others will believe in you either. The result is a low self-esteem that makes it difficult to want to even try.
Although I understand completely why you might want to isolate yourself to avoid the pain, that’s exactly the wrong thing to do. When a person with low self-esteem isolates, they become more and more stuck. The way out of this is to start taking small steps to be with other people so you can gain some confidence in yourself.
It’s common for people to think that they can’t do anything until they feel better. Actually, it works the other way. You will feel better if you start to do things to feel good about.
One way to get started is to take the focus off making friends. Instead, focus on doing something that matters to you. Join a club or sport or volunteer effort where people your age are working together to make something happen. Put your attention on doing well as a member. When working together, people get to know each other gradually. Friendships are likely to grow out of it if you are patient.
If you continue to feel so anxious, I do suggest seeing a therapist. A therapist can hear your whole story and make more specific suggestions. You will also have some ongoing support as you work to make changes.
I wish you well.