Ejemplo n.º 1
0
def note_add():
    speak("Słucham!")
    note_recorder()
    speak("Czy zapisać?")
    command = record_audio()
    if "tak" in command:
        speak("Podaj nazwę")
        name = record_audio()
        listfile = "notelist.txt"
        with open(listfile, 'a') as f:
            f.write(name + "\n")
        os.rename("note.wav", "{}-{}.wav".format(datetime.date.today(), name))
        speak("Zapisano notatkę: {}".format(name))
    elif "odtwórz" in command:
        os.system("aplay note.wav")
        speak("Czy zapisać?")
        command = record_audio()
        if "tak" in command:
            speak("Podaj nazwę")
            name = record_audio()
            listfile = "notelist.txt"
            with open(listfile, 'a') as f:
                f.write(name + "\n")
            os.rename("note.wav", "{}-{}.wav".format(datetime.date.today(), name))
            speak("Zapisano notatkę: {}".format(name))
        elif "nie" in command:
            os.remove("note.wav")
            speak("Notatka nie została zapisana")
    elif "nie" in command:
        os.remove("note.wav")
        speak("Notatka nie została zapisana")
    else:
        return
Ejemplo n.º 2
0
 def launch():
     speak("Podaj temat.")
     subject = record_audio()
     print(subject)
     speak("Podaj odbiorcę")
     recipient = record_audio()
     print(recipient)
     try:
         with open("recipients.txt") as f:
             emailContacts = dict(line.strip().split(":") for line in f)
     except FileNotFoundError:
         print("Lista odbiorców niedostępna.")
         emailContacts = {}
     if recipient in emailContacts:
         recipientAddress = emailContacts[recipient]
         print(recipientAddress)
         speak("Podaj treść")
         mailBody = record_audio()
         print(mailBody)
         speak("Przygotowano wiadomość do odbiorcy: " + recipient +
               " o temacie: " + subject + " i treści: " + mailBody +
               ". Czy otworzyć w programie pocztowym?")
         decision = record_audio()
         if decision == "tak":
             polecenie = "xdg-email --subject \'{!s}\' --body \'{!s}\' \'{!s}\'".format(
                 subject, mailBody, recipientAddress)
             subprocess.Popen(shlex.split(polecenie))
         else:
             speak("Kasuję wiadomość.")
     else:
         speak("Nie rozpoznano odbiorcy")
Ejemplo n.º 3
0
def note_playback():
    speak("Którą notatkę mam odtworzyć?")
    with open("notelist.txt") as file:
        lines = [line.strip() for line in file]
    command = record_audio()
    if command in lines:
        os.system("aplay {}-{}.wav".format(datetime.date.today(), command))
    else:
        speak("Nie znaleziono notatki.")
Ejemplo n.º 4
0
 def launch():
     speak("Czy uruchomić ponownie komputer?")
     command = record_audio()
     if "tak" in command:
         speak("OK.")
         os.system("shutdown -r now")
     else:
         speak("W porządku, anuluję operację.")
         return
Ejemplo n.º 5
0
 def launch():
     speak("Czy na pewno wyłączyć komputer?")
     command = record_audio()
     if "tak" in command:
         speak("Wyłączam komputer.")
         os.system("shutdown -h now")
     else:
         speak("W porządku, anuluję operację.")
         return
Ejemplo n.º 6
0
def note_remove():
    with open("notelist.txt") as file:
        lines = [line.strip() for line in file]
    speak("Którą notatkę mam usunąć?")
    command = record_audio()
    if command in lines:
        f = open("notelist.txt", "r")
        filecontent = f.read()
        f.close()
        newcontent = filecontent.replace("{}\n".format(command), "")
        f = open("notelist.txt", "w")
        f.write(newcontent)
        f.close()
        os.remove("{}-{}.wav".format(datetime.date.today(), command))
    else:
        speak("Nie znaleziono notatki.")
