示例#1
0
def run_alexa():
    command = take_command()
    if 'time' in command:
        time = datetime.datetime.now().strftime('%I:%M %p')
        print(time)
        talk('Current time is ' + time)
    elif 'play' in command:
        song = command.replace('play', '')
        talk('playing ' + song)
        pywhatkit.playonyt(song)
    elif 'tell me about' in command:
        look_for = command.replace('tell me about', '')
        info = wikipedia.summary(look_for, 100)
        print(info)
        talk(info)
    elif 'tell me a joke' in command:
        talk(pyjokes.get_joke())

    elif "note" in command:
        pyttsx3.speak("opening notepad")
        os.system("Notepad")

    else:
        talk('Okay,Please wait')
        pywhatkit.search(command)
def speak_out(audio, voice):
    #"speaks audio passed as argument"
    engine = pyttsx3.init() # object creation
    voices = engine.getProperty('voices')       #getting details of current voice
    engine.setProperty('voice', voices[voice].id)   #changing index, changes voices
    pyttsx3.speak(audio)
    engine.setProperty('rate', 300)     # setting up new voice rate
def __init__parser():
    with speech_recognition_system():
        try:
            with Microphone as source:
                Recognition.adjust_for_ambient_noise(source)
                Recognition.dynamic_energy_threshold = 3000
                audio = Recognition.listen(source, phrase_time_limit=6)
                speech = ''
                try:
                    speech = Recognition.recognize_google(
                        audio, language='en-in'), print(
                            "Got it! Now to recognize it...")
                    print(f"You said {speech}")
                except sr.WaitTimeoutError:
                    pass
                except sr.RequestError:
                    speak("I am Having Trouble Initiating Your Request")
                except Exception as e:
                    pass
                    print("Oops! Didn't catch that")
                    return "none"
            return speech.lower()
        except sr.WaitTimeoutError:
            pass
        except sr.UnknownValueError:
            pass
            speak("I Am Having Trouble Understanding Right Now")
def main():

    while True:
        os.system("cls")
        f = open("menu.txt", "r")
        a = "".join(f.readlines())
        print("\u001b[33m" + a)
        print("""
        \u001b[32m
        Press 1 : About Docker.
        Press 2 : About Hadoop
        Press 3 : About AWS Cloud 
        Press 4 : Ansible Configure
        Press 5 : Web Server Configure
        Press 6 : Machine Learning 
        Press 7 : Exit """)
        p.speak("Enter your Choice")
        choice = input(" Enter Your Choice : \u001b[31m ")
        print(choice)
        if int(choice) == 1:
            docker.docker()
        elif int(choice) == 2:
            hadoop_main.hadoop()
        elif int(choice) == 7:
            os.system("cls")
            f = open("by.txt", "r")
            a = "".join(f.readlines())
            print("\u001b[32m" + a)
            p.speak("see you soon , have a nice day")
            exit()
        else:
            input("Invalid Value, Press Enter to Continue")
            continue

        continue
示例#5
0
def start_game():

    print('Welcome to the AdventureGame!')
    pyttsx3.speak('Welcome to the AdventureGame!')
    help_screen()

    knight_sword = WeaponsClasses.Sword(10).sword_damage(5)
示例#6
0
def choiceMenu():
    print("Do you want to (1)chat, (2)choose or (3)exit?")
    
    ch = input()
    if ch == "chat" or ch == '1':
        py.speak('How can I help u?')
        print("How can I help u?")
        
        p=funcChat()
        print(p)
        check(p)
        return 0
    elif ch == "choose" or ch == '2':
        p=funcMenu()
        
        check(p)
        return 0
    elif ch == "exit" or ch == "quit" or '3':
        py.speak("Ok, seeya!!!")
        print("Exitting the program!!!")
        return 1
    else:
        print("Wrong choice, please try again")
        choiceMenu()
        return 0
