def __init__(self): self.mouth = Mouth() self.ears = Ears() self.va = Auto_NAT() self.current_weather = None self.current_temp = None self.forecast = {}
def smile_detection(self): x1, y1, x2, y2 = self.mouth_rect() mouth_rect = self.img[y1:y2, x1:x2] smile_cascade = face_cascade = cv2.CascadeClassifier( os.getcwd() + '\\haarcascades\\haarcascade_smile.xml') smiles = smile_cascade.detectMultiScale(mouth_rect, 1.1, 4) #mouthes = d.get('haarcascade_mcs_mouth').detectMultiScale(mouth_rect, 1.5, 2) i = None if len(smiles) != 0: i = self.check_mouth_distance(smiles, x1, y1) if i != None: self.organs_dict["smile"] = Mouth(smiles[i], True)
def smile_detection(self): x1, y1, x2, y2 = self.mouth_rect() mouth_rect = self.img[y1:y2, x1:x2] smile_cascade = face_cascade = cv2.CascadeClassifier( 'C:\Users\Katia\Anaconda3\pkgs\opencv-3.1.0-np111py35_1\Library\etc\haarcascades\haarcascade_smile.xml' ) smiles = smile_cascade.detectMultiScale(mouth_rect, 1.1, 4) #mouthes = d.get('haarcascade_mcs_mouth').detectMultiScale(mouth_rect, 1.5, 2) i = None if len(smiles) != 0: i = self.check_mouth_distance(smiles, x1, y1) if i != None: self.organs_dict["smile"] = Mouth(smiles[i], True)
import speech_recognition as SR from Mouth import Mouth import winsound import os import inspect import logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) dexSay = Mouth() BING_KEY_FILE = open('APIS/Bing.txt', 'r') BING_KEY = BING_KEY_FILE.read() class Ears(): def __init__(self): '''Initialize all the speech recognition reqs''' self.recognizer = SR.Recognizer() self.microphone = SR.Microphone() def listen(self, dexActive): with self.microphone as source: self.recognizer.adjust_for_ambient_noise(source) if dexActive: # VK_MEDIA_PLAY_PAUSE = 0xB3 # hwcode = win32api.MapVirtualKey(VK_MEDIA_PLAY_PAUSE, 0) # win32api.keybd_event(VK_MEDIA_PLAY_PAUSE, hwcode)
class Brain: def __init__(self): self.mouth = Mouth() self.ears = Ears() self.va = Auto_NAT() self.current_weather = None self.current_temp = None self.forecast = {} def assess(self, data): if 'Emma' in data: self.mouth.speak('Hello Lovely') self.ears.listen_to() self.ears.get_message() self.assess(self.ears.message) if 'time' in data: self.tell_time() elif 'weather' in data: self.mouth.speak('what is your zip code') self.ears.listen_to() self.ears.get_message() zip_code = self.ears.message self.get_weather(zip_code) self.mouth.speak(self.current_weather) self.mouth.speak(self.current_temp) self.mouth.close_mouth() elif 'forecast'in data: self.mouth.speak('what is your zip code') self.ears.listen_to() self.ears.get_message() zip_code = self.ears.message self.get_forecast(zip_code) elif 'open' in data: self.open_page() elif 'light' in data: self.lights() elif 'assistant' in data: self.va() else: self.mouth.speak('I dont understand') self.mouth.speak('have a nice day') self.mouth.close_mouth() def tell_time(self): current_time = "Current time is %s:%s %s" % (time.strftime("%I"), time.strftime("%M"), time.strftime("%p")) self.mouth.speak(current_time) self.mouth.close_mouth() def get_weather(self, location): # wunderground key 4e5650239b5d5af8 # http://api.wunderground.com/api/4e5650239b5d5af8/conditions/q/10550.json try: weather_url = 'http://api.wunderground.com/api/4e5650239b5d5af8/geolookup/conditions/q/PA/' + location + '.json' browser = mechanize.Browser() w = browser.open(weather_url) json_string = w.read() parsed_json = json.loads(json_string) city = parsed_json['location']['city'] state = parsed_json['location']['state'] weather = parsed_json['current_observation']['weather'] temperature = parsed_json['current_observation']['temp_f'] real_feel = parsed_json['current_observation']['feelslike_f'] self.current_weather = 'weather in %s %s is %s' % (city, state, weather.lower()) self.current_temp = 'It is currently %s degrees and it feels like %s' % (temperature, real_feel) except KeyError, ke: self.mouth.speak('Cant find weather for that %s' % ke)