diff --git a/README.md b/README.md index 0d9778e..1e6fdfa 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Dependencies can be installed by running this [pip](https://pypi.python.org/pypi 3. PyAudio 4. PyDub 5. Requests +6. PyYAML Operating Systems ---------------- diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..2083ab0 --- /dev/null +++ b/config.yml @@ -0,0 +1,7 @@ +config: + websites: + facebook: 'http://www.facebook.com' + twitter: 'http://www.twitter.com' + gmail: 'http://www.gmail.com' + youtube: 'http://www.youtube.com' + github: 'http://www.github.com' diff --git a/requirements.txt b/requirements.txt index 881f119..047486c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ PyAudio==0.2.8 pydub==0.9.1 requests==2.2.1 http://downloads.sourceforge.net/project/pyaiml/PyAIML%20%28unstable%29/0.8.6/PyAIML-0.8.6.zip +http://pyyaml.org/download/pyyaml/PyYAML-3.11.zip diff --git a/src/brain.py b/src/brain.py index 4f9b67a..4e15f51 100644 --- a/src/brain.py +++ b/src/brain.py @@ -4,13 +4,20 @@ import random import urllib import thread +import yaml + from src import google_tts from src.wikipedia import wikipedia from src import network from src.some_functions import * from src import common + + speak_engine = google_tts.Google_TTS() +with open('config.yml', 'r') as f: + config = yaml.load(f) + class Brain(): @@ -21,26 +28,12 @@ class Brain(): def process(self, text): words = text.lower().split(' ') if 'open' in words: - if 'facebook' in words: - speak_engine.say("I'm on it. Stand By.") - webbrowser.open_new_tab("http://www.facebook.com") - return True - if 'google' in words: - speak_engine.say("I'm on it. Stand By.") - webbrowser.open_new_tab("http://www.google.com") - return True - if 'twitter' in words: - speak_engine.say("I'm on it. Stand By.") - webbrowser.open_new_tab("http://www.twitter.com") - return True - if 'gmail' in words: - speak_engine.say("I'm on it. Stand By.") - webbrowser.open_new_tab("http://mail.google.com") - return True - if 'youtube' in words: - speak_engine.say("I'm on it. Stand By.") - webbrowser.open_new_tab("http://www.youtube.com") - return True + speak_engine.say("I'm on it. Stand By.") + websites = config["config"]["websites"] + website_to_open = text[text.index('open') + 5:] + if website_to_open in websites: + url = websites[website_to_open] + webbrowser.open_new_tab(url) if 'search' in words: speak_engine.say("I'm looking for it. Please stand by!") term_to_search = text[text.index('search') + 7:] @@ -57,7 +50,7 @@ def process(self, text): if 'a' in words and 'song' in words: thread.start_new_thread(play_music, ()) return True - if 'current' in words and 'time' in words: + if 'current' in words and 'time' in words: time = common.getCurrentTime() speak_engine.say(time) return True