-
Notifications
You must be signed in to change notification settings - Fork 0
/
pixi_new.py
179 lines (149 loc) · 6.71 KB
/
pixi_new.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
import speech_recognition as sr
import pyttsx3
import datetime
import pywhatkit
import wikipedia
import cv2
import pyaudio
import random
import threading
import datetime
import pyjokes
from threading import Thread, Lock
import runpy
import subprocess
import sys
import os
welcome = ['Hello Boss. I am gorky, An Autonomous Humanoid Robot. How can I help you?','Hi Sir! I am gorky. Ask me your question please.',"Hello Sir, I am gorky. How may I help?","Its gorky. How Can I help?"]
listener = sr.Recognizer()
gorky = pyttsx3.init()
rate = gorky.getProperty('rate')
gorky.setProperty('rate', rate - 30)
voices = gorky.getProperty('voices')
gorky.setProperty('voice', voices[1].id)
gorky.say(welcome[random.randint(0,3)])
gorky.runAndWait()
# Wish Me
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>= 0 and hour<12:
talk("Good Morning Sir !")
elif hour>= 12 and hour<18:
talk("Good Afternoon Sir !")
else:
talk("Good Evening Sir !")
# Talk a string
def talk(x):
gorky.say(x)
gorky.runAndWait()
# Normal kotha
def normal():
db = ['I am Fine Sir. Nice to meet you. How Can I help?','Great!Nice to meet you.','Alhamdulillah. How may I assist?']
select = random.randint(0,3)
return db[select]
# Current time
def time(command):
current_time = datetime.datetime.now().strftime('%I:%M %p')
return current_time
def takeCommand():
r = sr.Recognizer()
with sr.Microphone(0) as source:
print('Listening')
r.pause_threshold = 0.5
# r.adjust_for_ambient_noise(source,duration= 0.5)
try:
audio = r.listen(source,timeout=10,phrase_time_limit=10)
print("Recognizing")
command = r.recognize_google(audio, language='en-In')
command = command.lower()
print(command)
if 'time' in command:# time
wishMe()
talk('The time is ' + time(command))
elif 'hands up' in command or 'hand up' in command or 'rise' in command:
talk('Hands are going up')
# ard.write(b'u')
elif 'handshake' in command or 'hand shake' in command:
talk('Hello Sir. Nice to meet you')
# ard.write(b'h')
elif 'hands down' in command or 'hand down' in command:
talk('Hands are going down')
# ard.write(b'd')
elif 'age' in command or 'built' in command or 'created' in command or 'made' in command:
talk('I was created in 2022 by some students of European University of Bangladesh.')
elif 'your name' in command:
talk('My name is gorky, an Autonomous humanoid Robot')
elif 'father' in command or 'daddy' in command:
talk('I do not have any biological father Technically this is impossible.')
elif 'date' in command:
talk('Sorry, I am not interested.')
elif 'are you there' in command:
talk('Yes, At your service boss.')
elif 'allah' in command or 'god' in command or 'creator' in command:
talk('There should be a creator of the universe like I have. So yes, Allah, Vagaban or God exists.')
elif 'thanks a lot' in command or 'thank you' in command or 'thanks' in command:
talk('You are welcome boss')
elif 'how are you' in command or 'what is up' in command or 'whats up' in command:
talk(normal)
elif 'jokes' in command or 'i am sad' in command or "tell me a joke" in command:
talk(pyjokes.get_joke())
# face recognition
elif 'detect' in command or 'face recognition' in command or 'recognize me' in command or 'recognise me' in command:
# runpy.run_path('face_recog.py')
talk("Please Wait. Let me check my database. Keep your eyes on me.")
os.system("python face_recog.py")
talk("Ask me your next question please")
# print("ber")
# manushjoner information
elif 'hasina' in command or 'sheikh hasina' in command or 'prime minister' in command:
with open('./info/hasina.txt', 'r',encoding="utf8") as file:
text = file.read()
talk(text)
file.close()
elif 'polok' in command or 'junaid' in command or 'junaid ahmed' in command:
with open('./info/palak.txt', 'r',encoding="utf8") as file:
text = file.read()
talk(text)
file.close()
elif 'europian' in command or 'university' in command or 'eub' in command or 'european' in command:
with open('./info/eub.txt', 'r',encoding="utf8") as file:
text = file.read()
talk(text)
file.close()
elif 'sheikh' in command or 'mujibur' in command or 'father of' in command or 'bangabandhu' in command:
with open('./info/mujib.txt', 'r',encoding="utf8") as file:
text = file.read()
talk(text)
file.close()
# Kichu na paile then wikipedia
elif 'tell me about' in command:
command = command.replace('tell me about', '')
info = wikipedia.summary(command, 1)
talk(info)
elif 'what is' in command:
command = command.replace('what is', '')
info = wikipedia.summary(command, 1)
talk(info)
elif 'who is' in command:
command = command.replace('who is', '')
info = wikipedia.summary(command, 1)
talk(info)
elif 'do you' in command:
command = command.replace('do you', '')
info = wikipedia.summary(command, 1)
talk(info)
elif 'wikipedia' in command:
command = command.replace('do you', '')
info = wikipedia.summary(command, 1)
talk(info)
else:
talk('Sorry Sir. I do not understand. Please say it again')
except Exception as e:
print(e)
#talk('Sorry Sir. I do not understand. Please say it again')
# talk("Say that again sir")
return "None"
return command
if __name__ == '__main__':
while True:
takeCommand()