-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfriday.py
216 lines (185 loc) · 8.49 KB
/
friday.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# Import required libraries
import pyttsx3 as tts # Text-to-speech conversion library
import datetime # For date and time operations
import wikipedia # For fetching Wikipedia information
import webbrowser # For opening websites
import os # For system operations
import random # For random operations
import time # For time-related operations
import pyjokes # For generating random jokes
import pywhatkit as kit # For YouTube and WhatsApp operations
import pyautogui as pg # For GUI automation
import numpy as np # For numerical operations
import subprocess # For running system commands
def start():
# Initialize text-to-speech engine
engine = tts.init()
# Configure speech rate
rate = engine.getProperty('rate')
engine.setProperty('rate', 150) # Sets speed of speech
# Configure voice
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id) # Sets default voice
# Greet the user
greet= '''
███████╗██████╗ ██╗██████╗ █████╗ ██╗ ██╗
██╔════╝██╔══██╗██║██╔══██╗██╔══██╗╚██╗ ██╔╝
█████╗ ██████╔╝██║██║ ██║███████║ ╚████╔╝
██╔══╝ ██╔══██╗██║██║ ██║██╔══██║ ╚██╔╝
██║ ██║ ██║██║██████╔╝██║ ██║ ██║
╚═╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝
'''
print(greet)
# Initial greeting
engine.say("Hello, I am Friday your personal assistant")
engine.runAndWait()
# Main loop for continuous interaction
while True:
# Get user input
query = input("You: ")
# Basic greeting responses
if "hi" in query.lower() or "hello" in query.lower():
engine.say("How can I help you?")
engine.runAndWait()
# Joke feature
elif "joke" in query.lower():
jokes = pyjokes.get_joke()
print(jokes)
engine.say(jokes)
engine.runAndWait()
# Date information
elif "date" in query.lower():
today = datetime.date.today()
date_string = today.strftime("%B %d, %Y")
print(date_string)
engine.say(f"The date is {date_string}")
engine.runAndWait()
# Time information
elif "time" in query.lower():
time = datetime.datetime.now().strftime("%H:%M:%S")
print(time)
engine.say(f"The time is {time}")
engine.runAndWait()
# Wikipedia search
elif "wikipedia" in query.lower():
query = query.replace("wikipedia", "").strip()
try:
result = wikipedia.summary(query, sentences=2)
print(result)
engine.say(result)
engine.runAndWait()
except wikipedia.exceptions.PageError:
print(f"No Wikipedia page found for '{query}'")
# Browser operations - Google Chrome
elif "open google" in query.lower():
os.system("start Chrome")
engine.say("Opening Google")
engine.runAndWait()
# Browser operations - Brave
elif "open brave" in query.lower():
os.system("start Brave")
engine.say("Opening Brave")
engine.runAndWait()
# Website operations - YouTube
elif "open youtube" in query.lower():
webbrowser.open("https://www.youtube.com")
engine.say("Opening Youtube")
engine.runAndWait()
# Website operations - Stack Overflow
elif "open stackoverflow" in query.lower():
webbrowser.open("https://www.stackoverflow.com")
engine.say("Opening stackoverflow")
engine.runAndWait()
# YouTube video playback
elif "play" in query.lower():
query = query.replace("play", "").strip()
kit.playonyt(query)
engine.say(f"Playing {query} on YouTube")
engine.runAndWait()
# Social media - Snapchat
elif "open snap" in query.lower():
webbrowser.open("https://www.snapchat.com")
engine.say("Opening Snapchat")
engine.runAndWait()
# Social media - Instagram
elif "open insta" in query.lower():
webbrowser.open_new("https://www.instagram.com")
engine.say("Opening Instagram")
engine.runAndWait()
# Communication platform - Discord
elif "open discord" in query.lower():
webbrowser.open("https://www.discord.com")
engine.say("Opening Discord")
engine.runAndWait()
# Video conferencing - Zoom
elif "open zoom" in query.lower():
webbrowser.open("https://www.zoom.us")
engine.say("Opening Zoom")
engine.runAndWait()
# Video conferencing - Google Meet
elif "open meet" in query.lower():
webbrowser.open("https://www.meet.google.com")
engine.say("Opening Google Meet")
engine.runAndWait()
# Communication platform - Microsoft Teams
elif "open teams" in query.lower():
webbrowser.open("https://www.microsoft.com/en-us/microsoft-365/microsoft-teams/group-chat-software")
engine.say("Opening Microsoft Teams")
engine.runAndWait()
# Messaging - WhatsApp Desktop
elif "open whatsapp" in query.lower():
try:
# Launch WhatsApp using PowerShell command
subprocess.run(["powershell", "-Command", "Start-Process -FilePath 'whatsapp:'"], check=True)
engine.say("Opening Whatsapp Desktop")
engine.runAndWait()
continue
except subprocess.CalledProcessError as e:
print(f"Error launching WhatsApp Desktop: {e}")
return False
continue
# Email - Gmail
elif "open mail" in query.lower():
webbrowser.open("https://mail.google.com/mail/u/0/#inbox")
engine.say("Opening Gmail")
engine.runAndWait()
# WhatsApp messaging
elif "mssg" in query.lower():
query = query.replace("mssg", "").strip()
# Send WhatsApp message (replace with actual phone number)
kit.sendwhatmsg("+910000000000", "Hello i am friday", 15, 3)
time.sleep(10)
engine.say(f"Message sent to {query}")
engine.runAndWait()
# Calculator functionality
elif "calculate" in query.lower():
query = query.replace("calculate", "").strip()
result = eval(query)
print(result)
engine.say(f"The result of {query} is {result}")
engine.runAndWait()
# Web search
elif "search" in query.lower():
query = query.replace("search", "").strip()
kit.search(query)
engine.say(f"Searching for {query}")
engine.runAndWait()
# Thank you response
elif "thank you" in query.lower():
engine.say("You are welcome")
engine.say("I am always here to help you")
engine.runAndWait()
# Exit commands
elif "exit" in query.lower() or "bye" in query.lower():
engine.say("Goodbye")
engine.runAndWait()
os.system("taskkill /f /im Code.exe")
break
# Default response for unrecognized commands
else:
engine.say("I am sorry, I did not understand")
engine.runAndWait()
continue
# Main execution
if __name__ == "__main__":
start()