示例#7
0
def r1():
    doorisclosed = True
    print(
        'You wake up in a small, dark room. Rats running beneath your feet. In the background you can hear'
        'sounds of metal doors slamming and distant screams. You have to get out of here... but how?'
    )
    pyttsx3.speak(
        'You wake up in a small, dark room. Rats running beneath your feet. In the background you can hear'
        'sounds of metal doors slamming and distant screams. You have to get out of here... but how?'
    )
    while doorisclosed:
        userinput = input('What would you like to do : ')
        user_input(userinput)
        if userinput == "LOOK LEFT":
            #GO TO FUNCTION FOR LOOKING LEFT
            r1lookleft()
        elif userinput == "LOOK RIGHT":
            #GO TO FUNCTION FOR LOOKING RIGHT
            r1lookright()
        elif userinput == "LOOK FORWARD":
            #GO TO FUNCTION FOR LOOKING FORWARD
            r1lookforward()
        elif userinput == "LOOK DOWN":
            #GO TO FUNCTION FOR LOOKING DOWN
            r1lookdown()
        else:
            print('Not a valid input. type help to look at options')
def convertFile():
    app.speakPrint('Please write down the "path" of the -original- file')
    app.speakPrint(
        'You can click "shift + right-click" and choose copy as path')
    src = input()
    src = src.replace("\\", "\\\\").replace('"', "")
    while True:
        if not path.exists(src):
            app.speakPrint(
                "Sorry, Didn't find the file\nMake Sure To write the path correctly"
            )
            src = input()
            src = src.replace("\\", "\\\\")
        else:
            break

    app.speakPrint(
        'Please write down the name of the new file followed by the extension')
    print('Ex. : output.mp3')
    dst = input()
    while True:
        if src[0] == " ":
            src = src[1:]
        else:
            break
    if path.exists('Converted Files') == False:
        os.mkdir("Converted Files")
        app.speakPrint(
            '"Converted Files" folder has successfully been created')

    app.Speak("Converting")
    subprocess.call(['Utils\\ffmpeg.exe', '-i', src, f'Converted Files/{dst}'])
    speak("Done")
示例#9
0
def play(game, x_player, o_player, print_game=True):
    if print_game:
        game.print_number_board()
    letter = 'X'
    while game.empty_squares():
        if letter == 'O':
            square = o_player.get_move(game)
        else:
            square = x_player.get_move(game)
        if game.make_move(square, letter):
            if print_game:
                print(letter + ' makes a move to {}'.format(square))
                game.print_board()
                print()
            if game.current_winner:
                if print_game:
                    print(letter + ' wins!')
                return letter
            if letter == 'X':
                letter = 'O'
            else:
                letter = 'X'
        time.sleep(.8)
    if print_game:
        print("It's a Tie")
        p.speak("It's a Tie")
示例#10
0
def r1lookleft():
    print(
        'Looking left from the bed you are sat on you can see in the darkness a stone wall covered in damp'
        'there is a small black iron bar window going into the cell next door.'
    )
    pyttsx3.speak(
        'Looking left from the bed you are sat on you can see in the darkness a stone wall covered in damp'
        'there is a small black iron bar window going into the cell next door.'
    )
    looking_left = True
    stonewall_inspected = False
    while looking_left:
        uinput = input('What would you like to do : ')
        if uinput == "LOOK AWAY":
            print('You look away')
            looking_left = False
        #if uinput == "INSPECT STONE WALL" & stonewall_inspected == False:

        #   print('Looking at the stone wall closer, you notice one of the stones is loose.Pulling at the old stone'
        #         'it breaks out. Looking in the hole there is a rusty spanner. you put this in your pocket')
        #PUT SPANNER IN INVENTORY
        #   inventory.append('Spanner')
        #   stonewall_inspected = True
        #   print(inventory)
        if uinput == "INSPECT STONE WALL" & stonewall_inspected == True:
            print('There is nothing new about this wall.')

        if uinput == "INSPECT WINDOW":
            print('Inspect Window')
示例#11
0
def hadoop():
    os.system("cls")
    while True:
        f = open("hadoop.txt", "r")
        a = "".join(f.readlines())
        print("\u001b[33m" + a)
        print("""
        \u001b[32m
        Press 1: Hadoop Master  
        Press 2: Hadoop Slave
        Press 3: Hadoop Client
        Press 4: View Hadoop Web UI 
        Press 5: Return to Main Menu
        Press 6: Exit
        """)

        # user input entered
        p.speak("Enter your Choice...")
        var = int(input("Enter the option: "))
        if var == 1:
            master_confi.master()

        elif var == 2:
            slave_conf.slave()
        elif var == 3:
            client_confi.client()
        elif var == 5:
            break
        elif var == 6:
            exit()

        else:
            input("Invalid Value, Press Enter to Continue")
            p.speak("please choose right option")
            continue
