Esempio n. 1
0
def remf():
    setd = setf()
    os.chdir(setd)
    dir = os.listdir(os.path.isdir(setd))
    print dir
    mouth('Which folder do you want to delete ?')
    delf = ear()
Esempio n. 2
0
def ear():
    with mic as source:
        recognizer.adjust_for_ambient_noise(source)
        audio = recognizer.listen(source)
    text=''
    if conct is True:
        # recognize speech using Google
        try:
            text = recognizer.recognize_google(audio)
            return text
        except sr.UnknownValueError:
            mouth("Sorry, What did you said !")
            logging.info("Not Recognised")
            ear()
        except sr.RequestError as e:
            print("What's happening ? ; {0}".format(e))
            logging.error(e.message)
    else:
        # recognize speech using Sphinx
        try:
            text = recognizer.recognize_sphinx(audio)
            return text
        except sr.UnknownValueError:
            print("What did you said !")
        except sr.RequestError as e:
            print("What's happening ? ; {0}".format(e))
Esempio n. 3
0
def hotword():
    try:
        hotw = recognizer.recognize_google(audio)
        return hotw
    except sr.UnknownValueError:
        print("What did you said !")
        mouth("Sorry..What did you said !")
    except sr.RequestError as e:
        print("What's happening ? ; {0}".format(e))
Esempio n. 4
0
def setf():
    mouth("Choose a folder where do you want to do folder opearations")
    mouth("Download \t Document \t Picture\t Music\t Video \t Desktop")
    mouth("Default is Home Directory")
    fld = home
    destf = ear()
    print destf
    if "download" in destf:
        fld += '/Downloads'
        return fld
    elif "document" in destf:
        fld += '/Documents'
        return fld
    elif "pictures" in destf:
        fld += '/Pictures'
        return fld
    elif "music" in destf:
        fld += '/Music'
        return fld
    elif "videos" in destf:
        fld += '/Videos'
        return fld
    elif "desktop" in destf:
        fld += '/Desktop'
    else:
        return fld
Esempio n. 5
0
def makef(name):
    fol = name
    os.chdir(fol)
    fname = ear()
    fname = fname.replace(" ", "_")
    print fname

    if os.path.isdir(fol + '/' + fname) == True:
        mouth("oops Folder already exist")
        mouth("Choose another Name")
        makef()
    else:
        out = os.popen('mkdir ' + fname)
        mouth("%s has been created in %s Directory" % fname % fol)
Esempio n. 6
0
def setf():
    mouth("Choose a folder from below")
    mouth("1.Downloads \t 2.Documents \t 3.Pictures\t 4.Music\t 5.Videos")
    mouth("Default is Home Directory")
    fld = home
    destf = ear()
    print destf
    if "download" in destf:
        fld = fld + '/Downloads'
        return fld
    elif "documents" in destf:
        fld = fld + '/Documents'
        return fld
    elif "pictures" in destf:
        fld = fld + '/Pictures'
        return fld
    elif "music" in destf:
        fld = fld + '/Music'
        return fld
    elif "videos" in destf:
        fld = fld + '/Videos'
        return fld
    else:
        return fld
Esempio n. 7
0
def remf():
    mouth("From which folder folder")
    locf = ear()
    mouth('Which folder do you want to delete ?')
    delf = ear()
Esempio n. 8
0
def brain():
    string = ear()
    try:
        word_list = word_tokenize(string)
        if "search" in word_list and "google" not in word_list:
            searchs = string.replace('search', '')
            query = 'https://www.google.co.in/search?safe=active&q=' + searchs
            print string
            mouth('Searching...' + searchs)
            webbrowser.open(query)

        elif "mute" in word_list or "volume" in word_list:
            q = os.popen(
                """amixer sget Master | awk -F"[][]" '/dB/ { print $2 }'"""
            ).read()
            current_vol = int(q.replace('%', ''))

            if "increase" in word_list or "up" in word_list:
                if current_vol == 100:
                    mouth("Cannot Increasse further")
                else:
                    mouth("increassing Volume")
                    print(
                        os.popen('amixer set Master ' + str(current_vol + 10) +
                                 '%').read())

            elif "decrease" in word_list or "down" in word_list:
                if current_vol == 00:
                    mouth("Cannot Increasse further")
                else:
                    mouth("decreassing Volume")
                    print(
                        os.popen('amixer set Master ' + str(current_vol - 10) +
                                 '%').read())
            elif "mute" in word_list:
                print(os.popen('amixer set Master 0%').read())
                mouth("Muted")
        elif "folder" in word_list or "directory" in word_list:
            if "make" in word_list or "create" in word_list:
                fol = setf()
                mouth("What name do you want to give ?")
                makef(fol)
            elif "remove" in word_list or "delete" in word_list:
                remf()
        elif "shutdown" in word_list or "turn off" in word_list:
            mouth("Are you sure to shutdown")
            confirm = ear()
            if confirm == 'yes':
                os.popen('shutdown')
                mouth("System will shutdown in a minute")
            else:
                mouth("Thank you for not tuning me off.")
        elif "reboot" in word_list or "restart" in word_list:
            mouth("Are you sure to shutdown")
            confirm = ear()
            if confirm == 'yes':
                os.popen('systemctl reboot -i')
                mouth("Rebooting")
            else:
                mouth("Thank you for not tuning me off.")
        elif "file" in word_list:
            pass
    except Exception as e:
        logging.error(e.message)