def file_finder(speak):
    print("please specify the file name without extension")
    file_name = None
    while True:
        file_name = ask()
        if file_name == "":
            continue
        else:
            print("Do you want to speak again? Yes/No:")
            if ask().lower() == "no":
                break
            else:
                continue

    print("please specify the extension")
    extension = None
    while True:
        extension = ask()
        if extension == "":
            continue
        else:
            print("Do you want to speak again? Yes/No:")
            if ask().lower() == "no":
                break
            else:
                continue
    file_name = file_name + "." + extension

    sysos = platform.system()
    if sysos == "Windows":
        Windows(file_name)
    elif sysos == "Linux":
        Linux(file_name)
    elif sysos == "Darwin":
        Macos(file_name)
Example #2
0
def deletefile():
    speak("please tell me file name to delete")
    query = ask().lower()
    speak("please tell the file extension")
    ext = ask().lower()
    ext = identify_extension(ext)
    query = query + ext
    if os.path.exists(str(query)):
        os.remove(str(query))
        speak("file deleted successfully")
        query = query.lower()
    else:
        speak("file doesnt exist")
Example #3
0
def createfile():
    speak("please tell me file name")
    query = ask().lower()
    speak("Tell the file type that you want to create")
    ext = ask().lower()
    ext = identify_extension(ext)
    query = query + ext
    f = open(query, "w")
    speak(
        "file created successfully. please tell me what do you want to write ")
    query = ask().lower()
    f.write(str(query))
    speak("file created")
def Linux(file_name):
    cmd = subprocess.Popen(
        f"find . -name {file_name}", shell=True, stdout=subprocess.PIPE
    )
    subprocess_return = cmd.communicate()
    ans = subprocess_return[0].decode("utf-8")
    paths = []
    for line in ans.split("\n"):
        paths.append(line)
    paths.pop()

    if len(paths) == 0:
        print("No such file found")
    elif len(paths) == 1:
        subprocess.Popen(f"xdg-open {paths[0]}", shell=True, stdout=subprocess.PIPE)
    else:
        j = 1
        for line in paths:
            print(str(j) + ".", line)
            j += 1
        print(
            "There are multiple files with this name. Please specify the id of the path you want to open."
        )
        number = int(ask())
        os.startfile(paths[number - 1])
def notethat():
    speak("what should i remember sir")
    rememberMessage = ask()
    speak("you said me to remember" + rememberMessage)
    remember = open("data.txt", "w")
    remember.write(rememberMessage)
    remember.close()
def search_wiki():
    speak("What do you want to search on wikipedia ?")
    sinwiki = ask()
    sinwiki = sinwiki.replace("wikipedia", "")
    results = wikipedia.summary(sinwiki, sentences=2)
    print(results)
    speak("According to Wikipedia,")
    speak(results)
def folder_finder():
    speak(
        "please specify the folder name which contains Movies Videos Photos or Musics"
    )
    file_k = ask()
    file_names = [file_k.lower()]
    if (file_k[-1] != 's'):
        file_names.append(file_k.lower() + 's')

    sysos = platform.system()
    found_paths = []
    if sysos == "Windows":
        drive_latter = os.popen("fsutil fsinfo drives").readlines()
        drive_latter = drive_latter[1].split(' ')
        drive_latter.pop(0)
        drive_latter.pop(-1)

        for file_name in file_names:
            for drive_path in drive_latter:
                found_paths.extend(find_folder(file_name, drive_path))
    elif sysos == "Linux":
        found_paths = find_folder(file_name, "//")
    elif sysos == "Darwin":
        found_paths = find_folder(file_name, "//")

    if len(found_paths) == 0:
        speak('Sorry, system cannot find your folder. Please try again.')
    elif len(found_paths) == 1:
        speak('Here System found only one folder with given file name')
        print('Here System found only one folder with given file name : ',
              file_k)
        ff = found_paths[0]
    else:
        speak('System found This many path, from which path you want to play')
        print('System found This many path from which you want to play',
              file_k.capitalize())
        print('\n***************************')
        for i in range(0, len(found_paths)):
            print(i + 11, ' : ', found_paths[i])
        print('***************************')

        ff = found_paths[int(ask()) - 11]
        print("\033[1m", '\nPlease provide the Number of the file :',
              "\033[0m")
    return ff
