Esempio n. 1
0
def cleverbotRequest(text, mic, profile):
    #TODO maybe a more pythonic way to do this
    flag = 0
    for arg in sys.argv[1:]:
        if (arg == '--no-network-check'):
            flag = 1

    if flag == 1 and not diagnose.check_network_connection():
        Unclear.handle(text, mic, profile)
    else:
        answer = cb1.ask(text)
        mic.say(answer)
Esempio n. 2
0
def cleverbotRequest(text, mic, profile):
	#TODO maybe a more pythonic way to do this
	flag=0
	for arg in sys.argv[1:]:
		if(arg == '--no-network-check'):
			flag=1
			
	if flag==1 and not diagnose.check_network_connection():
		Unclear.handle(text, mic, profile)
	else:
		answer = cb1.ask(text)
		mic.say(answer)
Esempio n. 3
0
if __name__ == "__main__":

    print("*******************************************************")
    print("*             JASPER - THE TALKING COMPUTER           *")
    print("* (c) 2015 Shubhro Saha, Charlie Marsh & Jan Holthuis *")
    print("*******************************************************")

    logging.basicConfig()
    logger = logging.getLogger()
    logger.getChild("client.stt").setLevel(logging.INFO)

    if args.debug:
        logger.setLevel(logging.DEBUG)

    if not args.no_network_check and not diagnose.check_network_connection():
        logger.warning("Network not connected. This may prevent Jasper from " +
                       "running properly.")

    if args.diagnose:
        failed_checks = diagnose.run()
        sys.exit(0 if not failed_checks else 1)

    try:
        app = Jasper()
    except Exception:
        logger.error("Error occured!", exc_info=True)
        sys.exit(1)

    app.run()
Esempio n. 4
0
class TestModules(unittest.TestCase):
    def setUp(self):
        self.profile = DEFAULT_PROFILE
        self.send = False

    def runConversation(self, query, inputs, module):
        """Generic method for spoofing conversation.

        Arguments:
        query -- The initial input to the server.
        inputs -- Additional input, if conversation is extended.

        Returns:
        The server's responses, in a list.
        """
        self.assertTrue(module.isValid(query))
        mic = test_mic.Mic(inputs)
        module.handle(query, mic, self.profile)
        return mic.outputs

    def testLife(self):
        query = "What is the meaning of life?"
        inputs = []
        outputs = self.runConversation(query, inputs, Life)
        self.assertEqual(len(outputs), 1)
        self.assertTrue("42" in outputs[0])

    def testJoke(self):
        query = "Tell me a joke."
        inputs = ["Who's there?", "Random response"]
        outputs = self.runConversation(query, inputs, Joke)
        self.assertEqual(len(outputs), 3)
        allJokes = open(jasperpath.data('text', 'JOKES.txt'), 'r').read()
        self.assertTrue(outputs[2] in allJokes)

    def testTime(self):
        query = "What time is it?"
        inputs = []
        self.runConversation(query, inputs, Time)

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def testGmail(self):
        key = 'gmail_password'
        if key not in self.profile or not self.profile[key]:
            return

        query = "Check my email"
        inputs = []
        self.runConversation(query, inputs, Gmail)

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def testHN(self):
        query = "find me some of the top hacker news stories"
        if self.send:
            inputs = ["the first and third"]
        else:
            inputs = ["no"]
        outputs = self.runConversation(query, inputs, HN)
        self.assertTrue("front-page articles" in outputs[1])

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def testNews(self):
        query = "find me some of the top news stories"
        if self.send:
            inputs = ["the first"]
        else:
            inputs = ["no"]
        outputs = self.runConversation(query, inputs, News)
        self.assertTrue("top headlines" in outputs[1])

    @unittest.skipIf(not diagnose.check_network_connection(),
                     "No internet connection")
    def testWeather(self):
        query = "what's the weather like tomorrow"
        inputs = []
        outputs = self.runConversation(query, inputs, Weather)
        self.assertTrue("can't see that far ahead" in outputs[0]
                        or "Tomorrow" in outputs[0])
Esempio n. 5
0
    print("*********************************************************")
    print("*    JARVIS - Just A Rather Very Intelligent System     *")
    print("* (c) 2015 Shubhro Saha, Charlie Marsh & Jan Holthuis   *")
    print("*********************************************************")
    print("*And,Ang,Arc,Dyl,Eric,Ikh,Kez,Mik,Mir,Reg,Sef,Stel,Vero *")
    print("*********************************************************")
    print()

    logging.basicConfig()
    logger = logging.getLogger()
    logger.getChild("client.stt").setLevel(logging.INFO)

    if args.debug:
        logger.setLevel(logging.DEBUG)

    if not args.no_network_check and not diagnose.check_network_connection():
        logger.warning("Network not connected. This may prevent Jasper from " +
                       "running properly.")

    if args.diagnose:
        failed_checks = diagnose.run()
        sys.exit(0 if not failed_checks else 1)

    try:
        app = Jasper()
    except Exception:
        logger.error("Error occured!", exc_info=True)
        sys.exit(1)

    app.run()
Esempio n. 6
0
 def is_available(cls):
     return diagnose.check_network_connection()
Esempio n. 7
0
#!/usr/bin/env python2
# -*- coding: utf-8-*-
from __future__ import print_function
import os
import sys
import logging
import yaml
import argparse
import requests
import socket
from client import tts
from client import stt
from client import dingdangpath
from client import diagnose
from client.conversation import Conversation
# Add dingdangpath.LIB_PATH to sys.path
sys.path.append(dingdangpath.LIB_PATH)
parser = argparse.ArgumentParser(description='Dingdang Voice Control Center')
parser.add_argument('--local',
                    action='store_true',
                    help='Use text input instead of a real microphone')
parser.add_argument('--no-network-check',
                    action='store_true',
                    help='Disable the network connection check')
parser.add_argument('--diagnose',
                    action='store_true',
                    help='Run diagnose and exit')
parser.add_argument('--debug', action='store_true', help='Show debug messages')
parser.add_argument('--info', action='store_true', help='Show info messages')
parser.add_argument('--verbose',
Esempio n. 8
0
 def is_available(cls):
     return (super(cls, cls).is_available() and
             diagnose.check_python_import('pyvona') and
             diagnose.check_network_connection())
Esempio n. 9
0
 def is_available(cls):
     return (super(cls, cls).is_available() and
             diagnose.check_network_connection())
Esempio n. 10
0
 def is_available(cls):
     return diagnose.check_network_connection()
Esempio n. 11
0
 def is_available(cls):
     return (super(cls, cls).is_available()
             and diagnose.check_network_connection())