Ejemplo n.º 7
0
def note_list():
    speak("Lista notatek:")
    with open("notelist.txt") as file:
        lines = [line.strip() for line in file]
    for i in lines:
        speak(i)
    speak("Czy chcesz otworzyć którąś notatkę?")
    command = record_audio()
    if "tak" in command:
        note_playback()
    elif command in lines:
        os.system("aplay {}-{}.wav".format(datetime.date.today(), command))
    elif "nie" in command:
        speak("Rozumiem")
    else:
        return
Ejemplo n.º 8
0
def dictation():
    while True:
        output = (record_audio() + " ")
        if output == "przecinek ":
            output.replace("przecinek", ",")
            pyautogui.typewrite(output)
            continue
        elif output == "kropka ":
            output.replace("kropka", ".")
            pyautogui.typewrite(output)
            continue
        elif output == "enter ":
            output.replace("enter ", "\n")
            pyautogui.typewrite(output)
            continue
        elif "bez odbioru" in output:
            speak("okej")
            return
        else:
            for i in output:
                if i == 'ą':
                    pyautogui.hotkey('altright', 'a')
                elif i == "ć":
                    pyautogui.hotkey('altright', 'c')
                elif i == "ę":
                    pyautogui.hotkey('altright', 'e')
                elif i == "ł":
                    pyautogui.hotkey('altright', 'l')
                elif i == "ń":
                    pyautogui.hotkey('altright', 'n')
                elif i == "ó":
                    pyautogui.hotkey('altright', 'o')
                elif i == "ś":
                    pyautogui.hotkey('altright', 's')
                elif i == "ź":
                    pyautogui.hotkey('altright', 'x')
                elif i == "ż":
                    pyautogui.hotkey('altright', 'z')
                else:
                    print(i)
                    pyautogui.press(i)
Ejemplo n.º 9
0
def command_prompt(parameter):
    while True:
        if parameter == 'voice':
            command = record_audio()
        elif parameter == 'text':
            command = input()
        else:
            command = record_audio()
        if all(word not in command for word in (dictionary.quits + dictionary.plays + dictionary.pauses + dictionary.nexts)):
            if command in dictionary.lexicon:
                word = dictionary.lexicon[command]
                word.launch()
            elif programOn(command):
                elements = command.split(" ")
                for word in elements:
                    if word in dictionary.lexicon:
                        word = dictionary.lexicon[word]
                        word.launch()
            elif "gdzie" in command:
                command = command.split(" ", 2)
                location = command[2]
                speak("Pokazuję " + location)
                webbrowser.open_new_tab("https://www.google.com/maps/place/" + location + "/&")
            elif "co umiesz" in command:
                speak("Pokazuję listę funkcji")
                webbrowser.open_new_tab("https://github.com/ldziubek/alfred/blob/master/README.md")
            elif any(word in command for word in dictionary.search):
                command = command.split(" ", 1)
                keyword = command[1]
                speak("Wyszukuję " + keyword)
                webbrowser.open_new_tab("https://duckduckgo.com/?q=" + keyword)
            elif weatherInCity(command):
                elements = command.split(" ")
                for word in elements:
                    if word in dictionary.cities:
                        projectClasses.WeatherForecast.launchCity(word)
            elif weather(command):
                projectClasses.WeatherForecast.launch()
            if "to wszystko" in command:
                speak("Dziękuję. Bez odbioru.")
                return
            if "błąd rozpoznawania" in command:
                speak("Błąd. Bez odbioru.")
                return
        else:
            if programOff(command):
                elements = command.split(" ")
                for word in elements:
                    if word in dictionary.lexicon:
                        word = dictionary.lexicon[word]
                        word.kill()
            elif play(command):
                elements = command.split(" ")
                for word in elements:
                    if word in dictionary.lexicon:
                        word = dictionary.lexicon[word]
                        word.play()
            elif pause(command):
                elements = command.split(" ")
                for word in elements:
                    if word in dictionary.lexicon:
                        word = dictionary.lexicon[word]
                        word.pause()
            elif nextSong(command):
                elements = command.split(" ")
                for word in elements:
                    if word in dictionary.lexicon:
                        word = dictionary.lexicon[word]
                        word.next()