diff --git a/Get_Weather.py b/Get_Weather.py new file mode 100644 index 0000000..8ef7bc0 --- /dev/null +++ b/Get_Weather.py @@ -0,0 +1,3 @@ +import webbrowser +query=input("") +webbrowser.open(f"weather {query}") \ No newline at end of file diff --git a/Get_website.py b/Get_website.py new file mode 100644 index 0000000..3230e11 --- /dev/null +++ b/Get_website.py @@ -0,0 +1,92 @@ +# import requests +# +# # Making a GET request +# r = requests.get('https://www.geeksforgeeks.org/python-programming-language/') +# +# # check status code for response received +# # success code - 200 +# print(r) +# +# # print content of request +# print(r.content) + +# +# import requests +# +# # Making a GET request +# r = requests.get('https://www.geeksforgeeks.org/python-programming-language/') +# +# # print request object +# print(r.url) +# +# # print status code +# print(r.status_code) + + +# import requests +# from bs4 import BeautifulSoup +# +# # Making a GET request +# r = requests.get('https://www.geeksforgeeks.org/python-programming-language/') +# +# # Parsing the HTML +# soup = BeautifulSoup(r.content, 'html.parser') +# +# s = soup.find('div', class_='entry-content') +# +# lines = s.find_all('p') +# +# for line in lines: +# print(line.text) + + +# import requests +# from bs4 import BeautifulSoup +# +# # Making a GET request +# r = requests.get('https://www.instagram.com/talwiinder') +# +# # Parsing the HTML +# soup = BeautifulSoup(r.content, 'html.parser') +# +# # find all the anchor tags with "href" +# for link in soup.find_all('a'): +# print(link.get('href')) +from bs4 import BeautifulSoup as bs +import pandas as pd +pd.set_option('display.max_colwidth', 500) +import time +import requests +import random + +# List of Authors and Quotes +authors = [] + +quotes = [] + +# List of URLs +urls = [f"http://quotes.toscrape.com/page/{i}/" for i in range(1, 11)] + +# List for Randomizing our request rate +rate = [i / 10 for i in range(10)] + +# Iterating through the URLS +for url in urls: + + # Accessing the Webpage + page = requests.get(url) + + # Getting the webpage's content in pure html + soup = bs(page.content) + + # Adding the authors and quotes to their lists + authors.extend([i.text for i in soup.find_all(class_='author')]) + + quotes.extend([i.text for i in soup.find_all(class_='text')]) + + # Checking to see if we hit our required number of quotes then breaking the loop + if len(quotes) >= 52: + break + + # Randomizing our request rate + time.sleep(random.choice(rate)) \ No newline at end of file diff --git a/Personalised AI ChatBot.py b/Personalised AI ChatBot.py new file mode 100644 index 0000000..dfb24a4 --- /dev/null +++ b/Personalised AI ChatBot.py @@ -0,0 +1,244 @@ +import datetime, webbrowser, os, time +from winotify import Notification, audio + +import wikipedia as wiki + +from subprocess import call +import ctypes + +import requests +import random +import AppOpener + +def ask(): + user_query = str(input("User: ")) + return user_query + +def arguements(): + say(random.choice('yes', "no")) +def say(str): + print(f'Bot: {str}') +def say_end(str,end_with='\n'): + print(f'Bot: {str}',end=end_with) + +def sites(site): + website_link = {'instagram': "instagram.com", + 'chat gpt': 'chat.openai.com', + 'youtube music': 'music.youtube.com', + 'youtube': 'youtube.com', + 'google': 'google.com', + 'github': 'github.com', + 'gmail': 'https://mail.google.com/'} + + # say("in") + say(f"Opening {site}") + link=website_link.values() + link=list(link) + names=website_link.keys() + names=list(names) + try: + link_to=link[names.index(site)] + webbrowser.open(f'{link_to}') + print(site) + say(f"Opened {site}") + except ValueError: + webbrowser.open(f'{site}.com') + +# def OpenDir +def OpenApp(app_name): + say(f"Opening {app_name.removeprefix('open')}") + AppOpener.open(app_name,output=False,match_closest=True) + say(f"Opened {app_name.removeprefix('open')}!") +def drink_Water(): + call(["python", "water_notification.py"]) + +def CloseApp(App_name): + say(f"Closing {App_name}") + AppOpener.close(App_name,output=False,match_closest=True) + say(f"Closed {App_name}") +def wishMe(): + call(["python", "WishMe.py"]) + +def wiki_search(user_query): + cmd_title ,cmd_query =user_query.replace("search","").replace("wikipedia",'').replace("in"or"about"or"for","").strip(),cmd_title.removesuffix("about") + search_results = wiki.summary(cmd_query) + say("Here\'s your results") + say("*results may not be accurate*") + ctypes.windll.user32.MessageBoxW(0, search_results, f'''Searches {cmd_title}''', 0) + say("You may continue:)") + +def get_weather(user_query): + say("Opening your request, Hang on tight!",) + user_query = user_query.replace("get", "").capitalize() + webbrowser.open(f"{user_query}") + say("Opened the weather forcast for your requested city!") + +def Clear_Cache(): + try: + path1 = r"C:\Windows\Temp" + path2=r'C:\Users\sahil\AppData\Local\Temp' + for file in os.listdir(path1): + os.remove(file) + for file in os.listdir(path2): + os.remove(file) + say("Cleared your memory(cache)") + except WindowsError as e: + return e + +try: + wishMe() + while True: + user_query = ask() + if 'open' in user_query: + + #opening websites + if 'website' in user_query or 'site' in user_query : + + user_query=user_query.replace("open website",'') + sites(user_query) + + # Opening apps commands proceeds + elif "app" in user_query: + OpenApp(user_query.replace("open ",'').replace("app ",'')) + # Opening DIRS + elif 'directory' in user_query or 'dir' in user_query : + + + say(f'''Opening {user_query.removeprefix("open").replace("directory",'').strip()} ''') + os.startfile(f'''C:\\Users\\sahil\\{user_query.removeprefix("open").replace("directory"or"dir",'').strip()}''') + say(f'''Opened {user_query.removeprefix("open").replace("directory"or"dir",'').strip()} Dir''') + + else: + say("What do you wanna open?") + for i in list(["directory",'app','website']): + if i!=user_query: + say_end(f"{i}?") + say("just write `open {dir/app/website} {name}`") + + # play dirext video /song from youtube + elif 'play ' in user_query: + query=user_query.replace("play",'').capitalize() + say(f"Playing `{query}` in youtube") + webbrowser.open(f"https://youtube.com/results?search_query={query}") + elif 'time' in user_query: + if ("whats"and'the') in user_query: + strTime = datetime.datetime.now().strftime("%H:%M:%S") + say(f"{strTime}") + elif '?' in user_query: + strTime = datetime.datetime.now().strftime("%H:%M:%S") + say(f"if you asked about `what\'s the time` \n then it\'s {strTime}") + elif 'search' in user_query: + if 'module' in user_query: + user_query = user_query.replace("search module ", "").capitalize() + say("Opening `docs.python` , `pypi.org` and `python.org` for you:)") + search_Query1 = webbrowser.open(f"pypi {user_query}") + search_Query2 = webbrowser.open(f"docs.python. org {user_query}") + search_Query3=webbrowser.open(f'python.org {user_query}') + say("Opened!\n now go and continue your search!") + elif "wikipedia" in user_query: + wiki_search(user_query) + + elif 'browse' in user_query: + query=user_query.replace("browse ",'').capitalize() + say(f"doing your research about `{query}`") + say("Opening browser for the results!") + time.sleep(1) + webbrowser.open(query) + say("Opened browser") + elif 'minimize' in user_query: + + os.startfile(r"C:\Users\Default\AppData\Local\Microsoft\Windows\WinX\Group1\1 - Desktop.lnk") + elif 'show desktop' in user_query or 'show desktop'.capitalize() in user_query or 'minimize to taskbar' in user_query: + os.startfile(r"C:\Users\Default\AppData\Local\Microsoft\Windows\WinX\Group1\1 - Desktop.lnk") + + elif'clear' in user_query and 'cache' in user_query: + Clear_Cache() + + + + # elif 'set' in user_query: + # if 'reminder' in user_query: + # if 'water' in user_query: + + # say("Do you wanna turn on your \`drink water reminder\`?\n**it can be turn off**") + # drink_water_on = ask() + # if drink_water_on == "yes" or drink_water_on == 'on': + # say("Your `drink water notifier` is on") + # drink_Water() + # + # elif drink_water_on != (('yes' or 'on') or ('no' or 'off')): + # say("i didn\'t understand that!") + # else: + # say("i can\'t turn it off!") + # say("Sorry!") + elif 'get' in user_query: + if 'weather' in user_query: + if user_query.replace((("get weather"or "get weather forecast")and "for"),"") =="": + say("getting Forecast based on your location.since, you didn\'t provide an input for location") + get_weather(user_query) + say("Opened Weather Forecast based on your location:)") + else: + user_query.replace((("get weather"or "get weather forecast")and "for"),"").capitalize() + get_weather(user_query) + elif ('bot'and'info') in user_query: + say("Here are my information:\n Name : Lucifier ;\n Birth: 01/07/2023 ;\n Made by: Sahil:) ;") + elif ('all' and 'functions') in user_query: + say("i can do all this things:\n ~getting weather info and time;\n ~Can do searches for you;\n ~Can open specific sites-\n {`instagram`\n ,`youtube`,`ChatGPT`\n ,`YT Music`,`Spotify`};\n ~can open apps - \n {Vscode,spotify,python\n ,paint,notepad, edge,\n terminal, brave, notion,\n discord, github desktop,\n cmd,file explorer, telegram,\n opera gx browser, control panel};\n ~ Can remind you to drink water;") + + # engaging in casual converstional + elif 'hi' in user_query or 'Hi' in user_query or 'Hey' in user_query or 'Hello' in user_query or 'hey' in user_query or 'hello' in user_query: + + greets = ['Hi, nice to meet you!', 'oh hi:)', 'Hi master , what are you upto now?', + ] + say(random.choice(greets)) + + elif 'okay'in user_query or 'ok'in user_query or'OK'in user_query or'Ok'in user_query or'oky'in user_query or'Okyy'in user_query : + responses=['Yeah','Yup','Yes','Nvm:)','Always on your service!'] + say(random.choice(responses)) + + + elif 'Bye' in user_query or 'bye' in user_query or "take rest" in user_query: + exiting_code= ["Thank you for using me........!",'Thank you for making me a part of your screen time \n now you go and take rest, bye!','i appreciate your interest in me!\n For now im going off as you asked \n Thank you master'] + say(random.choice(exiting_code)) + exit() + elif 'how are you' in user_query: + replies=["I\'m absolutely fine, wby?","I\'m doing great.\n what about you?", "i\'m great,you?"] + say(random.choice(replies)) + elif 'im great' in user_query or 'im good' in user_query or 'i doing great' in user_query or 'im fine' in user_query or 'im fine too' in user_query: + replies=["Great king!๐Ÿ‘‘",'Good to hear that','Nice...','Keep moving on then brotherrr!!๐Ÿ“ˆ','feels good to hear that you are okay'] + say(random.choice(replies)) + elif 'yep' in user_query or'yes' in user_query or'yup' in user_query or'yeah' in user_query: + responses=['great!๐Ÿ‘',"OG๐Ÿ˜ถโ€๐ŸŒซ๏ธ",'okay!','Ok','ok'] + say(random.choice(responses)) + elif 'close' in user_query: + user_query= user_query.replace("close ",'') + CloseApp(user_query) + + else: + say("Sorry, i didn\'t understand that please repeat:)") +except Exception as e: + print(e) +# say("You can continue!") +# e=Exception +# with open(r"errors.txt","w+") as file: +# file.write(e) +# file.close() + +finally: + exit() + # print("\n") + # say('Sorry for the issue i ran in to a problem \n' + # " if you want to exit type `exit` or press `stop`\n" + # " If you want to give FeedBack type`feedback`\n" + # ) + # show_not = ask() + # if show_not == 'exit': + # say("Thank you for using me!") + # exit() + # elif show_not == 'feedback': + # say("you can give your feedback now:)") + # give_feedback = ask() + # if give_feedback != '' or give_feedback == '': + # say("Thank you for giving your feedback") + # + diff --git a/Personalised AI ChatBot2.py b/Personalised AI ChatBot2.py new file mode 100644 index 0000000..7c795a1 --- /dev/null +++ b/Personalised AI ChatBot2.py @@ -0,0 +1,50 @@ +import PIL.Image +import pystray +from PIL import Image + + +import pyttsx3 +from subprocess import call + + +image = PIL.Image.open("infinity.png") +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +# print(voices[1].id) +engine.setProperty('voice', voices[0].id) + + +def speak(audio): + engine.say(audio) + engine.runAndWait() + + +def if_clicked(icon, item): + if str(item) == 'Yes': + speak("So i guess we are starttighten your seatbelts! we are ready to launch!!") + print("So i guess we are going to start on, tighten your seatbelts! \nWe are ready to launch!!") + print("Starting!!") + speak("Starting") + speak("Started!") + call(["python", "Personalised AI ChatBot.py"]) + elif str(item) == 'No': + + speak("So you dont want me to start yet? that\'s totally okay. tell me when you are ready") + print("So you dont want me to start yet? \n that\'s totally okay. tell me, when you are ready") + + + elif str(item) == "Stop": + speak("Au revoir , see you soon!") + print("Au revoir , see you soon!") + icon.stop() + + +icon = pystray.Icon("Infinity", image, menu=pystray.Menu( + pystray.MenuItem("Start", pystray.Menu( + pystray.MenuItem("Yes", if_clicked), + pystray.MenuItem("No", if_clicked) + )), + pystray.MenuItem("Stop", if_clicked), +)) +if __name__ == '__main__': + icon.run() diff --git a/README.md b/README.md index 50a9444..bcb26df 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,65 @@ -# ChatBot -This an ai-based python chatbot. This an example of an basic ai program. - -# Practical Understanding -## Modules used - - `Random` (version 1.0.1) - [Documentation](https://docs.python.org/3/library/random.html) - - `Wikipedia` (version 1.4.0) - [Documentation](https://pypi.org/project/wikipedia/) - - `Time` (version 0.3.0) - [Documentation](https://docs.python.org/3/library/time.html) - - ## Working - - The `generate_response` function takes the user's input, checks it against the keywords defined in the various functions, and returns an appropriate response based on the highest-priority keyword matched. - -# Theoretical Understanding - ### Introduction to the chatbot: - - The chatbot is a program written in Python that can communicate with users by interpreting and responding to text-based inputs. The chatbot is designed to respond to certain keywords or phrases, such as greetings, inquiries about the user's well-being, and questions asked by the user. The chatbot is also capable of using the Wikipedia API to provide information and answer user questions. - - The purpose of the chatbot is to provide a user-friendly and interactive experience for those who interact with it. By responding to user inputs in a conversational manner, the chatbot can create a more engaging and personalized experience for the user. The chatbot can also be used in a variety of settings, such as customer service, education, and entertainment, among others. - - The chatbot's functionality and capabilities can be further developed and improved with additional programming and integration with other tools and technologies. Ultimately, the chatbot has the potential to be a powerful and versatile tool for interacting with users in a variety of contexts. - - ### Features of the chatbot include - - - Greeting: The chatbot can greet the user with various responses such as "hi", "hello", and "hey". - - - Responding to inquiries: The chatbot can respond to inquiries about the user's well-being with responses like "I'm good, thanks for asking!" and "I'm doing well, thanks!". - - - Responding to other phrases: The chatbot can respond to certain phrases like "nice", "good", and "great" with responses like "yes" and "yeah". - - - Answering user questions: The chatbot can respond to the user's request to ask a question by using the Wikipedia API to provide information and answer the user's question. - - Exiting the chat: The user can exit the chat by typing "exit". - ### Design and Development - - A simple chatbot that can respond to certain user inputs using pre-defined responses. The chatbot is designed to work in a loop, continuously accepting input from the user and generating responses until the user chooses to exit the program. - - The chatbot uses several functions to determine the appropriate response based on the user's input. For example, the `greetings` function uses a for loop to iterate through the words in the user's input and check if any of them match pre-defined greetings. If a match is found, the function returns a random greeting from a list of possible responses. - - Similarly, the `inquiry` function checks if the user's input contains any pre-defined inquiry phrases, and if a match is found, returns a random response from a list of possible answers. - - The chatbot also includes functions to respond to certain other phrases and to answer user questions using the Wikipedia API. The `generate_response` function calls these functions based on the user's input to determine the appropriate response. - - Finally, the chatbot includes a `while` loop that continuously accepts input from the user and generates responses until the user types "exit" to terminate the program. - - Overall, the code is a simple demonstration of how a chatbot can be built using Python, but there is certainly room for further development and improvement, such as adding more features, improving the natural language processing, and enhancing the user experience. - -### Applications of Chatbot - - - Customer service: The chatbot can be used as an initial point of contact for customer inquiries, providing automated responses to common questions and routing more complex queries to human support staff. - - - Informational services: The chatbot can be used to provide information on a wide range of topics, from weather forecasts and news updates to answers to more specialized questions. - - - Language learning: The chatbot could be adapted to provide language learning exercises or quizzes, helping users to improve their language skills through interactive conversations. - - - Personal assistance: The chatbot could be adapted to provide personal assistance, such as scheduling reminders, making reservations, or even ordering groceries or other goods and services. - - - Education: The chatbot could be used in educational settings to provide students with interactive lessons and quizzes, or to provide feedback and support for online courses. - - -### Pros - - The code is written in Python, a widely used and popular programming language. - * The chatbot responds to different types of inputs, such as greetings, inquiries about the user's well-being, and questions asked by the user. - + The chatbot uses the Wikipedia API to answer user questions. - - The chatbot provides a default response when it doesn't understand the user's input. - * The code is easy to understand and modify if needed, with each function focusing on a specific keyword or phrase and returning a corresponding response. - -### Cons - - - The chatbot's responses are limited to specific keywords or phrases, which may not cover all possible user inputs. - * The chatbot's use of the Wikipedia API may not always return the most accurate or up-to-date information. - + The chatbot is limited to text-based communication and cannot respond to voice or visual inputs. - -### Future plans - - - Our future plans is to make more efficient and not just to bound the program to specific responses. - - This plan is my personal favourite, make an voice assistant bot. +# What's a Chatbot? +[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/) +[![Build Status](https://travis-ci.org/isahilchanna/repo.svg?branch=Voice_CB)](https://travis-ci.org/isahilchanna/chatbot) + +>[!Important] +>This Branch has Voice inputs as well as Voice outputs too +>On top of that all of them in one file too +- It's a computer program that can have conversations with people, like a digital friend you can chat with! +- It uses artificial intelligence (AI) to understand what you type or say and respond in a way that makes sense. +- It's like having a friendly robot who's always ready to talk! + +## Chatbot's Key Features: +- Greetings: It can say hi, hello, and hey in a friendly way. +- Inquiries: It can ask how you're doing and respond to your well-being. +- Answering Questions: It can use Wikipedia to find answers to your questions, like a mini-search engine. +- Understanding Simple Phrases: It can get the gist of phrases like "nice" or "good" and respond appropriately. + +## How It Works (Behind the Scenes): +- It's written in Python, a popular programming language that makes it easy to understand and modify. +- It uses a "keyword matching" algorithm, which means it looks for specific words or phrases in your messages and responds with matching answers. +- It has different functions for different types of conversations, like greetings, inquiries, and answering questions. +- It keeps talking until you type "exit" to end the chat. +- Modules used : + - `pyttsx3` 2.90 - ([Documentation](https://pypi.org/project/pyttsx3/)) + - `Speech Recognition` 3.10.1 - ([Documentation](https://pypi.org/project/SpeechRecognition/)) + - `OS` - ([Documentation](https://docs.python.org/3/library/os.html?highlight=os#module-os)) + - `Smtplib` 20.12 - ([Documentation](https://docs.python.org/3/library/smtplib.html?highlight=smtplib#module-smtplib)) + - `Wikipedia` 1.4.0 - ([Documentation](https://pypi.org/project/wikipedia/)) + - `AppOpener` 1.7.0 - ([Documentation](https://pypi.org/project/appopener/)) + - `Webbrowser` ([Documentation](https://docs.python.org/3/library/webbrowser.html?highlight=webbrowser#module-webbrowser)) + - `Datetime` 5.4.0 ([Documentation](https://pypi.org/project/DateTime/)) + - `Ctypes` 1.2. ([Documentation](https://docs.python.org/3/library/ctypes.html?highlight=ctypes#module-ctypes)) + - `nltk` 3.8.1 ([Documentation](https://pypi.org/project/nltk/)) + - `pystray` 0.19.5 ([Documentation](https://pypi.org/project/pystray/)) + - `scikit-learn` 1.3.2 ([Documentation](https://pypi.org/project/scikit-learn/)) + - `winotify` 1.1.0 ([Documentation](https://pypi.org/project/winotify/)) + +## Applications: +- Personal Assistance +- Informational services +- Domain specific services +- Education + +## Strengths: +- Easy to understand and Modify +- leverages Wikipedia for informational access +- Handles diverse input types +- Provides default responses for unkown inputs + +## Limitations: +- Limited to pre-defined responses +- Relies on Wikipedia for accuracy +- Text-only interactions , no Graphic interphase + +## Cool Things About Your Chatbot: +- It's a great example of a basic AI program, showing how you can create smart interactions with computers. +- It has potential for lots of different uses, like helping customers, teaching students, or just being a fun companion. + +## Areas for Improvement: +- Right now, it's limited to text-based conversations. It would be awesome to give it a voice so you could talk to it instead of typing! +- It could also be made smarter by teaching it to understand more complex language and respond in more flexible ways. + +## Exciting Future Plans: +- Making it more efficient so it can handle conversations more smoothly. +- Giving it a voice so you can have a real conversation with it! diff --git a/Requirements.txt b/Requirements.txt new file mode 100644 index 0000000..e720f52 --- /dev/null +++ b/Requirements.txt @@ -0,0 +1 @@ +pip install pyttsx3 diff --git a/Restrainer.png b/Restrainer.png new file mode 100644 index 0000000..71c3d88 Binary files /dev/null and b/Restrainer.png differ diff --git a/SetRem.py b/SetRem.py new file mode 100644 index 0000000..4a5a146 --- /dev/null +++ b/SetRem.py @@ -0,0 +1,2 @@ +import time +import datetime diff --git a/Text-to-Voice.py b/Text-to-Voice.py new file mode 100644 index 0000000..12ccd8f --- /dev/null +++ b/Text-to-Voice.py @@ -0,0 +1,252 @@ +import datetime, webbrowser, os, time +from winotify import Notification, audio +import wikipedia as wiki +from subprocess import call +import ctypes +import requests +import random +import AppOpener +import pyttsx3 +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[1].id) +engine.setProperty('rate',140) +print("~~Text-to-Voice~~") +# Define function to speak text +def speak(text): + engine.setProperty('voice', voices[1].id) + + engine.say(text) + engine.runAndWait() + print(f'Bot: {text}') +def ask(): + user_query = str(input("User(type): ")) + return user_query + + +def sites(site): + website_link = {'instagram': "instagram.com", + 'chat gpt': 'chat.openai.com', + 'youtube music': 'music.youtube.com', + 'youtube': 'youtube.com', + 'google': 'google.com', + 'github': 'github.com', + 'gmail': 'https://mail.google.com/'} + + # speak("in") + speak(f"Opening {site}") + link=website_link.values() + link=list(link) + names=website_link.keys() + names=list(names) + try: + link_to=link[names.index(site)] + webbrowser.open(f'{link_to}') + print(site) + speak(f"Opened {site}") + except ValueError: + webbrowser.open(f'{site}.com') + +# def OpenDir +def OpenApp(app_name): + speak(f"Opening {app_name.removeprefix('open')}") + AppOpener.open(app_name,output=False,match_closest=True) + # speak(f"Opened {app_name.removeprefix('open')}!") +def drink_Water(): + call(["python", "water_notification.py"]) + +def CloseApp(App_name): + speak(f"Closing {App_name}") + AppOpener.close(App_name,output=False,match_closest=True) + speak(f"Closed {App_name}") +def wishMe(): + call(["python", "WishMe2_voice.py"]) + +def wiki_search(user_query): + cmd_title ,cmd_query =user_query.replace("search","").replace("wikipedia",'').replace("in"or"about"or"for","").strip(),cmd_title.removesuffix("about") + search_results = wiki.summary(cmd_query) + speak("Here\'s your results") + speak("*results may not be accurate*") + ctypes.windll.user32.MessageBoxW(0, search_results, f'''Searches {cmd_title}''', 0) + speak("You may continue:)") + +def get_weather(user_query): + speak("Opening your request, Hang on tight!",) + user_query = user_query.replace("get", "").capitalize() + webbrowser.open(f"{user_query}") + speak("Opened the weather forcast for your requested city!") + +def Clear_Cache(): + try: + path1 = r"C:\Windows\Temp" + path2=r'C:\Users\sahil\AppData\Local\Temp' + for file in os.listdir(path1): + os.remove(file) + for file in os.listdir(path2): + os.remove(file) + speak("Cleared your memory(cache)") + except WindowsError as e: + return e + +try: + wishMe() + while True: + user_query = ask() + if 'open' in user_query: + + #opening websites + if 'website' in user_query or 'site' in user_query : + + user_query=user_query.replace("open website",'') + sites(user_query) + + # Opening apps commands proceeds + elif "app" in user_query: + OpenApp(user_query.replace("open ",'').replace("app ",'')) + # Opening DIRS + elif 'directory' in user_query or 'dir' in user_query : + + + speak(f'''Opening {user_query.removeprefix("open").replace("directory",'').strip()} ''') + os.startfile(f'''C:\\Users\\sahil\\{user_query.removeprefix("open").replace("directory"or"dir",'').strip()}''') + speak(f'''Opened {user_query.removeprefix("open").replace("directory"or"dir",'').strip()} Dir''') + + else: + speak("What do you wanna open?") + for i in list(["directory",'app','website']): + if i!=user_query: + speak_end(f"{i}?") + speak("just write `open {dir/app/website} {name}`") + + # play dirext video /song from youtube + elif 'play ' in user_query: + query=user_query.replace("play",'').capitalize() + speak(f"Playing `{query}` in youtube") + webbrowser.open(f"https://youtube.com/results?search_query={query}") + elif 'time' in user_query: + if ("whats"and'the') in user_query: + strTime = datetime.datetime.now().strftime("%H:%M") + speak(f"The time is {strTime}") + elif '?' in user_query: + strTime = datetime.datetime.now().strftime("%H:%M") + speak(f"if you asked about `what\'s the time` \n then it\'s {strTime}") + elif 'search' in user_query: + if 'module' in user_query: + user_query = user_query.replace("search module ", "").capitalize() + speak("Opening `docs.python` , `The Python Package Index` and `python's official website' for you:)") + search_Query1 = webbrowser.open(f"pypi {user_query}") + search_Query2 = webbrowser.open(f"docs.python. org {user_query}") + search_Query3=webbrowser.open(f'python.org {user_query}') + speak("Opened!") + speak("You may continue:)") + elif "wikipedia" in user_query: + wiki_search(user_query) + + elif 'browse' in user_query: + query=user_query.replace("browse ",'').capitalize() + speak(f"doing your research about `{query}`") + speak("Opening browser for the results!") + time.sleep(1) + webbrowser.open(query) + speak("Opened browser") + elif 'minimize' in user_query: + + os.startfile(r"C:\Users\Default\AppData\Local\Microsoft\Windows\WinX\Group1\1 - Desktop.lnk") + elif 'show desktop' in user_query or 'show desktop'.capitalize() in user_query or 'minimize to taskbar' in user_query: + os.startfile(r"C:\Users\Default\AppData\Local\Microsoft\Windows\WinX\Group1\1 - Desktop.lnk") + + elif'clear' in user_query and 'cache' in user_query: + Clear_Cache() + speak("Cleared your memory(cache)") + + + + # elif 'set' in user_query: + # if 'reminder' in user_query: + # if 'water' in user_query: + + # speak("Do you wanna turn on your \`drink water reminder\`?\n**it can be turn off**") + # drink_water_on = ask() + # if drink_water_on == "yes" or drink_water_on == 'on': + # speak("Your `drink water notifier` is on") + # drink_Water() + # + # elif drink_water_on != (('yes' or 'on') or ('no' or 'off')): + # speak("i didn\'t understand that!") + # else: + # speak("i can\'t turn it off!") + # speak("Sorry!") + elif 'get' in user_query: + if 'weather' in user_query: + if user_query.replace((("get weather"or "get weather forecast")and "for"),"") =="": + speak("getting Forecast based on your location since, you didn\'t provide an input for location") + get_weather(user_query) + speak("Opened Weather Forecast based on your location:)") + else: + user_query.replace((("get weather"or "get weather forecast")and "for"),"").capitalize() + get_weather(user_query) + elif ('bot'and'info') in user_query: + speak("Here are my information:\n Name : Lucifier ;\n Birth: 01/07/2023 ;\n Made by: Sahil:) ;") + elif ('all' and 'functions') in user_query: + speak("i can do all this things:\n ~getting weather info and time;\n ~Can do searches for you;\n ~Can open specific sites-\n {`instagram`\n ,`youtube`,`ChatGPT`\n ,`YT Music`,`Spotify`};\n ~can open apps - \n {Vscode,spotify,python\n ,paint,notepad, edge,\n terminal, brave, notion,\n discord, github desktop,\n cmd,file explorer, telegram,\n opera gx browser, control panel};\n ~ Can remind you to drink water;") + + # engaging in casual converstional + elif 'hi' in user_query or 'Hi' in user_query or 'Hey' in user_query or 'Hello' in user_query or 'hey' in user_query or 'hello' in user_query: + + greets = ['Hi, nice to meet you!', 'oh hi:)', 'Hi master , what are you upto now?', + ] + speak(random.choice(greets)) + + elif 'okay'in user_query or 'ok'in user_query or'OK'in user_query or'Ok'in user_query or'oky'in user_query or'Okyy'in user_query : + responses=['Yeah','Yup','Yes','Nvm:)','Always on your service!'] + speak(random.choice(responses)) + + + elif 'Bye' in user_query or 'bye' in user_query or "take rest" in user_query: + exiting_code= ["Thank you for using me........!",'Thank you for making me a part of your screen time \n now you go and take rest, bye!','i appreciate your interest in me!\n For now im going off as you asked \n Thank you master'] + speak(random.choice(exiting_code)) + exit() + elif 'how are you' in user_query: + replies=["I\'m absolutely fine, wby?","I\'m doing great.\n what about you?", "i\'m great,you?"] + speak(random.choice(replies)) + elif 'im great' in user_query or 'im good' in user_query or 'i doing great' in user_query or 'im fine' in user_query or 'im fine too' in user_query: + replies=["Great king!๐Ÿ‘‘",'Good to hear that','Nice...','Keep moving on then brotherrr!!๐Ÿ“ˆ','feels good to hear that you are okay'] + speak(random.choice(replies)) + elif 'yep' in user_query or'yes' in user_query or'yup' in user_query or'yeah' in user_query: + responses=['great!๐Ÿ‘',"OG๐Ÿ˜ถโ€๐ŸŒซ๏ธ",'okay!','Ok','ok'] + speak(random.choice(responses)) + elif 'close' in user_query: + user_query= user_query.replace("close ",'') + CloseApp(user_query) + elif 'exit' in user_query: + speak("Thankyou for using me...!!") + exit() + else: + speak("Sorry, i didn\'t understand that please repeat:)") + +except Exception as e: + print(e) +# speak("You can continue!") +# e=Exception +# with open(r"errors.txt","w+") as file: +# file.write(e) +# file.close() + +finally: + exit() + # print("\n") + # speak('Sorry for the issue i ran in to a problem \n' + # " if you want to exit type `exit` or press `stop`\n" + # " If you want to give FeedBack type`feedback`\n" + # ) + # show_not = ask() + # if show_not == 'exit': + # speak("Thank you for using me!") + # exit() + # elif show_not == 'feedback': + # speak("you can give your feedback now:)") + # give_feedback = ask() + # if give_feedback != '' or give_feedback == '': + # speak("Thank you for giving your feedback") + # + diff --git a/Translator.py b/Translator.py new file mode 100644 index 0000000..ffbaff6 --- /dev/null +++ b/Translator.py @@ -0,0 +1,13 @@ +from translator import translator + +languages=['fr'] + +text=input("User: Enter your text to translate") +print(f"Bot: I can translate it to {languages}") +# lang=input("into which Language you wanna translate it to?") + + +translator1=translator.Translator(from_lang='en', to_lang=languages) +tranlation=translator1.translate(text) +print(f'{tranlation}') + diff --git a/Voice.py b/Voice.py new file mode 100644 index 0000000..9c65752 --- /dev/null +++ b/Voice.py @@ -0,0 +1,13 @@ +import pyttsx3 +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[1].id) + +# Define function to speak text +def speak(text): + print(f'Bot: {text}') + engine.say(text) + engine.runAndWait() + + +speak("Hello, I am your Personalised AI ChatBot. How may I help you?") \ No newline at end of file diff --git a/WishMe.py b/WishMe.py new file mode 100644 index 0000000..6ca5b5a --- /dev/null +++ b/WishMe.py @@ -0,0 +1,16 @@ + +import time +import datetime +# Define function to speak text +def speak(text): + print(f'Bot: {text}') + + +hour = int(datetime.datetime.now().hour) +if 0 <= hour < 12: + speak("Good Morning!") +elif 12 <= hour < 18: + speak("Good Afternoon!") +else: + speak("Good Evening!") +speak("how may I help you?") \ No newline at end of file diff --git a/WishMe2_voice.py b/WishMe2_voice.py new file mode 100644 index 0000000..9b6f1d3 --- /dev/null +++ b/WishMe2_voice.py @@ -0,0 +1,22 @@ +import pyttsx3 +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[1].id) + + +import time +import datetime +# Define function to speak text +def speak(text): + print(f'Bot: {text}') + engine.say(text) + engine.runAndWait() + +hour = int(datetime.datetime.now().hour) +if 0 <= hour < 12: + speak("Good Morning!") +elif 12 <= hour < 18: + speak("Good Afternoon!") +else: + speak("Good Evening!") +speak("how may I help you?") \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps.py b/apps.py new file mode 100644 index 0000000..9ed54d6 --- /dev/null +++ b/apps.py @@ -0,0 +1,7 @@ +# opera gx brave paint cmd control panel cmd vscode terminal edge notepad spotify +from AppOpener import open + +appp=input("enter app name") +appp.replace(("open "or"close" ),"") +open(appp,output=True,match_closest=True) +# close(appp,output=False) \ No newline at end of file diff --git a/city.list.json.gz b/city.list.json.gz new file mode 100644 index 0000000..990b0a8 Binary files /dev/null and b/city.list.json.gz differ diff --git a/city.list.min.json.gz b/city.list.min.json.gz new file mode 100644 index 0000000..df82da8 Binary files /dev/null and b/city.list.min.json.gz differ diff --git a/clock.ico b/clock.ico new file mode 100644 index 0000000..d35f9e8 Binary files /dev/null and b/clock.ico differ diff --git a/current.city.list.min.json.gz b/current.city.list.min.json.gz new file mode 100644 index 0000000..521c617 Binary files /dev/null and b/current.city.list.min.json.gz differ diff --git a/dir_opener.py b/dir_opener.py new file mode 100644 index 0000000..baf04e0 --- /dev/null +++ b/dir_opener.py @@ -0,0 +1,11 @@ +import os +# # def open_directory(dir_path): +# # if os.path.exists(dir_path): +# # os.open(dir_path,flags=True) +# # else: +# # print("couldnt open") +# # dir_path=r"C:\Users\sahil\Desktop" +# # open_directory(dir_path) +# +cmd="discord" +os.system(cmd) diff --git a/errors.txt b/errors.txt new file mode 100644 index 0000000..e69de29 diff --git a/icon.ico b/icon.ico new file mode 100644 index 0000000..814a753 Binary files /dev/null and b/icon.ico differ diff --git a/infinity.png b/infinity.png new file mode 100644 index 0000000..dfaf614 Binary files /dev/null and b/infinity.png differ diff --git a/jarvis 2 .py b/jarvis 2 .py new file mode 100644 index 0000000..4468e20 --- /dev/null +++ b/jarvis 2 .py @@ -0,0 +1,106 @@ +import speech_recognition as sr # recognise speech +import playsound # to play an audio file +from gtts import gTTS # google text to speech +import random +from time import ctime # get time details +import webbrowser # open browser +import ssl +import certifi +import time +import os # to remove created audio files + +r = sr.Recognizer() # initialise a recogniser +# listen for audio and convert it to text: +def record_audio(ask=False): + with sr.Microphone() as source: # microphone as source + if ask: + speak(ask) + audio = r.listen(source) # listen for the audio via source + voice_data = '' + try: + voice_data = r.recognize_google(audio) # convert audio to text + except sr.UnknownValueError: # error: recognizer does not understand + speak('I did not get that') + except sr.RequestError: + speak('Sorry, the service is down') # error: recognizer is not connected + print(f">> {voice_data.lower()}") # print what user said + return voice_data.lower() + +def respond(voice_data): + speak('How can I help you?') + # 1: greeting + if there_exists(['hey','hi','hello']): + greetings = ["hey, how can I help you ", "hey, what's up?", "I'm listening ", "how can I help you?", "hello "] + greet = greetings[random.randint(0,len(greetings)-1)] + speak(greet) + + # 2: name + if there_exists(["what is your name","what's your name","tell me your name"]): + if person_obj.name: + speak("my name is May day") + else: + speak("my name is May Day. what's your name?") + + if there_exists(["my name is","i am"]): + person_name = voice_data.split("is")[-1].strip() + speak(f"okay, i will remember that {person_name}") + person_obj.setName(person_name) # remember name in person object + + # 3: greeting + if there_exists(["how are you","how are you doing"]): + speak(f"I'm very well, thanks for asking {person_obj.name}") + + # 4: time + if there_exists(["what's the time","tell me the time","what time is it"]): + time = ctime().split(" ")[3].split(":")[0:2] + if time[0] == "00": + hours = '12' + else: + hours = time[0] + minutes = time[1] + time = f'{hours} {minutes}' + speak(time) + + # 5: search google + if there_exists(["search for"]) and 'youtube' not in voice_data: + search_term = voice_data.split("for")[-1] + url = f"https://google.com/search?q={search_term}" + webbrowser.get().open(url) + speak(f'Here is what I found for {search_term} on google') + + # 6: search youtube + if there_exists(["youtube"]): + search_term = voice_data.split("for")[-1] + url = f"https://www.youtube.com/results?search_query={search_term}" + webbrowser.get().open(url) + speak(f'Here is what I found for {search_term} on youtube') + + # 7: get stock price + if there_exists(["price of"]): + search_term = voice_data.lower().split(" of ")[-1].strip() #strip removes whitespace after/before a term in string + stocks = { + "apple":"AAPL", + "microsoft":"MSFT", + "facebook":"FB", + "tesla":"TSLA", + "bitcoin":"BTC-USD" + } + try: + stock = stocks[search_term] + stock = yf.Ticker(stock) + price = stock.info["regularMarketPrice"] + + speak(f'price of {search_term} is {price} {stock.info["currency"]} {person_obj.name}') + except: + speak('oops, something went wrong') + if there_exists(["exit", "quit", "goodbye"]): + speak("going offline") + exit() + + +time.sleep(1) + +person_obj = person() +while(1): + voice_data = record_audio() # get the voice input + respond(voice_data) # respond \ No newline at end of file diff --git a/jarvis 3.py b/jarvis 3.py new file mode 100644 index 0000000..af69ee4 --- /dev/null +++ b/jarvis 3.py @@ -0,0 +1,79 @@ + +from encodings import search_function +import pyttsx3 +import datetime +import speech_recognition as sr +engine=pyttsx3.init() + +voice = engine.getProperty('voices') +newVoiceRate = 200 +engine.setProperty('rate',newVoiceRate) +engine.setProperty('voices', voice[0].id) +def speak(audio): + engine.say(audio) + engine.runAndWait() + +def time(): + Time = datetime.datetime.now().strftime("%I:%M:%S") + speak(Time) + +def date(): + year = int(datetime.datetime.now().year) + month = int(datetime.datetime.now().month) + date = int(datetime.datetime.now().day) + speak("The current date is") + speak(date) + speak(month) + speak(year) + +def wishme(): + speak("you are back sir!!") + hour = datetime.datetime.now().hour + + if hour >= 6 and hour <=12: + speak("Good Morning sir!!") + elif hour >=12 and hour <= 18 : + speak("Good Afternoon sir!!") + elif hour >=18 and hour<= 24: + speak("Good Evening sir!!") + else: + speak("Good Night sir!! have a sweet dream!") + speak("GST sir !! good night , sweet dreams , take care!! bye") + + speak("lucifier at your service! how can i help you my lord?") + +def takeCommand(): + r = sr.Recognizer() + with sr.Microphone() as source: + print("Listening sir!...") + r.pause_threshold = 1 + audio = r.listen(source) + try: + print("Recognizing your command sir!!...") + query = r.recognize_google(audio, "en =US") + print(query) + except Exception as e: + print (e) + speak("Sir please say that again please...") + + return "None" + return query +if __name__ == "__main__": + + wishme() + + while True: + query = takeCommand().lower() + print(query) + + if "time" in query: + time() + elif "date" in query: + date() + elif "quit" in query or "offline" in query or "switch off" in query: + speak("On your command sir!!") + speak("Going offline sir in 3 2 1 good bye sir....") + quit() + + + diff --git a/jarvis.py b/jarvis.py new file mode 100644 index 0000000..1c2a463 --- /dev/null +++ b/jarvis.py @@ -0,0 +1,93 @@ +import pyttsx3 #pip install pyttsx3 +import speech_recognition as sr #pip install speechRecognition +import datetime +import wikipedia #pip install wikipedia +import webbrowser +import os +import smtplib + +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +# print(voices[1].id) +engine.setProperty('voice', voices[1].id) + + +def speak(audio): + engine.say(audio) + engine.runAndWait() + + +def wishMe(): + hour = int(datetime.datetime.now().hour) + if hour>=0 and hour<12: + speak("Good Morning! sahiil channa") + + elif hour>=12 and hour<18: + speak("Good Afternoon!") + + else: + speak("Good Evening! sahiil channa") + + speak("I am your assistant Sir. Please tell me how may I help you") + +def takeCommand(): + #It takes microphone input from the user and returns string output + + r = sr.Recognizer() + with sr.Microphone() as source: + print("Listening...") + r.pause_threshold = 1 + audio = r.listen(source) + + try: + print("Recognizing...") + query = r.recognize_google(audio, language='en-in') + print(f"User said: {query}\n") + + except Exception as e: + # print(e) + print("Say that again please...") + return "None" + return query +if __name__ == "__main__": + wishMe() + while True: + # if 1: + query = takeCommand().lower() + + # Logic for executing tasks based on query + if 'wikipedia' in query: + speak('Searching Wikipedia...') + query = query.replace("wikipedia", "") + results = wikipedia.summary(query, sentences=2) + speak("According to Wikipedia") + print(results) + speak(results) + + elif 'open youtube' in query: + speak("Opening youtube...") + webbrowser.open("youtube.com") + + elif 'open google' in query: + speak("Opening google...") + webbrowser.open("google.com") + + elif 'open stackoverflow' in query: + speak("Opening stackoverflow...") + webbrowser.open("stackoverflow.com") + + + elif 'play music' in query: + speak('Playing music...') + webbrowser.open("music.youtube.com") + + elif 'the time' in query: + strTime = datetime.datetime.now().strftime("%H:%M:%S") + speak(f"Sir, the time is {strTime}") + + elif 'open code' in query: + codePath = "C:\\Users\\sahil\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe" + os.startfile(codePath) + elif 'quit' in query or ' exit' in query: + speak("Ok, I am going to take a nap...") + exit() diff --git a/jarvis.py errors.pdf b/jarvis.py errors.pdf new file mode 100644 index 0000000..ee21ef2 Binary files /dev/null and b/jarvis.py errors.pdf differ diff --git a/jarvis{Txt_ver_errors}.txt b/jarvis{Txt_ver_errors}.txt new file mode 100644 index 0000000..53b8330 --- /dev/null +++ b/jarvis{Txt_ver_errors}.txt @@ -0,0 +1,2 @@ + + argument of type 'NoneType' is not iterable \ No newline at end of file diff --git a/path.py b/path.py new file mode 100644 index 0000000..079c551 --- /dev/null +++ b/path.py @@ -0,0 +1,8 @@ +import os +say=input("Enter your path ") +if 'open' in say: + ispath=say.removeprefix("open ") + os.chdir() + ispath_check=os.path.exists(ispath) + print(ispath, + ispath_check) \ No newline at end of file diff --git a/pexels-photo-8728168.webp b/pexels-photo-8728168.webp new file mode 100644 index 0000000..ee20561 Binary files /dev/null and b/pexels-photo-8728168.webp differ diff --git a/test_Personalised AI ChatBot.py b/test_Personalised AI ChatBot.py new file mode 100644 index 0000000..55eb72b --- /dev/null +++ b/test_Personalised AI ChatBot.py @@ -0,0 +1,6 @@ +from unittest import TestCase + + +class Test(TestCase): + def test_sites(self): + self.fail() diff --git a/trial_cli.py b/trial_cli.py new file mode 100644 index 0000000..37f06d4 --- /dev/null +++ b/trial_cli.py @@ -0,0 +1,24 @@ +# import sys +# import os +# +# print (' line 1e to stderr ', file=sys.stderr) +# sys.stderr.write(' line 2e to stderr \n') ; sys.stderr.flush() +# os.write(2, b' line 3e to stderr \n') + +import argparse + +def process_input(input_value): + # Your code to process the input and produce results + return f"Processed: {input_value}" + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Your program description") + parser.add_argument("input", help="Input for your program") + + args = parser.parse_args() + + input_value = args.input + result = process_input(input_value) + + # Print the result to the console + print(result) diff --git a/veve.py b/veve.py new file mode 100644 index 0000000..e5a021d --- /dev/null +++ b/veve.py @@ -0,0 +1,75 @@ +# all our imports +import speech_recognition as sr +from time import sleep +from datetime import datetime +import webbrowser +import pyttsx3 +# make an instance of Recognizer class +r = sr.Recognizer() +# confs for pyttsx3 +engine = pyttsx3.init() +""" speak (text to speech) """ +def speak(text): + engine.say(text) + engine.runAndWait() +""" fn to recognize our voice and return the text_version of it""" +def recognize_voice(): + text = '' + # create an instance of the Microphone class + with sr.Microphone() as source: + # adjust for ambient noise + r.adjust_for_ambient_noise(source) + # capture the voice + voice = r.listen(source) + # let's recognize it + try: + text = r.recognize_google(voice) + except sr.RequestError: + speak("Sorry, the I can't access the Google API...") + except sr.UnknownValueError: + speak("Sorry, Unable to recognize your speech...") + return text.lower() +""" fn to respond back """ +def reply(text_version): + # name + if "name" in text_version: + speak("My name is Friday!") + + # how are you? + if "how are you" in text_version: + speak("I am fine sir , thank you...") + # date + if "date" in text_version: + # get today's date and format it - 9 November 2020 + date = datetime.now().strftime("%-d %B %Y") + speak(date) + # time + if "time" in text_version: + # get current time and format it like - 02 28 + time = datetime.now().time().strftime("%H %M") + speak("The time is " + time) + + # search google + if "search" in text_version: + speak("What do you want me to search for?") + keyword = recognize_voice() + # if "keyword" is not empty + if keyword != '': + url = "https://google.com/search?q=" + keyword + # webbrowser module to work with the webbrowser + speak("Here are the search results for " + keyword) + webbrowser.open(url) + sleep(3) + + # quit/exit + if "quit" in text_version or "exit" in text_version: + speak("Ok, I am going to take a nap...") + exit() +# wait a second for adjust_for_ambient_noise() to do its thing +sleep(1) +while True: + speak("Yes sir i'm on and ready to take commands!...") + # listen for voice and convert it into text format + text_version = recognize_voice() + # give "text_version" to reply() fn + reply(text_version) \ No newline at end of file diff --git a/voice-to-voice chatbot.py b/voice-to-voice chatbot.py new file mode 100644 index 0000000..146d66e --- /dev/null +++ b/voice-to-voice chatbot.py @@ -0,0 +1,117 @@ +import speech_recognition as sr +import pyttsx3 +import datetime +import wikipedia +import webbrowser +import os +import smtplib +import AppOpener +import ctypes +import logging +# Initialize text-to-speech engine +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +engine.setProperty('voice', voices[0].id) +engine.setProperty('rate',130) +# Define function to speak text +def speak(text): + engine.say(text) + engine.runAndWait() + print(f'Bot: {text}') + +# Define function to recognize speech +def recognize_speech(): + r = sr.Recognizer() + with sr.Microphone() as source: + print("Bot: Listening...") + r.pause_threshold = 1 + r.adjust_for_ambient_noise(source, duration=5) # Adjust for ambient noise + audio = r.listen(source, timeout=5) # Listen for up to 5 seconds + try: + print("Bot: Recognizing...") + query = r.recognize_google(audio, language='hi-in') + print(f"User said: {query}\n") + except sr.UnknownValueError: + + + print("Bot: Could not understand audio") + return "None" + except sr.RequestError as e: + print(f"Bot: Could not request results from Google Speech Recognition; {e}") + return "None" + return query +# Define function to wish user +def wish_me(): + hour = int(datetime.datetime.now().hour) + if hour>=0 and hour<12: + speak("Good Morning! sir") + elif hour>=12 and hour<18: + speak("Good Afternoon! sir") + else: + speak("Good Evening! sir") + speak("I am your P.A A.I powered. How may I help you?") + +# Main program +if __name__ == "__main__": + wish_me() + while True: + logging.info("A.I is listening") + query = recognize_speech().lower() + if 'wikipedia' in query: + speak('Searching Wikipedia...') + query = query.replace("wikipedia", "") + results = wikipedia.summary(query, sentences=2) + speak("According to Wikipedia") + print(results) + speak(results) + elif 'open youtube' in query: + webbrowser.open("youtube.com") + elif 'open google' in query: + webbrowser.open("google.com") + elif 'play music' in query: + music_dir = 'C:\\Music' + songs = os.listdir(music_dir) + os.startfile(os.path.join(music_dir, songs[0])) + elif 'time' in query: + strTime = datetime.datetime.now().strftime("%H:%M") + speak(f"The time is {strTime}") + elif 'search in wikipedia' in query: + speak('Searching Wikipedia...') + query = query.replace("search in wikipedia", "") + results = wikipedia.summary(query, sentences=2) + speak("According to Wikipedia") + speak(results) + elif 'spell' in query: + speak("Please spell the word") + word = recognize_speech().lower() + speak(word) + elif 'quit' in query : + speak("Goodbye!") + exit() + elif 'exit' in query or 'stop' in query : + + speak("Goodbye!") + exit() + elif 'bye' in query or 'mar ja' in query: + speak("Goodbye!") + exit() + elif 'close 'in query: + speak("Closing app") + AppOpener.close((query.replace("close ", "")),match_closest=True,output=False) + elif 'open 'in query: + speak("Opening app") + AppOpener.open((query.replace("open ", "")),match_closest=True,output=False) + elif 'switch 'in query: + speak("Switching app") + AppOpener.switch((query.replace("switch ", "")),match_closest=True,output=False) + elif 'minimize 'in query: + speak("Minimizing app") + AppOpener.minimize((query.replace("minimize ", "")),match_closest=True,output=False) + elif 'speak' in query: + query = query.replace("speak", "") + speak(query) + elif 'what is your name' in query: + speak("My name is Jarvis") + + + diff --git a/voices.py b/voices.py new file mode 100644 index 0000000..eab6dd4 --- /dev/null +++ b/voices.py @@ -0,0 +1,17 @@ +import pyttsx3 +engine = pyttsx3.init() + +# Voice IDs pulled from engine.getProperty('voices') +# These will be system specific +en_voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\WOW432Node\Microsoft\Speech\Voices\Tokens\MSTTS_V110_enIN_HeeraM" +ru_voice_id = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_RU-RU_IRINA_11.0" + +# Use female English voice +engine.setProperty('voice', en_voice_id) +engine.say('Hello with my new voice') + +# Use female Russian voice +engine.setProperty('voice', ru_voice_id) +engine.say('ะŸั€ะธะฒะตั‚. ะณะดะต ั…ะฐะบะตั€') + +engine.runAndWait() \ No newline at end of file diff --git a/water_notification.py b/water_notification.py new file mode 100644 index 0000000..8f14623 --- /dev/null +++ b/water_notification.py @@ -0,0 +1,22 @@ +import time +from winotify import Notification, audio + +def Drink_Water(): + toast = Notification(app_id="Lucifier", + title='drink water', + msg="Drink WATer", + duration="long", + icon=r'D:\Languages\PYTHON\python programs\Jarvis\Jarvis {Text_Version_1,0}\icon.ico') + + toast.set_audio(audio.SMS, loop=False) + toast.show() + + +if __name__ =='__main__': + + while True: + current_time = time.strftime("%I:%M %p") + + if current_time.endswith(":00 AM") or current_time.endswith(":00 PM"): + Drink_Water() +# Drink_Water() \ No newline at end of file diff --git a/weather.py b/weather.py new file mode 100644 index 0000000..abbf54e --- /dev/null +++ b/weather.py @@ -0,0 +1,3 @@ +import webbrowser +cmd=input("weather?") +webbrowser.open(f'weather {cmd}') \ No newline at end of file diff --git a/windows_notifier.py b/windows_notifier.py new file mode 100644 index 0000000..701b1cd --- /dev/null +++ b/windows_notifier.py @@ -0,0 +1,15 @@ +# from win10toast import ToastNotifier +# +# notifier= ToastNotifier() +# +# notifier.show_toast("Hii","Hey",duration=4) +import time +from winotify import Notification, audio +toast = Notification(app_id="Lucifier", + title='drink water', + msg="Drink WATer", + duration="short", + icon=r'D:\Languages\PYTHON\python programs\Jarvis\Jarvis {Text_Version_1,0}\icon.ico') + +toast.set_audio(audio.LoopingCall, loop=False) +toast.show() \ No newline at end of file