def folder_finder(speak):
    print("please specify the folder name")
    file_name = None
    while True:
        file_name = ask()
        if file_name == "":
            continue
        else:
            print("Do you want to speak again? Yes/No:")
            if ask().lower() == "no":
                break
            else:
                continue
    # file_name = ask()
    sysos = platform.system()

    if sysos == "Windows":
        found_paths = find_folder(file_name, "\\")
    elif sysos == "Linux":
        found_paths = find_folder(file_name, "//")
    elif sysos == "Darwin":
        found_paths = find_folder(file_name, "//")

    if len(found_paths) == 0:
        print("No such folder found")
    elif len(found_paths) == 1:
        os.startfile(found_paths[0])
    else:
        j = 1
        for line in found_paths:
            print(str(j) + ".", line)
            j += 1
        print(
            "There are multiple folders with this name. Please specify the id of the path you want to open."
        )
        number = int(ask())
        os.startfile(found_paths[number - 1])
def player():
    file_path_video = folder_finder()

    flist_video = [
        p for p in pathlib.Path(file_path_video).iterdir() if p.is_file()
    ]
    f_video = []
    filename = {}

    c = 0
    for f in flist_video:
        f_video.append('"' + str(f) + '"')
        stemp, ftemp = os.path.split(str(f))
        filename[c] = str(ftemp)
        c += 1

    speak('Please provide the Number of the file')
    print_dict(filename)
    t = int(ask()) - 11
    os.system(f_video[t])
def eval_s_caller(query):

    app_id = json.load(open(WFA_KEY_JSON, "r"))["APPID"]
    client = wolframalpha.Client(app_id)
    if "calculate" in query.lower():
        indx = query.lower().split().index("calculate")
    elif "evaluate" in query.lower():
        indx = query.lower().split().index("evaluate")

    try:
        query = query.split()[indx + 1:]
    except:
        speak("Could you please specify what to calculate?")
        query = ask()
    res = client.query(" ".join(query))
    try:
        answer = next(res.results).text
    except:
        speak("No responce from the API")
        return
    print("The answer is " + answer)
    speak("The answer is " + answer)
Example #11
0
    "delete ppt": delete_caller,
    "remove ppt": delete_caller,
    "delete powerpoint": delete_caller,
    "remove powerpoint": delete_caller,
    "delete css": delete_caller,
    "remove css": delete_caller,
    "delete javascript": delete_caller,
    "remove javascript": delete_caller,
    "delete python": delete_caller,
    "remove python": delete_caller,
    "delete java": delete_caller,
    "remove java": delete_caller,
    "delete cpp": delete_caller,
    "remove cpp": delete_caller,
    "delete html": delete_caller,
    "remove html": delete_caller,
    "delete pdf": delete_caller,
    "remove pdf": delete_caller,
}

# main function
if __name__ == "__main__":

    while True:
        query = ask().lower()

        if str(query) in query:
            # calling create file function
            speak("deleting file")
            deletefile()
my_list = []

my_list += list(dict1.keys())
query_list = list(my_list)

rm = True
# print(rb.recombyte_q.__docs__())
if rm or not os.path.exists(rb.DATA_STORAGE_FILENAME):
    # os.remove("F:\\temp\Grp-28-Intelligent_Systems_of_Voice_Recognition\Project\ISVR\data_storage.p")
    rb.save_data(query_list)

query_list, total_words, words_dict, tot_words_dict = rb.load_data()
command = None
while True:

    command = va.ask().lower()
    if command == "":
        continue
    if "search" in command and "online" in command:
        webbrowser.open("https://www.google.com/search?q=" +
                        command.split("online")[1])
        continue
    if ("stop" in command and "stopwatch"
            not in command) or "shut down" in command or "shutdown" in command:
        break
    answer = rb.recombyte_q(command,
                            query_list,
                            words_dict,
                            tot_words_dict,
                            t4=0.9)
"""
Developer   : Naman Dave
College ID  : 201801439
About       : Temporary file (for testing purpose)
"""
import os
import src.va as va
import recombyte as rb

my_list = [
        ]
query_list = list(my_list)

rm = True

if rm or not os.path.exists(rb.DATA_STORAGE_FILENAME):
    os.remove("data_storage.p")
    rb.save_data(query_list)

query_list, total_words, words_dict, tot_words_dict = rb.load_data()
command = ""
while True:
    command = va.ask()
    if "stop" in command:
        break
    answer = rb.recombyte_q(command, query_list, words_dict, tot_words_dict)
    print(answer)
    if answer != []:
        va.speak(answer[0][0])