Desktop Assistant in Python

mail@pastecode.io avatar
unknown
python
2 years ago
2.7 kB
1
Indexable
Never
print("Desktop Assistant")
#libraries:
import time, random, webbrowser,pyttsx3
#to use pyttsx3 you need additional install

name = "Lena"

greetings = ["Hi","Hello","Hey","Greetings","Hola","Ni hao","Bonjour","Privyet"]


audio = pyttsx3.init()
rate = 130
audio.setProperty("rate",rate)
voices = audio.getProperty("voices")
#0=male 1=female
audio.setProperty("voice",voices[1].id)



while True:
    audio.say("Enter (s) to start talking: ")
    audio.runAndWait()
    start = input("Enter (s) to start talking: ")
    if start == "s" or start == "S":
        r = random.choice(greetings)
        print(r)
        audio.say(r)
        audio.runAndWait()
        audio.say("Hello I am " + name)
        audio.runAndWait()
        audio.say("What is your name?")
        audio.runAndWait()
        yourname = input("What is your name:")
        print("Nice to meet you: " + yourname)
        audio.say("Nice to meet you " + yourname)
        audio.runAndWait()
        print('''
        Enter website number to open
        1.Google
        2.Youtube
        3.Netflix
        4.Roblox
        5.Discord
        6.Firefox
        7.Twitter
        8.Instagram
        9.Reddit
        ''')
        print("What webpage should I open for you?" + yourname)
        audio.say("What webpage should I open for you?" + yourname)
        audio.runAndWait()
        web = input("Enter webpage number:")

        while True:
        if web == "1":
            print("Opening Google for you " + yourname)
            webbrowser.open("https://www.google.com")
            audio.say("Opening Google for you " + yourname)
            audio.runAndWait()
        elif web == "2":
            print("Opening Youtube for you " + yourname)
            webbrowser.open("https://www.youtube.com")
            audio.say("Opening Youtube for you " + yourname)
            audio.runAndWait()
        elif web == "3":
            print("Opening Netflix for you " + yourname)
            webbrowser.open("https://www.netflix.com")
            audio.say("Opening Netflix for you " + yourname)
            audio.runAndWait()
        elif web == "4":
            print("Opening Roblox for you " + yourname)
            webbrowser.open("https://www.roblox.com")
            audio.say("Opening Roblox for you " + yourname)
            audio.runAndWait()

        else:
            print("Sorry wrong command!")
            audio.say("Sorry wrong command!")
            audio.runAndWait()

        
        break
    else:
        print("Sorry you did not typed the right command")
        audio.say("Sorry you did not typed the right command")
        audio.runAndWait()
        time.sleep(1)