-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.py
108 lines (81 loc) · 3.24 KB
/
command.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
import pip
import os
import pyttsx3
engine = pyttsx3.init()
engine.say("Hello there..how are you..")
engine.say("Please tell me your name by typing ")
engine.runAndWait()
user = input("Please Enter Your name : ")
engine.say(f"Hello {user}")
engine.runAndWait()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.say("If you are a boy then simply type b and for girl please type g")
engine.runAndWait()
gender = input(str("please write here b for boy or g for girl : "))
if( gender == "B" or gender =="b"):
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
engine = pyttsx3.init()
engine.say("Thank you you are ready to go..")
engine.runAndWait()
engine.stop()
elif( gender =="F" or gender =="f"):
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine = pyttsx3.init()
engine.say("Thank you you are ready to go..")
engine.runAndWait()
engine.stop()
else:
engine = pyttsx3.init()
engine.say("please enter a character g or b according to your gender")
engine.runAndWait()
engine.stop()
os.system("color 0e")
# this funcction checks for the dependencies for running this program
def install(package):
os.system("color 5f")
engine = pyttsx3.init()
engine.say("let me check the voice dependencies before continuing")
engine.runAndWait()
if hasattr(pip, 'main'):
engine.say("I am installing the dependencies")
pip.main(['install', package])
else:
pip._internal.main(['install', package])
engine.say("I am done now, it is ready now")
engine.say("All dependencies are update and working")
engine.runAndWait()
engine.say("This is a Modern command line Interface created by Anand Prabhakar")
engine.runAndWait()
print("==========================================================================")
print("\n||\tCommand Line Interface CLI 1.0 By Anand Prabhakar, Nalanda, Bihar,India\t||\n||\tPowered by Python. \t\t\t\t\t\t||\n||\tjust learning..no commercial use.. \t\t\t\t||\n")
print("==========================================================================")
def main():
engine = pyttsx3.init()
engine.say("Please Enter the command you want to run")
engine.runAndWait()
#it takes commands as input
command = input("\n\tEnter the command you want to execute : ")
print("Output after execution : \n")
print("============================================================")
#it runs the command and show output
commanding(command)
print("============================================================")
def commanding(i):
os.system("color 0e")
engine = pyttsx3.init()
engine.say("You have entered the following command")
engine.say(i)
engine.runAndWait()
a = os.system(i)
engine.say("Here is output for the command you entered")
engine.runAndWait()
print("\n\t\tDo you want to Enter Command again\n")
print("-------------------------------------------------------------")
main()
return a
if __name__ == "__main__":
install('pyttsx3')
main()