Skip to content

Commit

Permalink
updated main2.py
Browse files Browse the repository at this point in the history
  • Loading branch information
satyam9090 authored Jun 9, 2020
1 parent 7db1054 commit 16e9fc1
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions main2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
# obtain audio from the microphone
def func():
r = sr.Recognizer()
isl_gif=['all the best', 'any questions', 'are you angry', 'are you busy', 'are you hungry', 'are you sick', 'be careful',
isl_gif=['any questions', 'are you angry', 'are you busy', 'are you hungry', 'are you sick', 'be careful',
'can we meet tomorrow', 'did you book tickets', 'did you finish homework', 'do you go to office', 'do you have money',
'do you want something to drink', 'do you want tea or coffee', 'do you watch TV', 'dont worry', 'flower is beautiful',
'good afternoon', 'good evening', 'good morning', 'good night', 'good question', 'had your lunch', 'happy journey',
'hello what is your name', 'how many people are there in your family', 'i am a clerk', 'i am bore doing nothing',
'i am fine', 'i am sorry', 'i am thinking', 'i am tired', 'i dont understand anything', 'i go to a theatre', 'i love to shop',
'i had to say something but i forgot', 'i have headache', 'i like pink colour', 'i live in nagpur', 'lets go for lunch', 'my mother is a homemaker',
'my name is john', 'nice to meet you', 'no smoking please', 'open the door', 'please call an ambulance', 'please call me later',
'my name is john', 'nice to meet you', 'no smoking please', 'open the door', 'please call me later',
'please clean the room', 'please give me your pen', 'please use dustbin dont throw garbage', 'please wait for sometime', 'shall I help you',
'shall we go together tommorow', 'sign language interpreter', 'sit down', 'stand up', 'take care', 'there was traffic jam', 'wait I am thinking',
'what are you doing', 'what is the problem', 'what is todays date', 'what is your age', 'what is your father do', 'what is your job',
'what are you doing', 'what is the problem', 'what is todays date', 'what is your father do', 'what is your job',
'what is your mobile number', 'what is your name', 'whats up', 'when is your interview', 'when we will go', 'where do you stay',
'where is the bathroom', 'where is the police station', 'you are wrong','address','agra','ahemdabad', 'all', 'april', 'assam', 'august', 'australia', 'badoda', 'banana', 'banaras', 'banglore',
'bihar','bihar','bridge','cat', 'chandigarh', 'chennai', 'christmas', 'church', 'clinic', 'coconut', 'crocodile','dasara',
Expand All @@ -34,8 +34,7 @@ def func():
'voice', 'wednesday', 'weight','please wait for sometime','what is your mobile number','what are you doing','are you busy']


arr=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r',
's','t','u','v','w','x','y','z']
arr=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', 's','t','u','v','w','x','y','z']
with sr.Microphone() as source:
# image = "signlang.png"
# msg="HEARING IMPAIRMENT ASSISTANT"
Expand All @@ -44,26 +43,18 @@ def func():
r.adjust_for_ambient_noise(source)
i=0
while True:
root1 = tk.Tk()
root1.title('Detecting Voice')
# root1.configure(height=350, width=700)
T = tk.Text(root1, height=350, width=700)
T.pack()
T.insert(tk.END,"Just a text Widget")
# audio = r.listen(source)
root1.mainloop()
print("I am Listening")
audio = r.listen(source)
# recognize speech using Sphinx
try:
a=r.recognize_google(audio)
ourMessage = 'You Said: ' + a.lower()
messageVar = tk.Message(root, text = ourMessage)
messageVar.config(bg='orange')
messageVar.pack( )
a = a.lower()
print('You Said: ' + a.lower())

for c in string.punctuation:
a= a.replace(c,"")

if(a.lower()=='goodbye'):
if(a.lower()=='goodbye' or a.lower()=='good bye' or a.lower()=='bye'):
print("oops!Time To say good bye")
break

Expand Down Expand Up @@ -104,31 +95,27 @@ def next_frame(self):
self.loc %= len(self.frames)
self.config(image=self.frames[self.loc])
self.after(self.delay, self.next_frame)
root1 = tk.Tk()
root = tk.Tk()
lbl = ImageLabel(root)
lbl.pack()
lbl.load(r'ISL_Gifs/{0}.gif'.format(a.lower()))
root.mainloop()
else:

for i in range(len(a)):
#a[i]=a[i].lower()
if(a[i] in arr):

ImageAddress = 'letters/'+a[i]+'.jpg'
ImageItself = Image.open(ImageAddress)
ImageNumpyFormat = np.asarray(ImageItself)
plt.imshow(ImageNumpyFormat)
plt.draw()
plt.pause(0.8) # pause how many seconds
#plt.close()
plt.pause(0.8)
else:
continue

except:
print("Could not listen")
print(" ")
plt.close()
#func()
while 1:
image = "signlang.png"
msg="HEARING IMPAIRMENT ASSISTANT"
Expand Down

0 comments on commit 16e9fc1

Please sign in to comment.