Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
RajatGarg97 authored Apr 26, 2019
2 parents 2028b60 + 0124045 commit 0813f6f
Show file tree
Hide file tree
Showing 6 changed files with 985 additions and 928 deletions.
10 changes: 8 additions & 2 deletions MacOS/benji.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@


def events(frame, put,link):
"""Identifies the event to be performed."""
identity_keywords = ["who are you", "who r u", "what is your name"]
youtube_keywords = ["play ", "stream ", "queue " , "youtube"]
launch_keywords = ["open "]
Expand Down Expand Up @@ -426,16 +427,17 @@ def events(frame, put,link):

i=0

#A stdout class to redirect output to tkinter window
class StdRedirector(object):

class StdRedirector(object):
"""A stdout class to redirect output to tkinter window."""
def __init__(self, text_window):
self.text_window = text_window

def write(self, output):
self.text_window.insert(tk.END, output)

class MyFrame(tk.Frame):
"""Creates the graphical user interface."""
def __init__(self,*args,**kwargs):

self.textBox = tk.Text(root,
Expand Down Expand Up @@ -470,6 +472,7 @@ def __init__(self,*args,**kwargs):


def OnEnter(self,event):
"""Identifies the text and sends it for display to displayText."""
put=self.textBox.get("1.2","end-1c")
print(put)
self.textBox.delete('1.2',tk.END)
Expand All @@ -482,6 +485,7 @@ def OnEnter(self,event):
self.displayText('Reenter')

def OnClicked(self):
"""Recognizes the audio and sends it for display to displayText."""
r = sr.Recognizer()
with sr.Microphone() as source:
system('say Hey I am Listening ')
Expand All @@ -505,6 +509,7 @@ def OnClicked(self):


def displayText(self, text):
"""Displays the text in a output window."""
try :
if not self.output_window.winfo_viewable() :
self.output_window.update()
Expand All @@ -514,6 +519,7 @@ def displayText(self, text):
print(text)

def createOutputWindow(self):
"""Creates a output window to display the text."""
self.output_window = tk.Toplevel()
output_text_window = tk.Text(self.output_window)
self.stddirec = StdRedirector(output_text_window)
Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ Maintainers : [Dhruv Apte](https://github.com/the-ethan-hunt), [Abhimanyu Thakre
You can install B.E.N.J.I. on your laptop by cloning this repository as of first:
1. `git clone http://github.com/the-ethan-hunt/B.E.N.J.I`
2. Open your `IPython notebook` to `%run benji.py`. For `Command Prompt` try `python benji.py`. <br><br>
Note:If a module is not found, then install each module by: pip install modulename<br>
P.S. B.E.N.J.I. now works for Windows, Linux and Mac OS :tada:

#### Mac installation Troubleshooting
#### Mac Installation Troubleshooting

````
creating build/temp.macosx-10.12-x86_64-3.6/src
Expand All @@ -77,6 +78,30 @@ ModuleNotFoundError: No module named 'PIL'
```
Command to solve the above: ```pip3 install Pillow```

```
Traceback (most recent call last):
File "MacOS/benji.py", line 10, in <module>
import wikipedia
ModuleNotFoundError: No module named 'wikipedia'
```
Command to solve the above: ```pip3 install wikipedia```

```
Traceback (most recent call last):
File "MacOS/benji.py", line 21, in <module>
import speech_recognition as sr
ModuleNotFoundError: No module named 'speech_recognition'
```
Command to solve the above: ```pip3 install SpeechRecognition```

```
Traceback (most recent call last):
File "MacOS/benji.py", line 23, in <module>
import pyttsx3
ModuleNotFoundError: No module named 'pyttsx3'
```
Command to solve the above: ```pip3 install pyttsx3```

Change the pip version above according to what you have installed on your mac.

### B.E.N.J.I working in Linux
Expand All @@ -85,6 +110,9 @@ Change the pip version above according to what you have installed on your mac.
### B.E.N.J.I working on Windows
![Working on Windows](working-benji-windows.gif)

### B.E.N.J.I working on Mac
![Working on Windows](working-benji-mac.gif)

### Contributing

[(Back to top)](#list-of-contents)
Expand Down
19 changes: 14 additions & 5 deletions linux/benji.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@


def events(frame, put):
"""Identifies the event to be performed."""
identity_keywords = ["who are you", "who r u", "what is your name"]
open_keywords = ["open "]
launcher_keywords = ["launch "]
Expand Down Expand Up @@ -320,16 +321,17 @@ def events(frame, put):
except:
speak.say("Sorry,couldn't print")

#A customized thread class for tracking reminders
class reminderThread(threading.Thread):

class reminderThread(threading.Thread):
"""A customized thread class for tracking reminders."""
def __init__(self, frame):
threading.Thread.__init__(self)
self.event = threading.Event()
self.reminder_given_flag = False
self.frame = frame

def run(self):
"""Displays the upcoming reminders."""
while not self.event.is_set() :
upcoming_reminders = list()
self.removePastReminders()
Expand Down Expand Up @@ -360,6 +362,7 @@ def run(self):
time.sleep(1)

def removePastReminders(self):
"""Removes the past reminders."""
try :
file_hand = open(reminder_filename, 'r')
reminder_list = file_hand.readlines()
Expand All @@ -380,18 +383,19 @@ def removePastReminders(self):
self.frame.displayText("Error occured")
i=0

#A stdout class to redirect output to tkinter window
class StdRedirector(object):

class StdRedirector(object):
"""A stdout class to redirect output to tkinter window."""
def __init__(self, text_window):
self.text_window = text_window

def write(self, output):
self.text_window.insert(tk.END, output)

class MyFrame(tk.Frame):
"""Creates the graphical user interface."""
def __init__(self,*args,**kwargs):
#new Thread to track reminders
"""Creates a new thread to track reminders."""
global reminder_thread
reminder_thread = reminderThread(self)
tk.Frame.__init__(self,*args,**kwargs)
Expand Down Expand Up @@ -419,6 +423,7 @@ def __init__(self,*args,**kwargs):
reminder_thread.start()

def OnEnter(self,event):
"""Identifies the text and sends it for display to displayText."""
put=self.textBox.get("1.2","end-1c")
self.displayText(put)
self.textBox.insert('1.2',put)
Expand All @@ -428,6 +433,7 @@ def OnEnter(self,event):
self.displayText('Reenter')

def OnClicked(self):
"""Recognizes the audio and sends it for display to displayText."""
r = sr.Recognizer()
with sr.Microphone() as source:
speak.say('Hey I am Listening ')
Expand All @@ -446,11 +452,13 @@ def OnClicked(self):
self.displayText("Could not request results; {0}".format(e))

def onClose(self, event):
"""Destroys the thread."""
global reminder_thread
reminder_thread.event.set()
#root.destroy()

def displayText(self, text):
"""Displays the text in a output window."""
try :
if not self.output_window.winfo_viewable() :
self.output_window.update()
Expand All @@ -460,6 +468,7 @@ def displayText(self, text):
print(text)

def createOutputWindow(self):
"""Creates a output window to display the text."""
self.output_window = tk.Toplevel()
output_text_window = tk.Text(self.output_window)
self.stddirec = StdRedirector(output_text_window)
Expand Down
Loading

0 comments on commit 0813f6f

Please sign in to comment.