Example #1
0
class VoiceCommand:
    """
	distributes jobs to an appropriate action in the actions folder. 
	"""

    def __init__(self, speaker):
        self.speaker = speaker
        self.controller = webbrowser.get()

        # initialize action class instances
        self.Youtube = Youtube(self.speaker)
        self.Wolfram = Wolfram(self.speaker, os.environ.get("WOLFRAM_API_KEY"))
        self.Music = Music(self.speaker)
        self.Screenshot = Screenshot(self.speaker)
        self.News = News(self.speaker)
        self.Webpage = Webpage(self.speaker)

    def accidental_recording(self):
        print "---Accidental recording---"
        print "Saying: Oops, sorry."
        self.speaker.play_wav("./wav/sorry.wav")

    def open_webpage(self, job):
        self.Webpage.process(job, self.controller)

    def google(self, job):
        self.speaker.say("searching...")
        google_url = "http://www.google.com/search?q="
        phrase = job.query
        url = google_url + phrase.replace(" ", "+")
        self.controller.open(url)

    def search_youtube(self, job):
        self.Youtube.search(job, self.controller)

    def play_youtube(self, job):
        self.Youtube.process(job, self.controller)

    def take_screenshot(self):
        self.Screenshot.take()

    def ai_respond(self, job, AI, memory):
        response = AI.respond(job.query, memory)
        self.speaker.say(response)

    def get_news(self, job):
        self.News.process(job, self.controller)

    def change_news_source(self, job):
        self.News.set_news_url()

    def ask_wolfram(self, job):
        self.Wolfram.process(job, self.controller)

    def play_music(self, job):
        self.Music.process(job, self.controller)
Example #2
0
class VoiceCommand:
	def __init__(self, speaker):
		self.speaker = speaker
		self.controller = webbrowser.get()
		
		# initialize action classes
		self.Youtube = Youtube(self.speaker)
		self.Wolfram = Wolfram(self.speaker, os.environ.get('WOLFRAM_API_KEY'))
		self.Music = Music(self.speaker)
		self.Screenshot = Screenshot(self.speaker)
		self.News = News(self.speaker)
		self.Webpage = Webpage(self.speaker)

	def accidental_recording(self):
		print "---Accidental recording---"
		print "Saying: Oops, sorry."
		self.speaker.play_wav("./wav/sorry.wav")

	def open_webpage(self, job):
		self.Webpage.process(job, self.controller)

	def google(self, job):
		self.speaker.say("searching...")
		google_url = "http://www.google.com/search?q="
		phrase = job.recorded()[job.recorded().find(' ') + 1:]
		url = google_url + phrase.replace(" ", "+")
		self.controller.open(url)

	def search_youtube(self, job):
		self.Youtube.search(job, self.controller)

	def play_youtube(self, job):
		self.Youtube.process(job, self.controller)

	def take_screenshot(self):
		self.Screenshot.take()

	def ai_respond(self, job, AI, memory):
		response = AI.respond(job.recorded()[8:], memory)
		self.speaker.say(response)

	def get_news(self, job):
		self.News.process(job, self.controller)

	def ask_wolfram(self, job):
		self.Wolfram.process(job, self.controller)

	def play_music(self, job):
		self.Music.process(job, self.controller)
Example #3
0
class VoiceCommand:
	"""
	Distribute jobs to the appropriate action.

	"""
	def __init__(self, speaker):
		self.speaker = speaker
		self.controller = webbrowser.get()

		# initialize action class instances
		self.Chatbot = Chatbot(self.speaker)
		self.Youtube = Youtube(self.speaker)

		self.Helper = ActionsHelper(self.speaker)
		self.Webpage = Webpage(self.speaker, self.Helper)
		self.News = News(self.speaker, self.Helper)
		self.Search = Search(self.speaker, self.Helper)
		self.Screenshot = Screenshot(self.speaker, self.Helper)
		self.Music = Music(self.speaker, self.Helper)

		self.Wolfram = Wolfram(self.speaker, os.environ.get('WOLFRAM_API_KEY'))

	def accidental_recording(self):
		"""Started recording by accident, just post message."""
		print "---Accidental recording---"
		print "Saying: Oops, sorry."
		self.speaker.play_wav("./wav/sorry.wav")

	def open_webpage(self, job):
		"""Send to open webpage action; if no page found, search."""
		if self.Webpage.process(job, self.controller) != True:
			self.Search.process(job, self.controller)

	def search(self, job):
		"""Send to web search action."""
		self.Search.process(job, self.controller)

	def search_youtube(self, job):
		"""Send to search youtube action."""
		self.Youtube.search(job, self.controller)

	def play_youtube(self, job):
		"""Send to play first youtube video from search action."""
		self.Youtube.process(job, self.controller)

	def take_screenshot(self):
		"""Send to take screenshot action."""
		self.Screenshot.take()

	def chatbot_respond(self, job):
		"""Send to chatbot to respond action."""
		self.Chatbot.process(job)

	def get_news(self, job):
		"""Send to open news action."""
		self.News.process(job, self.controller)

	def ask_wolfram(self, job):
		"""
		Send to WolframAlpha for a response. 
		If no response is found, send to chatbot for response.

		"""
		if not self.Wolfram.process(job, self.controller):
			self.chatbot_respond(job)

	def play_music(self, job):
		"""Send to play radio action."""
		self.Music.process(job, self.controller)
Example #4
0
class VoiceCommand:
    """
	Distribute jobs to the appropriate action.

	"""

    def __init__(self, speaker):
        self.speaker = speaker
        self.controller = webbrowser.get()

        # initialize action class instances
        self.Chatbot = Chatbot(self.speaker)
        self.Youtube = Youtube(self.speaker)

        self.Helper = ActionsHelper(self.speaker)
        self.Webpage = Webpage(self.speaker, self.Helper)
        self.News = News(self.speaker, self.Helper)
        self.Search = Search(self.speaker, self.Helper)
        self.Screenshot = Screenshot(self.speaker, self.Helper)
        self.Music = Music(self.speaker, self.Helper)

        self.Wolfram = Wolfram(self.speaker, os.environ.get("WOLFRAM_API_KEY"))

    def accidental_recording(self):
        """Started recording by accident, just post message."""
        print "---Accidental recording---"
        print "Saying: Oops, sorry."
        self.speaker.play_wav("./wav/sorry.wav")

    def open_webpage(self, job):
        """Send to open webpage action; if no page found, search."""
        if self.Webpage.process(job, self.controller) != True:
            self.Search.process(job, self.controller)

    def search(self, job):
        """Send to web search action."""
        self.Search.process(job, self.controller)

    def search_youtube(self, job):
        """Send to search youtube action."""
        self.Youtube.search(job, self.controller)

    def play_youtube(self, job):
        """Send to play first youtube video from search action."""
        self.Youtube.process(job, self.controller)

    def take_screenshot(self):
        """Send to take screenshot action."""
        self.Screenshot.take()

    def chatbot_respond(self, job):
        """Send to chatbot to respond action."""
        self.Chatbot.process(job)

    def get_news(self, job):
        """Send to open news action."""
        self.News.process(job, self.controller)

    def ask_wolfram(self, job):
        """
		Send to WolframAlpha for a response. 
		If no response is found, send to chatbot for response.

		"""
        if not self.Wolfram.process(job, self.controller):
            self.chatbot_respond(job)

    def play_music(self, job):
        """Send to play radio action."""
        self.Music.process(job, self.controller)