Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 60f9735

Browse files
Merge pull request avinashkranjan#766 from sayantani11/desktop_assistant
Desktop Voice Assistant
2 parents 5149e7f + b7c2aea commit 60f9735

File tree

3 files changed

+208
-0
lines changed

3 files changed

+208
-0
lines changed

‎Desktop-Voice-assistant/READme.md‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# DESKTOP VOICE ASSISTANT
2+
It would be great to have a desktop voice assistant who could perform tasks like sending email, playing music, search wikipedia on its own when we ask it to. This desktop assistant does exactly that for the user.
3+
4+
5+
# What tasks can it perform?
6+
1. It can send emails on your behalf.
7+
2. It can search wikipedia and read the first few lines for you.
8+
3. It can open youtube, google, facebook and spotify.
9+
4. Send messages in whatsapp on your behalf.
10+
5. Tell you jokes.
11+
6. Tell date and time for you.
12+
7. Open apps on your device.
13+
14+
15+
# How to use
16+
1. Start the assistant.
17+
2. Keep giving the required commands
18+
3. If done say 'no thanks' and the assistant will stop itself
19+
20+
21+
# Side note
22+
Make sure you set Master as your name. (line 21)
23+
Enter the email and app password. (line 63)
24+
You need to be logged into whatsapp for using the assistant to send whatsapp messages. (While using 'Send Whatsapp message' option
25+
26+
27+
# Additional features:
28+
You can use it to open apps on your device like word, one note, notepad, VS code etc.
29+
The path will vary from user to user.
30+
Here is the code you can use:
31+
32+
import os
33+
elif 'Open <App name>' in query:
34+
path= "Location of the application"
35+
os.startfile(path)
36+
37+
38+
# For using the mailSent function:
39+
Here for making the sent Email function work, there are certain changes that should be made in respective device or else the function won't work and a error will pop up
40+
For the function to work:
41+
1. In google search "Less secured apps in gmail"
42+
2. Select "Control access to less secure apps"
43+
3. Here enable the less secure apps for the account you will be using to send emails
44+
Now its a concern of security if we have to write our password this way
45+
for no privacy breach we can use the following steps:
46+
1. Go to goole and search "App passwords google"
47+
2. Open "App passwords-Sign in Google"
48+
3. Sign in the with the account you want to use for sending emails using this
49+
4.Under "select the app and device you want generate password for"
50+
i> Select App= Mail Select Device= Windows 10
51+
ii>Click on generate
52+
5. Copy the app password and use it here.
53+
54+
55+
# Development Status
56+
The amount of things that can be done with this AI assistant is endless. This is just a basic structure which is at present complete. It might be using hotwords in future that will trigger the assistant, , might be used in sending the system to sleep mode, set alarm, send text messages to contacts on your phone and lot more.
57+
58+
59+
# Developed by Sayantani Saha
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pyttsx3
2+
datetime
3+
speech_recognition
4+
pyaudio
5+
wikipedia
6+
webbrowser
7+
smtplib
8+
pywhatkit
9+
pyjokes
10+
time
11+
sys
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import pyttsx3
2+
import datetime
3+
import speech_recognition as sr
4+
import pyaudio
5+
import wikipedia
6+
import webbrowser
7+
import smtplib
8+
import pywhatkit as kit
9+
import pyjokes
10+
import time
11+
import sys
12+
13+
print("Your Assistant is starting......")
14+
15+
engine = pyttsx3.init('sapi5')
16+
voices= engine.getProperty('voices')
17+
engine.setProperty('voice', voices[1].id)
18+
engine.setProperty('rate', 190)
19+
20+
Master=input("Enter your name: ") # when you start using the assistant enter your name here
21+
22+
def speak(audio):
23+
engine.say(audio)
24+
engine.runAndWait()
25+
26+
def wish_user():
27+
hour= int(datetime.datetime.now().hour)
28+
if hour>=0 and hour<12:
29+
speak("Good Morning!" + Master)
30+
31+
elif hour>=12 and hour<16:
32+
speak("Good Afternoon!" + Master)
33+
34+
else:
35+
speak("Good Evening" + Master)
36+
37+
speak("I am your Desktop-Assistant! How may I help you?")
38+
39+
def user_command():
40+
# takes microphone command and converts to string
41+
42+
r= sr.Recognizer()
43+
with sr.Microphone() as source:
44+
print("I am listening....")
45+
r.pause_threshold=1
46+
audio=r.listen(source)
47+
48+
try:
49+
print("Recognising.....")
50+
query=r.recognize_google(audio,language='en-in')
51+
print(f"User said: {query}\n")
52+
53+
except Exception as e:
54+
print("I am sorry I don't understand, Say that again please...")
55+
return "None"
56+
return query
57+
58+
def mailSent(to, content):
59+
server=smtplib.SMTP('smtp.gmail.com', 587)
60+
server.ehlo()
61+
server.starttls()
62+
server.login('your email', 'your app password') # when you start working with the assistant, save this on your device
63+
#check READme.md for creating an app password
64+
server.sendmail('Your email',to,content)
65+
66+
server.close()
67+
68+
if __name__=='__main__':
69+
70+
wish_user()
71+
while True:
72+
query= user_command().lower()
73+
74+
if 'wikipedia' in query:
75+
speak('Give me sometime I am looking into Wikipedia')
76+
query= query.replace("wikipedia","")
77+
results= wikipedia.summary(query, sentences=5)
78+
speak("This is what I found!")
79+
speak(results)
80+
81+
elif 'open youtube' in query:
82+
webbrowser.open("youtube.com")
83+
84+
elif 'search google' in query:
85+
webbrowser.open("google.com")
86+
87+
elif 'play music' in query:
88+
webbrowser.open("spotify.com")
89+
# you can use API as well, with the help of spotipy module
90+
91+
elif 'time' in query:
92+
time= datetime.datetime.now().strftime("%H:%M")
93+
speak(f"Its {time} now")
94+
95+
elif 'date today' in query:
96+
date=datetime.datetime.today()
97+
speak(f"Today is {date}")
98+
99+
elif 'send email' in query:
100+
try:
101+
speak("please tell me the content of the email")
102+
content=user_command()
103+
speak(content)
104+
to=input()
105+
speak(to)
106+
mailSent(to, content)
107+
speak(f"successfully sent the email to {to}")
108+
except Exception as e:
109+
print(e)
110+
speak("sorry! i was unable to send the mail")
111+
112+
elif 'send whatsapp message' in query: #you should be logged in into whatsapp web for this
113+
speak("To whom should I send the message?")
114+
number=int(input())
115+
speak("Tell me the message please")
116+
message=user_command()
117+
speak("At what time should I send?")
118+
speak("At what time? (24 hours system)")
119+
hr=int(input("Hours: "))
120+
mins=int(input("Minutes: "))
121+
kit.sendwhatmsg(number,message,hr,mins)
122+
# this should be in the format ("+91xxxxxxxxxx","This is message", 15, 20)
123+
124+
elif 'open facebook' in query:
125+
webbrowser.open("facebook.com")
126+
127+
elif 'make me laugh' in query:
128+
joke=pyjokes.get_joke()
129+
speak(joke)
130+
131+
elif 'no thanks' in query:
132+
speak("thanks for using me! Have a good day")
133+
sys.exit()
134+
135+
time.sleep(5)
136+
speak("do you have any other work?")
137+
138+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /