Hey prithviraj23,
We'd be happy to help out with the audio issues you're facing with your AirPods on your MacBook Pro. Great job isolating things further though. Doesn't sound like there's an issue with the AirPods if they're working normally on other devices and it sounds like the issue is isolated to the MacBook Pro.
With that being the case, try testing things out in the Voice Memo app. Record a memo while using your AirPods and let us know if you notice the same issue. This could be due to some settings on the Mac causing this behavior and by testing in Voice Memo we can begin to isolate things further.
Additionally, you might need to try resetting your AirPods using these steps, as it can resolve many of the issues you face with your AirPods:
Put your AirPods in their charging case, and close the lid.
1. Wait 30 seconds.
2. Open the lid of your charging case.
3. With your AirPods in your ears and connected to your iPhone, iPad, or iPod touch, go to Settings > Bluetooth, or Settings > [your AirPods], and tap the More Info button
next to your AirPods. If you don't see your AirPods in Settings > Bluetooth or in Settings > [your AirPods], just go to the next step.
4. Tap Forget This Device, and tap again to confirm.
5. With the lid open, press and hold the setup button on the back of the case for about 15 seconds, until the status light on the front of the case flashes amber, then white.*

6. Reconnect your AirPods: With your AirPods in their charging case and the lid open, place your AirPods close to your iPhone, iPad, or iPod touch. Follow the steps on your device's screen.
All these steps and more on resetting your AirPods is available here: How to reset your AirPods and AirPods Pro
We hope this information helps out and look forward to hearing the results.
Take care!