示例#12
0
 def run(self):
     # 获得购物车信息
     cart_infos = self.buycartinfo()
     # 打印并选择想要抢购的商品信息
     title, items = ['id', 'title'], []
     for key, value in cart_infos.items():
         items.append([key, value['title']])
     self.printTable(title, items)
     good_id = input('请选择想要抢购的商品编号(例如"0"): ')
     assert good_id in cart_infos, '输入的商品编号有误'
     # 根据选择尝试购买商品
     print(
         f'[{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} INFO]: 正在尝试抢购商品***{cart_infos[good_id]["title"]}***'
     )
     while True:
         try:
             is_success = self.buygood(cart_infos[good_id])
         except:
             is_success = False
         if is_success: break
         time.sleep(self.trybuy_interval)
         print(
             f'[{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} INFO]: 抢购***{cart_infos[good_id]["title"]}***失败, 将在{self.trybuy_interval}秒后重新尝试下单.'
         )
     print(
         f'[{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} INFO]: 抢购***{cart_infos[good_id]["title"]}***成功, 已为您自动提交订单, 请尽快前往京东完成付款.'
     )
     # 电脑语音提示
     for _ in range(5):
         pyttsx3.speak('已经为您抢购到你所需的商品, 请尽快前往京东完成付款.')
     # 发送Server酱提示
     if self.server_key:
         self.pushwechat(
             f'已经为您抢购到你所需的商品***{cart_infos[good_id]["title"]}***, 请尽快前往京东完成付款.'
         )
def UpdateHdfsSite():
    pt.speak("Starting update of hdfs file")
    filename = "/etc/hadoop/hdfs-site.xml"
    f = open(filename, 'r')
    file_lines = list(f.readlines())
    offset = len(file_lines) - 1
    if file_lines[offset - 1] == "</property>\n":
        pt.speak("hdfs-site is already configured")
        print("hdfs-site is already configured.........\n")
        pt.speak("checking core-site.xml")
        print("checking core-site.xml.........")
        return
    pt.speak("Create folder for datanode enter path")
    folder = get_input_speech("Create folder for datanode(enter path): ")
    string = "<property>\n<name>dfs.data.dir</name>\n<value>{}</value>\n</property>\n".format(
        folder)
    file_lines.insert(offset, string)
    print(file_lines)
    f.close()

    f = open(filename, 'w+')
    for i in range(len(file_lines)):
        f.write(file_lines[i])
    f.close()
    pt.speak("Update successful")
def CheckDataNodeStatus():
    pt.speak("checking datanode status")
    sub = subprocess.Popen("jps", shell=True, stdout=subprocess.PIPE)
    output = sub.stdout.read()
    if 'DataNode' in str(output):
        return 1
    else:
        return 0
示例#15
0
def totext(l):
    #Function to write and speak the output of the Response to display
    speak(l)

    print(l)

    with open('text.data', 'wb') as filehandle:
        pickle.dump(l, filehandle)
def checkNameNodeStatus():
    pt.speak("Checking namenode status")
    sub = subprocess.Popen("jps", shell=True, stdout=subprocess.PIPE)
    output = sub.stdout.read()
    if 'NameNode' in str(output):
        return 1
    else:
        return 0
示例#17
0
def loginpage():
    pyttsx3.speak("Plz login with your name and password: "******"------------------------")
    print("_______Login-Page_______")
    print("------------------------")
    m=input("Name: ")
    n=int(input("Password(only digits): "))
    q=admin_account(m,n)
示例#18
0
def check_net():
    try:
        if requests.get('https://8.8.8.8').ok:
            time.sleep(1)
            pyttsx3.speak("Have a nice day a k r")
            open_github()            
    except:
        time.sleep(1)
        pyttsx3.speak("Unable to open GitHub. Looks like you are offline")
def checkJava():
    pt.speak("checking Java")
    r = os.system("java -version")
    if r != 0:
        pt.speak("Java is not installed in your system")
        print("Java is not installed in your system....")
        return 0
    else:
        return 1
