Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import speech_recognition as sr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'speech_recognition'
>>>
>>> def listen_for_name():
...     recognizer = sr.Recognizer()
...
>>>     with sr.Microphone() as source:
  File "<stdin>", line 1
    with sr.Microphone() as source:
IndentationError: unexpected indent
>>>         print("Say something:")
  File "<stdin>", line 1
    print("Say something:")
IndentationError: unexpected indent
>>>         recognizer.adjust_for_ambient_noise(source)
  File "<stdin>", line 1
    recognizer.adjust_for_ambient_noise(source)
IndentationError: unexpected indent
>>>         audio = recognizer.listen(source)
  File "<stdin>", line 1
    audio = recognizer.listen(source)
IndentationError: unexpected indent
>>>
>>>     try:
  File "<stdin>", line 1
    try:
IndentationError: unexpected indent
>>>         text = recognizer.recognize_google(audio).lower()
  File "<stdin>", line 1
    text = recognizer.recognize_google(audio).lower()
IndentationError: unexpected indent
>>>         print(f"You said: {text}")
  File "<stdin>", line 1
    print(f"You said: {text}")
IndentationError: unexpected indent
>>>
>>>         if "mr. monkey" in text:
  File "<stdin>", line 1
    if "mr. monkey" in text:
IndentationError: unexpected indent
>>>             respond_to_monkey()
  File "<stdin>", line 1
    respond_to_monkey()
IndentationError: unexpected indent
>>>
>>>     except sr.UnknownValueError:
  File "<stdin>", line 1
    except sr.UnknownValueError:
IndentationError: unexpected indent
>>>         print("Sorry, I couldn't understand audio.")
  File "<stdin>", line 1
    print("Sorry, I couldn't understand audio.")
IndentationError: unexpected indent
>>>     except sr.RequestError as e:
  File "<stdin>", line 1
    except sr.RequestError as e:
IndentationError: unexpected indent
>>>         print(f"Error with the speech recognition service; {e}")
  File "<stdin>", line 1
    print(f"Error with the speech recognition service; {e}")
IndentationError: unexpected indent
>>>
>>> def respond_to_monkey():
...     print("Hello, Mr. Monkey! How can I help you?")
...
>>> # Call the function to listen for the name and respond
>>> listen_for_name()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in listen_for_name
NameError: name 'sr' is not defined. Did you mean: 'str'?
>>> pip install SpeechRecognition
  File "<stdin>", line 1
    pip install SpeechRecognition
        ^^^^^^^
SyntaxError: invalid syntax
>>> pip install gtts
  File "<stdin>", line 1
    pip install gtts
        ^^^^^^^
SyntaxError: invalid syntax
>>> import speech_recognition as sr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'speech_recognition'
>>> from gtts import gTTS
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gtts'
>>> import os
>>>
>>> def listen_for_command():
...     recognizer = sr.Recognizer()
...
>>>     with sr.Microphone() as source:
  File "<stdin>", line 1
    with sr.Microphone() as source:
IndentationError: unexpected indent
>>>         print("Say something:")
  File "<stdin>", line 1
    print("Say something:")
IndentationError: unexpected indent
>>>         recognizer.adjust_for_ambient_noise(source)
  File "<stdin>", line 1
    recognizer.adjust_for_ambient_noise(source)
IndentationError: unexpected indent
>>>         audio = recognizer.listen(source)
  File "<stdin>", line 1
    audio = recognizer.listen(source)
IndentationError: unexpected indent
>>>
>>>     try:
  File "<stdin>", line 1
    try:
IndentationError: unexpected indent
>>>         text = recognizer.recognize_google(audio).lower()
  File "<stdin>", line 1
    text = recognizer.recognize_google(audio).lower()
IndentationError: unexpected indent
>>>         print(f"You said: {text}")
  File "<stdin>", line 1
    print(f"You said: {text}")
IndentationError: unexpected indent
>>>         return text
  File "<stdin>", line 1
    return text
IndentationError: unexpected indent
>>>     except sr.UnknownValueError:
  File "<stdin>", line 1
    except sr.UnknownValueError:
IndentationError: unexpected indent
>>>         print("Sorry, I couldn't understand audio.")
  File "<stdin>", line 1
    print("Sorry, I couldn't understand audio.")
IndentationError: unexpected indent
>>>         return ""
  File "<stdin>", line 1
    return ""
IndentationError: unexpected indent
>>>     except sr.RequestError as e:
  File "<stdin>", line 1
    except sr.RequestError as e:
IndentationError: unexpected indent
>>>         print(f"Error with the speech recognition service; {e}")
  File "<stdin>", line 1
    print(f"Error with the speech recognition service; {e}")
IndentationError: unexpected indent
>>>         return ""
  File "<stdin>", line 1
    return ""
IndentationError: unexpected indent
>>>
>>> def respond_to_command(command):
...     if "mr. monkey" in command:
...         if "how are you" in command:
...             speak("I'm doing well, thank you!")
...         elif "what is your name" in command:
...             speak("My name is Mr. Monkey.")
...         elif "calculate" in command:
...             try:
...                 equation = command.split("calculate")[1].strip()
...                 result = eval(equation)
...                 speak(f"The result is {result}.")
...             except Exception as e:
...                 speak("Sorry, I couldn't calculate that.")
...         else:
...             speak("I'm sorry, I don't understand that command.")
...
>>> def speak(text):
...     tts = gTTS(text=text, lang='en')
...     tts.save("response.mp3")
...     os.system("start response.mp3")
...
>>> while True:
...     command = listen_for_command()
...     if command:
...         respond_to_command(command)