Python Bot

[Solved] Python Bot | Python - Code Explorer | yomemimo.com
Question : python bot

Answered by : zealous-zebra-kk607wxm07ej

import emailfrom email.policy import EmailPolicyimport speech_recognition as srimport pyttsx3import pywhatkitimport datetimeimport wikipediaimport pyjokesimport numpy as npimport webbrowser
listener = sr.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('listening...')            voice = listener.listen(source)            command = listener.recognize_google(voice)            command = command.lower()            if 'alexa' in command:                command = command.replace('alexa', '')                print(command)    except:        pass    return command
def run_alexa():    command = take_command()    print(command)    if 'play' 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('Current time is ' + time)    elif 'who is' in command:        person = command.replace('who 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('I am in a relationship with wifi')    elif 'joke' in command:        talk(pyjokes.get_joke())    elif 'who made you' in command:        talk('My lord, Jack Watkins')    elif 'Hi how are you' in command:        talk('Good in the cloud ya know')    elif 'speak french' in command:        talk('Bonjour Comment ca va? I know Its not the best')    elif 'what age should you be dating' in command:        talk('I mean if your werid you would say 10, but about maybe 14?')    elif 'what does your name mean' in command:        talk('Jarvis stands for just a really very intelligent system')    elif 'why did you ruin my day' in command:        talk('why did you ruin my day')    elif 'what is the hardest math problem' in command:        talk('Im better then humans, so you will never know')    elif 'bye' in command:        talk('ok bye for now, i will be in the cloud')    elif 'open video called' in command:      video = command.replace('open the video','')      talk('opening the video ' + video)      pywhatkit.playonyt(video)    elif 'open chrome' in command:        talk('ok')        webbrowser. get('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'). open('https://google.com')       
    else:        print('Say That Command One More time.')
while True:    ru

Source : | Last Update : Sat, 30 Jul 22

Answers related to python bot

Code Explorer Popular Question For Python