import speech_recognition as mic import pyttsx3 import pywhatkit import datetime import wikipedia import pyjokes  listener = mic.Recognizer() engine = pyttsx3.init() voices = engine.getProperty('voices') engine.setProperty('voice', voices[1].id)   def talk(text):     engine.say(text)     engine.runAndWait()   def take_command():     try:         with sr.Microphone() as source:             print('Yeah I am listening!')             voice = listener.listen(source)             command = listener.recognize_google(voice)             command = command.lower()             if 'google' in command:                 command = command.replace('google', '')                 print(command)     except:         pass     return command   def run_alexa():     command = take_command()     print(command)     if 'play song' in command:         song = command.replace('play', '')         talk('playing ' + song)         pywhatkit.playonyt(song)     elif 'time' in command:         time = datetime.datetime.now().strftime('%I:%M %p')         talk('The current time is ' + time)     elif 'who is' in command:         person = command.replace('who the heck is', '')         info = wikipedia.summary(person, 1)         print(info)         talk(info)     elif 'date' in command:         talk('sorry, I have a headache')     elif 'are you single' in command:         talk('No, my best freind is you!')     elif 'joke' in command:         talk(pyjokes.get_joke())     else:         talk('Sorry I did not get that')   while True:     run_alexa()          #you have to install the following by the commands.Just copy and paste each text given     #below, you can paste it on the code editors terminal or in cmd.     #pip install SpeechRecognition     #pip install pyttsx3     #pip install pywhatkit     #pip install DateTime     #pip install wikipedia     #pip install PyAudio     #pip install pyjokes      

Read more of this post