def restart(t):
    while t:
        mins, secs = divmod(t, 60)
        timer = '{:1d}{:1d}'.format(mins, secs)
        print(timer, end="\r")
        nix.speak(timer)
        time.sleep(1)
        t -= 1
    print("Windows is restarting now!")
    nix.speak("Your Windows is restarting now!")
    os.system("shutdown /r /t 0")
    exit()
def logoff(t):
    while t:
        mins, secs = divmod(t, 60)
        timer = '{:1d}{:1d}'.format(mins, secs)
        print(timer, end="\r")
        nix.speak(timer)
        time.sleep(1)
        t -= 1
    print("Windows is logging out!")
    nix.speak("Windows is logging out")
    os.system("shutdown /l /t 0")
    exit()
def shutdown(t):
    while t:
        mins, secs = divmod(t, 60)
        timer = '{:1d}{:1d}'.format(mins, secs)
        print(timer, end="\r")
        nix.speak(timer)
        time.sleep(1)
        t -= 1
    print("Windows is shutting down!")
    nix.speak("Windows is shutting down")
    os.system("shutdown /s /t 0")
    exit()
def weather():
    apiKey = 'f2ad852dc1e89e7dd3da6b3fb2508e1a'
    base_url = "http://api.openweathermap.org/data/2.5/weather?"
    nix.speak("Tell me the city name")
    city_name = sr.takeCommand()
    complete_url = base_url + "appid=" + apiKey + "&q=" + city_name
    response = requests.get(complete_url)
    x = response.json()

    if x["cod"] != "404":
        y = x["main"]
        current_temperature = y["temp"]
        current_pressure = y["pressure"]
        current_humidiy = y["humidity"]
        z = x["weather"]
        weather_description = z[0]["description"]

        print("Temperature (in kelvin unit) = " + str(current_temperature) +
              "\nAtmospheric pressure (in hPa unit) = " +
              str(current_pressure) + "\nHumidity (in percentage) = " +
              str(current_humidiy) + "\nDescription = " +
              str(weather_description))
        nix.speak("Weather report for " + str(city_name))
        time.sleep(1)
        nix.speak("Temperature is " + str(current_temperature) + "Kelvin" +
                  "Atmospheric pressure is " + str(current_pressure) + "hPa" +
                  "Humidity is " + str(current_humidiy) + "hPa" +
                  "And the weather status is " + str(weather_description))
    else:
        print(" City not found!")
        nix.speak(" City not found!")
def applications(input):
    if 'open word' in query or 'open ms word' in query or 'ms word' in query:
            nix.speak("Opening Microsoft Office Word")
            wordPath = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Word.lnk"
            os.startfile(wordPath)
            nix.speak("Done for you! Anything else for me?")

    elif 'open code' in query:
            nix.speak("Opening Microsoft Visual Studio")
            codePath = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\devenv.exe"
            os.startfile(codePath)
            nix.speak("Done for you! Anything else for me?")

    else: 
        nix.speak("Application not available") 
        return
Exemplo n.º 6
0
def wishMe():
    hour = int(datetime.datetime.now().hour)
    if hour >= 0 and hour < 12:
        nix.speak("Good Morning")

    elif hour >= 12 and hour < 18:
        nix.speak("Good Afternoon")

    else:
        nix.speak("Good Evening")

    nix.speak("Akash! How may I help you?")
def covid_19():
    print("We are getting details from www.mohfw.gov.in")
    nix.speak("We are getting details from www.mohfw.gov.in")
    print("Please wait...")
    nix.speak("Please wait...")
    extract_contents = lambda row: [x.text.replace('\n', '') for x in row]
    URL = 'https://www.mohfw.gov.in/'

    SHORT_HEADERS = [
        'SNo', 'State', 'Indian-Confirmed', 'Foreign-Confirmed', 'Cured',
        'Death'
    ]

    response = requests.get(URL).content
    soup = BeautifulSoup(response, 'html.parser')
    header = extract_contents(soup.tr.find_all('th'))

    stats = []
    all_rows = soup.find_all('tr')

    for row in all_rows:
        stat = extract_contents(row.find_all('td'))
        if stat:
            if len(stat) == 5:
                # last row
                stat = ['', *stat]
                stats.append(stat)
            elif len(stat) == 6:
                stats.append(stat)

    stats[-1][1] = "Total Cases"

    stats.remove(stats[-1])
    objects = []
    for row in stats:
        objects.append(row[1])

    y_pos = np.arange(len(objects))

    performance = []
    for row in stats:
        try:
            performance.append(int(row[2]) + int(row[3]))

        except:
            print("")
            os.system('cls')

    table = tabulate(stats, headers=SHORT_HEADERS)
    print(table)
    nix.speak("The result is on your screen.")
def givenews():
    apiKey = "85d1024e0ceb4dae849c4783ad8753a4"
    url = f"https://newsapi.org/v2/top-headlines?country=in&apiKey={apiKey}"
    r = requests.get(url)
    data = r.json()
    data = data["articles"]
    flag = True
    count = 0
    for items in data:
        count += 1
        if count > 10:
            break
        print(items["title"])
        to_speak = items["title"].split(" - ")[0]
        if flag:
            nix.speak("Today's top ten Headline are : ")
            flag = False
        else:
            nix.speak("Next news :")
        nix.speak(to_speak)
def lock():
    ctypes.windll.user32.LockWorkStation()
    time.sleep(1)
    print("Your windows has been locked")
    nix.speak("Windows has been locked!")
Exemplo n.º 10
0
def systest():
    print("Hello")
    nix.speak("Hello")