Speech recognition is not taking voice as input

I was working on a voice controlled AI assistant but the problem is that speech recognition is not taking my voice as input and returning the except condition. I have all the necessary modules installed (pyaudio and even pyttsx3.). Can someone please review this code and suggest what could be the problem. (My microphone is working fine, I’m using bluetooth earpierces.)

Code:

import speech_recognition as sr
import win32com.client
# import pvporcupine as p
# import pyttsx3 as p1
sp= win32com.client.Dispatch("SAPI.SpVoice")
def Listen():
        a= sr.Recognizer()
        with sr.Microphone(device_index=1) as mic:
            a.adjust_for_ambient_noise(mic, duration=0.2)
            audio=a.listen(mic)
            text=a.recognize_google_cloud(audio, language="en-in")
            text=text.lower()
            print(f"You said: {text}")
            return text
def say(t):
        sp.speak(t)
# def activate():
#       porcupine= p.create( access_key='${QrNXs2IXzdItREYSr3PUYfZCXa72eJ9Z6jA9xKl8FNgcHJ/Ruiyzuw}',
#                           keywords=["${E:\Hey-rose_en_windows_v3_0_0}"])
while True:
    print("Listening...")
    say("I'm listening")
    t= Listen()
    say(t)

Here’s a problem:

except:
    return "Didn't quite get that, please try again..."

You’re destroying the incredibly useful error information Python is trying to show you and replacing it with an entirely useless “error message”. Get rid of the try/except and you will at least have a better idea of how to start troubleshooting your problem.

Here’s another problem:

Your access key is compromised. Revoke and regenerate it ASAP.

What is sr? You don’t define it anywhere.

Also, text.lower() returns the text coverted to lowercase and then discards it.

Thanks for the suggestion dude, I’m getting this error:

Traceback (most recent call last):
  File "e:\CS projet\CS project\import speech_recognition as sr.py", line 23, in <module>
    t= Listen()
       ^^^^^^^^
  File "e:\CS projet\CS project\import speech_recognition as sr.py", line 11, in Listen
    text=a.recognize_google_cloud(audio, language="en-in")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\CS projet\CS project\.venv\Lib\site-packages\speech_recognition\__init__.py", line 689, in recognize_google_cloud
    assert os.environ.get('GOOGLE_APPLICATION_CREDENTIALS') is not None
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

how do I fix this?

Give the environment variable GOOGLE_APPLICATION_CREDENTIALS a value, the required Google application credentials.