def checkHadoop():
    pt.speak("Checking Hadoop")
    r = os.system("hadoop -v")
    if r != 0:
        pt.speak("hadoop is not installed in your system")
        print("hadoop is not installed in your system....")
        return 0
    else:
        return 1
示例#21
0
def get_text():
    while (1):
        r = sr.Recognizer()
        with sr.Microphone() as source:
            audio_text = r.listen(source)
            try:
                return r.recognize_google(audio_text)
            except:
                print("Sorry, I did not get that.\nPlease try again...")
                pyttsx3.speak("Sorry, I did not get that. Please Try Again...")
def stopwatch():
    watch = int(input('for how many seconds\t'))
    counter = watch
    n = 0
    while watch>n-1:
        print(counter)
        pyttsx3.speak(counter)
        n += 1
        counter -= 1
    pyttsx3.speak('Your time is up!!!')
示例#23
0
def design1():
		os.system(" cls ")
		os.system(" tput bold ")
		print("=============================================================================================================================================================")
		os.system(" tput  setaf 1 ")
		print("\t\t\t\t----------------->Your welcome in this Hadoop Automation Menu Program<----------------\t\t")
		pyttsx3.speak("Your welcome in this Hadoop Automation Menu Program")
		os.system(" tput  setaf 3 ")
		print("=============================================================================================================================================================\n")
		os.system(" tput setaf 77 ")
def read_text():
    page_num = int(page_number.get())
    path_name = path.get()
    pyttsx3.speak("Welcome to PDF Reader")

    file = open(path_name, "rb")

    fileReader = PyPDF2.PdfFileReader(file)
    page = fileReader.getPage(page_num - 1)
    page_content = page.extractText()
    pyttsx3.speak(page_content)
示例#25
0
def contEx():
    print("Do you wish to (1)continue or (2)exit?")
    c=input()
    if c=='1' or c == 'continue':
        choiceMenu()
        return 0
    elif c=='2' or c == 'exit' or c == 'quit':
        py.speak("Ok, seeya!!!")
        print("Exitting the program!!!")
        
        return 1
def display(event=None):
    try:
        text = TextBlob(var1.get())
        lang = text.detect_language()
        lang_dict = languages.get()
        lang_to = dict[lang_dict]
        mytext = text.translate(from_lang=lang, to=lang_to)
        var2.set(mytext)
        pyttsx3.speak(mytext)
        
        
    except:
        var2.set("Try another keyword")
示例#27
0
def hadoop():
    pyttsx3.speak("Welcome to the hadoop world")
    while True:
        tprint("Hadoop", font="block", chr_ignore=True)
        print("Press 1: To Configure Name Node")
        print("Press 2: To configure Slave Nodes")
        print("Press 3: To configure CLient Node")
        print("Press 3: To Go Back")
        hnn = input("Enter your choice: ")
        if (int(hnn) == 1):
            hamaster()
        elif (int(hnn) == 2):
            print("hadoop slave")
示例#28
0
def ask_choice():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        print("Start Speaking!")
        psy.speak("Star Speaking.")
        print()
        r.pause_threshold = 1
        audio = r.record(source, duration=6)
        text = r.recognize_google(audio, language="en-in")
        print("You said  {}".format(text))
        option = text.lower()
    psy.speak("Ok Working on it Please Wait!")
    return option
示例#29
0
def commands():    
    r = sr.Recognizer()
    with sr.Microphone() as source:
        r.adjust_for_ambient_noise(source, duration=1)
        print("Start Speaking!")
        psy.speak("Star Speaking.")
        audio = r.record(source, duration=6)
        print("Working on it")
        psy.speak("Ok Working on it Please Wait!")
        text = r.recognize_google(audio, language="en-in")
        print("You said  {}".format(text))

    p = text.lower()
    return p
def mycommand():
    try:
        r = sr.Recognizer()
        with sr.Microphone() as source:
            print("Listening...")
            audio = r.listen(source)
        query = r.recognize_google(audio, language='en-in')
        print('User: '******'\n')

    except sr.UnknownValueError:
        tts.speak("Sorry sir! I didn't get that! Try typing the command!")
        query = str(input('Command: '))

    return query