Beispiel #1
0
def wikipedia_search(whatToSearch):
    driver.get('https://www.wikipedia.org/')

    search = driver.find_element_by_xpath('//*[@id="searchInput"]')
    search.click()
    search.send_keys(whatToSearch)

    searchbtn = driver.find_element_by_xpath('//*[@id="search-form"]/fieldset/button/i')
    searchbtn.click()

    para = driver.find_element_by_xpath('//*[@id="mw-content-text"]/div[1]/p[3]')
    readable_text = para.text
    tts2.speak(readable_text)
Beispiel #2
0
def welcome():
    currentTime =  datetime.datetime.now()

    if(currentTime.hour < 12):
        tts2.speak('Good Morning sir!')
    elif(currentTime.hour < 18):
        tts2.speak('Good afternoon sir!')
    else:
        tts2.speak('good evening sir!')
Beispiel #3
0
def mainthread(param = ''):
    if(param == ''):
        input = stt.listen()
    else:
        input = param

    #bot commands -start
    if(input == 'exit' or input == 'bye' or input == 'quiet'):
        input = ''
        tts2.speak('goodbye, have a nice day sir!')
        global var
        var = False

    #spotify commands check - start
    elif (input == "open spotify"):
        input = ""
        import spotify
        tts2.speak('spotify opened')   

    elif (input == "play" or input == "pause"):
        input = ""
        try:
            spotify.playPause()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "exit spotify" or input == "close spotify"):
        input = ""
        try:
            spotify.close()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "mute"):
        input = ""
        try:    
            spotify.mute()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "next"):
        input = ""
        try:
            spotify.next()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "previous"):
        input = ""
        try:
            spotify.prev()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "shuffle"):
        input = ""
        try:
            spotify.shuffle()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "repeat"):
        input = ""
        try:
            spotify.repeat()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "like"):
        input = ""
        try:
            spotify.like()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif (input == "what is playing" or input == "what's playing"):
        input = ""
        try:
            spotify.nowPlaying()
        except NameError:
            tts2.speak(NameErrorSpeak)

    elif ('search' in str(input) and 'spotify' in str(input)):
        try:
            stopwords = ['search', 'for', 'spotify', 'on']
            querywords = input.split()
            resultwords  = [word for word in querywords if word.lower() not in stopwords]
            result = ' '.join(resultwords)

            spotify.search(result)
            input = ""
        except NameError:
            tts2.speak(NameErrorSpeak)
        except:
            print("error occured!")

    elif (input == "test method"):
        input = ""
        spotify.search("attention")

    elif (input == "home"):
        input = ""
        try:
            spotify.home()
        except NameError:
            tts2.speak(NameErrorSpeak)

     #spotify commands check -end

    #time and date commands -start
    elif((detectionwords.detectwhat(input) == 'found') and ('time' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('time')))

    elif((detectionwords.detectwhat(input) == 'found') and ('date' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('date')))

    elif((detectionwords.detectwhat(input) == 'found') and ('day' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('day')))

    elif((detectionwords.detectwhat(input) == 'found') and ('month' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('month')))

    elif((detectionwords.detectwhat(input) == 'found') and ('year' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('year')))

    elif((detectionwords.detectwhat(input) == 'found') and ('hour' in str(input))):
        input = ''
        tts2.speak(str(timeFunc.exec('hour')))     
                
    elif((detectionwords.detectwhat(input) == 'found') and (('minute' in str(input)) or ('minutes' in str(input)))):
        input = ''
        tts2.speak(str(timeFunc.exec('minute')))
