Skip to content

Commit

Permalink
new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesaini047 committed Mar 19, 2024
1 parent 5afa274 commit e750522
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 182 deletions.
Binary file added __pycache__/chatgpt.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/s_functions.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/voice_work.cpython-310.pyc
Binary file not shown.
32 changes: 0 additions & 32 deletions chatgpt.py

This file was deleted.

Binary file removed images/ a dog.jpg
Binary file not shown.
131 changes: 23 additions & 108 deletions loki.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,20 @@
from inspect import _void
import re
import s_functions
import chatgpt
import s_functions as sf
import voice_work
import wikipedia # pip install wikipedia
import webbrowser
import os
import datetime
import requests
import random
# import pywhatkit
import BeautifulSoup


from bs4 import BeautifulSoup

voice_p = voice_work.voice()
chat = chatgpt.Chatgpt()

#other functions

def searchGoogle(query):
if "google" in query:
import wikipedia as googleScrap
query = query.replace("jarvis","")
query = query.replace("google search","")
query = query.replace("google","")
voice_p.speak("This is what I found on google")

try:
# pywhatkit.search(query)
result = googleScrap.summary(query,1)
voice_p.speak(result)

except:
voice_p.speak("No speakable output available")

def searchYoutube(query):
if "youtube" in query:
voice_p.speak("This is what I found for your search!")
query = query.replace("youtube search","")
query = query.replace("youtube","")
query = query.replace("jarvis","")
web = "https://www.youtube.com/results?search_query=" + query
webbrowser.open(web)
# pywhatkit.playonyt(query)
voice_p.speak("Done, Sir")

def searchWikipedia(query):
if "wikipedia" in query:
voice_p.speak("Searching from wikipedia....")
query = query.replace("wikipedia","")
query = query.replace("search wikipedia","")
query = query.replace("jarvis","")
results = wikipedia.summary(query,sentences = 2)
voice_p.speak("According to wikipedia..")
print(results)
voice_p.speak(results)

def commands(command_user):
prompt_text = str(command_user)
# Logic for executing tasks based on command_user
if 'wikipedia' in command_user:
voice_p.speak('Searching Wikipedia...')
command_user = command_user.replace("wikipedia", "")
results = wikipedia.summary(command_user, sentences=2)
voice_p.speak("According to Wikipedia")
return results

elif 'open youtube' in command_user:
if 'open youtube' in command_user:
webbrowser.open("youtube.com")

elif 'open google' in command_user:
Expand All @@ -85,6 +32,15 @@ def commands(command_user):
elif 'open whatsapp' in command_user:
webbrowser.open("whatsapp.com")

elif "google" in command_user:
sf.searchGoogle(command_user)

elif "youtube" in command_user:
sf.searchYoutube(command_user)

elif "wikipedia" in command_user:
sf.searchWikipedia(command_user)

elif 'play music' in command_user:
music_dir = 'C:\\Users\\Lenovo\\Music'
songs = os.listdir(music_dir)
Expand All @@ -95,7 +51,7 @@ def commands(command_user):
strTime = datetime.datetime.now().strftime("%H:%M:%S")
return (f"Sir, the time is {strTime}")

elif 'open code' in command_user:
elif 'open vs code' in command_user:
codePath = "C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
os.startfile(codePath)

Expand All @@ -106,70 +62,29 @@ def commands(command_user):
except AttributeError:
length = 8

password = s_functions.passwordgenerator(int(length))
password = sf.passwordgenerator(int(length))
return (f"Your password is {str(password)}")

elif 'bye' in command_user or 'stop' in command_user or 'exit' in command_user:
voice_p.printandspeak("Bye Sir, have a good day.")
exit()

elif "google" in command_user:
searchGoogle(command_user)

elif "youtube" in command_user:
searchYoutube(command_user)

elif "wikipedia" in command_user:
searchWikipedia(command_user)

