예제 #1
0
def open_application(input):

    if "chrome" in input:
        ass.assistant_speaks("Google Chrome")
        os.startfile(
            r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe')
        return

    elif "firefox" in input or "mozilla" in input:
        ass.assistant_speaks("Opening Mozilla Firefox")
        os.startfile(r'C:\Program Files\Firefox Developer Edition\firefox.exe')
        return

    elif "code" in input:
        ass.assistant_speaks("Opening Microsoft visual Code")
        os.startfile(
            r'C:\Users\ashut\AppData\Local\Programs\Microsoft VS Code\Code.exe'
        )
        return

    elif "hatch" in input:
        ass.assistant_speaks("Opening Hatch File")
        os.startfile(r'H:')
        return

    else:

        ass.assistant_speaks("Application not available")
        return
def find_web(text):
  
    driver = webdriver.Firefox() 
    driver.implicitly_wait(1) 
    driver.maximize_window() 
  
    if 'youtube' in text.lower(): 
  
        ass.assistant_speaks("Opening in youtube") 
        indx = text.lower().split().index('youtube') 
        query = text.split()[indx + 1:] 
        driver.get("http://www.youtube.com/results?search_query =" + '+'.join(query)) 
        return
  
    elif 'wikipedia' in text.lower(): 
  
        ass.assistant_speaks("Opening Wikipedia") 
        indx = text.lower().split().index('wikipedia') 
        query = text.split()[indx + 1:] 
        driver.get("https://en.wikipedia.org/wiki/" + '_'.join(query)) 
        return
  
    else: 
  
        if 'google' in text: 
  
            indx = text.lower().split().index('google') 
            query = text.split()[indx + 1:] 
            driver.get("https://www.google.com/search?q =" + '+'.join(query)) 
  
        elif 'search' in text: 
  
            indx = text.lower().split().index('google') 
            query = text.split()[indx + 1:] 
            driver.get("https://www.google.com/search?q =" + '+'.join(query)) 
  
        else: 
  
            driver.get("https://www.google.com/search?q =" + '+'.join(text.split())) 
  
        return
def get_audio():

    rObject = sr.Recognizer()
    audio = ''

    with sr.Microphone() as source:
        print("Please Ask What You Need")

        # recording the audio using speech recognition
        audio = rObject.listen(source, phrase_time_limit=2)
    print("Please Stop.")  # limit 5 secs

    try:

        text = rObject.recognize_google(audio, language='en-US')
        print("You : ", text)
        return text

    except:

        ass.assistant_speaks(
            "Could not understand your audio, PLease try again !")
        return 0
예제 #4
0
def Main():
    ass.assistant_speaks("Hello, Ashutosh This is Seja For You...")
    n = "Ashutosh"

    ass.assistant_speaks("Today's date is " + da.get_date())

    while (1):

        ass.assistant_speaks(
            "Tell me What for today? Anything Special For me ...")
        text = ga.get_audio()

        if text == '':
            continue

        if "exit" in str(text) or "bye" in str(text) or "sleep" in str(text):
            ass.assistant_speaks("Ok bye, " + n + '.')
            break

        # calling process text to process the query
        tp.process_speak(text)
예제 #5
0
def process_speak(text):
    # print(text)
    try: 
        if 'search' in text or 'play' in text: 
            wa.find_web(text) 
            return
            
        elif 'todays date' in text or 'date' in text:
            ass.assistant_speaks(da.get_date())
            return
  
        elif "who are you" in text or "define yourself" in text: 
            speak = "Hello, I am Goku Sir" 
            ass.assistant_speaks(speak) 
            return
  
        elif "who made you" in text or "created you" in text: 
            speak = "You Sir Ashutosh."
            ass.assistant_speaks(speak) 
            return
  
        elif "ashutoshpith" in text:
            speak = """It's Your Website Sir"""
            ass.assistant_speaks(speak) 
            return
  
        elif "calculate" in text.lower(): 
              
            # write your wolframalpha app_id here 
            app_id = "WOLFRAMALPHA_APP_ID" 
            client = wolframalpha.Client(app_id) 
  
            indx = text.lower().split().index('calculate') 
            query = text.split()[indx + 1:] 
            res = client.query(' '.join(query)) 
            answer = next(res.results).text 
            ass.assistant_speaks("The answer is " + answer) 
            return
  
        elif 'open' in text: 
            open_application(text.lower())  
            return
  
        else: 
  
            ass.assistant_speaks("I can search the web for you, Do you want to continue?") 
            ans = ga.get_audio() 
            if 'yes' in str(ans) or 'yeah' in str(ans): 
                wa.find_web(text) 
            else: 
                return
    except : 
  
        ass.assistant_speaks("I don't understand, I can search the web for you, Do you want to continue?") 
        ans = ga.get_audio() 
        if 'yes' in str(ans) or 'yeah' in str(ans): 
            wa.find_web(text)