text: import pyttsx3  # pip install pyttsx3
  import speech_recognition as sr  # pip install speechRecognition
  import datetime
  import wikipedia  # pip install wikipedia
  import webbrowser
  import os
  import smtplib
  
  print("Intializing Rosy")
  
  MASTER = "Avinder"
  
  engine = pyttsx3.init('sapi5')
  voices = engine.getProperty('voices')
  engine.setProperty('voice', voices[1].id)
  
  # Speak function will pronounce the string which is passes to it
  
  
  def speak(text):
      engine.say(text)
      engine.runAndWait()
  
  # This function will wish you as per the current time
  
  
  def wishMe():
      hour = int(datetime.datetime.now().hour)
  
      if hour >= 0 and hour < 12:
          speak("Good Morning" + MASTER)
  
      elif hour >= 12 and hour < 18:
          speak("Good Afternoon" + MASTER)
  
      else:
          speak("Good Evening" + MASTER)
  
      speak("I am Rosy. How may I help you?")
  
  # This function will take command from the microphone
  
  
  def takeCommand():
      r = sr.Recognizer()
      with sr.Microphone() as source:
          print("Listening...")
          audio = r.listen(source)
  
      try:
          print("Recognizing...")
          query = r.recognize_google(audio, language='en-in')
          print(f"user said: {query}\n")
  
      except Exception as e:
          print("Say that again please")
          query = None
      return query
  
  
  # Main Program starts here...
  
  def main():
      speak("Intializing Rosy...")
      wishMe()
      query = takeCommand()
  
      # Logic for executing tasks as per the query
      if 'wikipedia' in query.lower():
          speak('Searching wikipedia...')
          query = query.replace("wikipedia", "")
          results = wikipedia.summary(query, sentences=2)
          print(results)
          speak(results)
  
      elif 'open harvard' in query.lower():
          # webbrowser.open("youtube.com")
          url = "https://www.harvard.edu/"
  
          chrome_path = 'C:/Program Files/Google/Chrome/Application/chrome.exe %s'
          webbrowser.get(chrome_path).open(url)
  
      elif 'open youtube' in query.lower():
          # webbrowser.open("youtube.com")
          url = "youtube.com"
  
          chrome_path = 'C:/Program Files/Google/Chrome/Application/chrome.exe %s'
          webbrowser.get(chrome_path).open(url)
  
      elif 'play music' in query.lower():
          songs_dir = "C:\\Users\\avind\\Desktop\\music"
          songs = os.listdir(songs_dir)
          print(songs)
          os.startfile(os.path.join(songs_dir, songs[0]))
  
      elif 'the time' in query.lower():
          strTime = datetime.datetime.now().strftime("%H:%M:%S")
          speak(f"{MASTER} the time is {strTime}")
  
  
  main()
  