"""Run this once to trigger macOS microphone permission dialog.""" import speech_recognition as sr print("Requesting microphone access...") print("If you see a macOS popup, click ALLOW.") print() mic = sr.Microphone() rec = sr.Recognizer() with mic as source: rec.adjust_for_ambient_noise(source, duration=2) print("Microphone access GRANTED!") print("You can close this window.")