File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ # Shutdown your pc using voice command using python
2+
3+ ## Introduction
4+ If your far from your pc and you want to shutdown your pc, you can automate it by your voice command using this program.
5+
6+ ## How to install library
7+ pip install pywin32
8+ pip install SpeechRecognition
9+
10+ ## How to use
11+ 1 . You has to install all the library mentioned above.
12+ 2 . Run this programme in your command prompt or any terminal.
13+ 3 . Specify "Shutdown" keyword when you want to shutdown your pc.
14+ 4 . It will ask confirmation from you.
15+ 5 . Say "Yes".
16+ 6 . It will shoutdown your pc in 3 second.
Original file line number Diff line number Diff line change 1+ from win32com .client import Dispatch
2+ import speech_recognition as sr
3+ import os
4+ import time
5+
6+
7+ def speak (audio ):
8+ speak = Dispatch (("sapi.spvoice" ))
9+ speak .speak (audio )
10+
11+
12+ speak ("Hello, I am your personal assistant" )
13+
14+
15+ def TakeCommand ():
16+ r = sr .Recognizer ()
17+ with sr .Microphone () as source :
18+ print ("Listening..." )
19+ r .pause_threshold = 1
20+ r .adjust_for_ambient_noise (source , duration = 1 )
21+ audio = r .listen (source )
22+ try :
23+ print ("Recognizing..." )
24+ Query = r .recognize_google (audio , language = 'en-in' )
25+
26+ except Exception :
27+ speak ("Say that again please" )
28+ return "None"
29+ return Query
30+
31+
32+ while (True ):
33+ if __name__ == '__main__' :
34+ Query = TakeCommand ().lower ()
35+
36+ if "shut down" or "shutdown" in Query :
37+ speak ("Do you want to shutdown your pc " )
38+ Query2 = TakeCommand ().lower ()
39+
40+ if "yes" in Query2 :
41+ speak ("ok shutdowning..." )
42+ time .sleep (3 )
43+ os .system ("shutdown /s /t 0" )
44+ elif "no" in Query2 :
45+ speak ("Ok" )
You can’t perform that action at this time.
0 commit comments