Beispiel #4
0
        if content.upper().find(current_city.upper()) == -1:
            if typed:
                prompt = "This place does not exist, please type again" + "\n"
            else:
                prompt = "You may have already told this, please try again" + "\n"
            isPlaying += 1
        elif reply_ending.upper() != current_city[:1].upper():
            prompt = "It is not starting with " + reply_ending.upper(
            ) + ", try again" + "\n"
            isPlaying += 1
        else:
            score += 10
            content = content.replace(current_city, '')
            ending = current_city[-1:]
            reply = city.get_city(ending, content)
            tts2.speak(reply)
            content = content.replace(reply, '')
            print("Computer replies with " + reply + "...\n")
            reply_ending = reply[-1:]
            prompt = 'Tell a city or a country starting with ' + reply_ending.upper(
            ) + "\n"

store.save(score, name)
leaderboard = store.leader()
if (leaderboard['1st'][1] > score):
    tts2.speak("Don't worry, Not everyone is a computer")
else:
    tts2.speak("Go get a life, Nerd!")
print("\n 1st : " + leaderboard['1st'][0] + " - " +
      str(leaderboard['1st'][1]) + "\n 2nd : " + leaderboard['2nd'][0] +
      " - " + str(leaderboard['2nd'][1]) + "\n 3rd : " +
Beispiel #5
0
def oversmartdoctor(language2):

    username = config.username
    password = config.password
    authUrl = config.priaid_authservice_url
    healthUrl = config.priaid_healthservice_url
    language = config.language
    apicall = PriaidDiagnosisClient.DiagnosisClient(username, password,
                                                    authUrl, language,
                                                    healthUrl)

    #'''initialize paramenters'''
    ldel = ''
    #apicall=PriaidDiagnosisClient.DiagnosisClient()
    l = (apicall.loadSymptoms())
    symplist = []
    #print(apicall.loadIssues())
    gender = PriaidDiagnosisClient.Gender.Male
    year = 1999
    #query=input("Enter your gender:")

    #'''Prompt user for gender'''

    #ldel=text_to_speech.speak("Tell me your gender",ldel)
    if (language2 == "en-US"):
        ldel = text_to_speech.speak("Tell me your gender", ldel)
    elif (language2 == "hi-IN"):
        ldel = text_to_speech.speakhindi(
            translate.translate_hindi("Tell me your gender"), ldel)
    time.sleep(3)
    print("speak now")

    query = speech_to_text.main(language2)
    if (language2 == "hi-IN"):
        query = translate.translate(query)
    if (re.search(r'\b(jarvis)\b', query, re.I)):
        if (re.search(r'\b(male|boy|man|gentleman)\b', query, re.I)):
            gender = PriaidDiagnosisClient.Gender.Male
        if (re.search(r'\b(woman|girl|female|lady)\b', query, re.I)):
            gender = PriaidDiagnosisClient.Gender.Female

    #'''Prompt user for year of birth'''

    #query=input("Enter your year of birth:")
    #ldel=text_to_speech.speak("Tell me when you were born",ldel)
    if (language2 == "en-US"):
        ldel = text_to_speech.speak("Tell me when you were born", ldel)
    elif (language2 == "hi-IN"):
        ldel = text_to_speech.speakhindi(
            translate.translate_hindi("Tell me when you were born"), ldel)

    time.sleep(4)
    print("speak now")
    query = speech_to_text.main(language2)
    if (language2 == "hi-IN"):
        query = translate.translate(query)
    if (re.search(r'\b(jarvis)\b', query, re.I)):
        year = int(query.strip().split(" ")[1])

    counter = 0

    #'''Prompt user for symptoms'''
    while (1):
        counter = counter + 1
        if counter < 2:
            if (language2 == "en-US"):
                ldel = text_to_speech.speak(
                    "Tell me any symptoms you are having", ldel)
            elif (language2 == "hi-IN"):
                ldel = text_to_speech.speakhindi(
                    translate.translate_hindi(
                        "Tell me any symptoms you are having"), ldel)
        #query=input("Enter the symptom:")
        else:
            if (language2 == "en-US"):
                ldel = text_to_speech.speak(
                    "Tell me any other symptoms you are having", ldel)
            elif (language2 == "hi-IN"):
                ldel = text_to_speech.speakhindi(
                    translate.translate_hindi(
                        "Tell me any othersymptoms you are having"), ldel)
                #ldel=text_to_speech.speak("Tell me any other symptoms you are having",ldel)
        time.sleep(4)

        print("speak now")

        query = speech_to_text.main(language2)
        if (language2 == "hi-IN"):
            query = translate.translate(query)
        if (re.search(r'\b(jarvis)\b', query, re.I)):
            if (re.search(r'\b(no|none|bye|that is it|is it)\b', query, re.I)):
                break
        else:
            continue
        strlis = (query).split()
        probid2 = []
        for j in strlis:
            for i in l:
                #liss=re.split("&|,",i["Name"].lower())
                #liss=list(map(str.strip,liss))
                patt = r'\b(' + re.escape(j) + r')'
                if (re.search(patt, i["Name"], re.I)):
                    probid2.append(i)
                    print(i, j, probid2)
        print(probid2)
        if (len(probid2) > 0):
            symplist.append(probid2[0])
    idlist = []
    for i in symplist:
        idlist.append(i["ID"])

#'''draw conclusion based on collected symptoms'''
    finalres = apicall.loadDiagnosis(idlist, gender, year)[0]
    issuex = apicall.loadIssueInfo(finalres["Issue"]["ID"])
    if (language2 == "en-US"):
        ldel = text_to_speech.speak(
            str("You might have " + str(issuex["Name"]) +
                str(issuex["DescriptionShort"]) +
                str(issuex["TreatmentDescription"])), ldel)
    elif (language2 == "hi-IN"):
        ldel = text_to_speech.speakhindi(
            translate.translate_hindi("You might have " + str(issuex["Name"]) +
                                      str(issuex["DescriptionShort"]) +
                                      str(issuex["TreatmentDescription"])),
            ldel)
    #a = pygame.mixer.Sound(ldel)
    #print("length",a.get_length())

    time.sleep(10)
    print(finalres)
Beispiel #6
0
#wake word detection
while 1:
    wakewordinput = constparam
    print(constparam)
    wakewordlistener = wakeword.wakeworddetect(wakewordinput)

    if(wakewordlistener == 'awake'):
        timeFunc.welcome()

        while var:
            input = constparam

            #bot commands -start
            if(input == 'exit' or input == 'bye' or input == 'quiet'):
                input = ''
                tts2.speak('goodbye, have a nice day sir!')
                var = False

            #spotify commands check - start
            elif (input == "open spotify"):
                input = ""
                import spotify
                tts2.speak('spotify opened')   

            elif (input == "play" or input == "pause"):
                input = ""
                try:
                    spotify.playPause()
                except NameError:
                    tts2.speak(NameErrorSpeak)
from urllib.request import urlopen as uReq
import youtubesearch as ytplay
import translate
import symptomspecificdiagnosis
l = ''
language = 'en-US'
while (1):
    query = speech_to_text.main(language)
    if (language == "hi-IN"):
        query = translate.translate(query)
    query = query.lower()
    #query=input("Enter:")
    print(query)
    if re.search(r'\b(jarv|jarvis|jar)\b', query, re.I):
        if re.search(r'\b(up|awake)\b', query, re.I):
            l = text_to_speech.speak("For you sir,always", l)
            print("For you sir! always!")
        if re.search(r'\b(where is)\b', query, re.I):
            #data=query
            #data = data[re.search(r'\b(where is)\b',query, re.I).span()[1]:]#.split(" ")
            data = query[re.search(r'\b(where is)\b', query, re.I).span(
            )[1]:].strip()
            location = data[2]
            location = data
            l = text_to_speech.speak(
                "Hold on Apoorv, I will show you where " + location + " is.",
                l)
            webbrowser.open("https://www.google.nl/maps/place/" +
                            location)  #+ "/&amp;")
        if re.search(r'\b(play)\b', query, re.I):
            if re.search(r'\b(youtube)\b', query, re.I):