elif "temperature" in command_user:
search = "temperature in delhi"
search = "temperature in jaipur"
url = f"https://www.google.com/search?q={search}"
r = requests.get(url)
data = BeautifulSoup(r.text,"html.parser")
temp = data.find("div", class_ = "BNeawe").text
voice_p.speak(f"current{search} is {temp}")
elif "weather" in query:
search = "temperature in delhi"

elif "weather" in command_user:
search = "temperature in jaipur"
url = f"https://www.google.com/search?q={search}"
r = requests.get(url)
data = BeautifulSoup(r.text,"html.parser")
temp = data.find("div", class_ = "BNeawe").text
voice_p.speak(f"current{search} is {temp}")
# elif 'generate image' in command_user:

# response = chat.generate_image(prompt_text=prompt_text)
# for image in response['data']:
# # print(image['url'])
# img_data = requests.get(image['url']).content
# command_user = command_user.replace("generate image", "")
# if 'of' in command_user:
# command_user = command_user.replace("of", "")
# # os.chdir('images')1
# os.chdir("images")
# fname = os.path.join(os.getcwd(), str(command_user)+'.jpg')
# with open(fname, 'wb') as handler:
# handler.write(img_data)
# os.chdir("..")
# return "Image generated"

# elif 'write code' in command_user or 'write a code' in command_user or 'write program' in command_user:
# response = chat.write_code(prompt_text=prompt_text)

# for choice in response['choices']:
# print(choice['text'])
# return"Here is code"

# else:
# response = chat.text_out(prompt_text=prompt_text)

# for choice in response['choices']:
# voice_p.printandspeak(choice['text'])
# # s_functions.intotxtfile(prompt_text, choice['text'])
# if choice['text'].find('?') != -1:
# commander()
# else:
# pass

elif 'bye' in command_user or 'stop' in command_user or 'exit' in command_user:
voice_p.printandspeak("Bye Sir, have a good day.")
exit()

else :
voice_p.printandspeak("command not found")

Expand Down
Binary file modified requirements.txt
Binary file not shown.
85 changes: 43 additions & 42 deletions s_functions.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@

import random


# normal maths
import string


def addition(a, b):
c = a + b
return c


def subtract(a, b):
c = a - b
return c


def area_of_circle(radius):
"""This function will calculate area of circle . when you enter radius .
This function will calculate automatically area of circle and give you answer."""

area = 3.14159 * radius * radius
return area


def perimeter_of_circle(radius):
"""This function will calculate perimeter of circle . when you enter radius .
This function will calculate automatically perimeter of circle and give you answer."""

perimeter = 2 * 3.14159 * radius
return perimeter


def factorial(n):
"""This function is used to calculate factorial for you. In class 11 and 12 this operation used .
This function is very useful for students. symbol used in maths for this function is !."""

a = 1
b = 1
while a <= n:
b *= n
n -= 1
return b
import voice_work
import pywhatkit
import webbrowser
import wikipedia

voice_p = voice_work.voice()
def searchGoogle(query):
if "google" in query:
import wikipedia as googleScrap
query = query.replace("jarvis","")
query = query.replace("google search","")
query = query.replace("google","")
voice_p.speak("This is what I found on google")

try:
pywhatkit.search(query)
result = googleScrap.summary(query,1)
voice_p.speak(result)

except:
voice_p.speak("No speakable output available")

def searchYoutube(query):
if "youtube" in query:
voice_p.speak("This is what I found for your search!")
query = query.replace("youtube search","")
query = query.replace("youtube","")
query = query.replace("jarvis","")
web = "https://www.youtube.com/results?search_query=" + query
webbrowser.open(web)
pywhatkit.playonyt(query)
voice_p.speak("Done, Sir")

def searchWikipedia(query):
if "wikipedia" in query:
voice_p.speak("Searching from wikipedia....")
query = query.replace("wikipedia","")
query = query.replace("search wikipedia","")
query = query.replace("jarvis","")
results = wikipedia.summary(query,sentences = 2)
voice_p.speak("According to wikipedia..")
print(results)
voice_p.speak(results)

# password_generator

Expand Down

0 comments on commit e750522

Please sign in to comment.