예제 #1
0
    def testWordExtraction(self):
        sentences = "temp_sentences.txt"
        dictionary = "temp_dictionary.dic"
        languagemodel = "temp_languagemodel.lm"

        words = []

        mock_module = Mock()
        mock_module.WORDS = [
            'MOCK'
        ]

        words.extend(mock_module.WORDS)

        with patch.object(g2p, 'translateWords') as translateWords:
            with patch.object(vocabcompiler, 'text2lm') as text2lm:
                with patch.object(brain.Brain, 'get_modules',
                                  classmethod(lambda cls: [mock_module])):
                    vocabcompiler.compile(sentences, dictionary, languagemodel)

                    translateWords.assert_called_once_with(
                        UnorderedList(words))
                    self.assertTrue(text2lm.called)
        os.remove(sentences)
        os.remove(dictionary)
예제 #2
0
    def testWordExtraction(self):
        sentences = "temp_sentences.txt"
        dictionary = "temp_dictionary.dic"
        languagemodel = "temp_languagemodel.lm"

        words = [
            'MUSIC', 'SPOTIFY'
        ]

        mock_module = Mock()
        mock_module.WORDS = [
            'MOCK'
        ]

        words.extend(mock_module.WORDS)

        with patch.object(g2p, 'translateWords') as translateWords:
            with patch.object(vocabcompiler, 'text2lm') as text2lm:
                with patch.object(brain.Brain, 'get_modules', classmethod(lambda cls: [mock_module])) as modules:
                    vocabcompiler.compile(sentences, dictionary, languagemodel)

                    translateWords.assert_called_once_with(UnorderedList(words))
                    self.assertTrue(text2lm.called)
        os.remove(sentences)
        os.remove(dictionary)
예제 #3
0
def configure():
    try:
        print "COMPILING DICTIONARY"
        vocabcompiler.compile("../client/sentences.txt",
                              "../client/dictionary.dic",
                              "../client/languagemodel.lm")
        print "STARTING CLIENT PROGRAM"
        os.system("$JASPER_HOME/jasper/client/start.sh &")

    except OSError:
        print "BOOT FAILURE: OSERROR"
        fail(
            "There was a problem starting Jasper. You may be missing the language model and associated files. Please read the documentation to configure your Raspberry Pi."
        )

    except IOError:
        print "BOOT FAILURE: IOERROR"
        fail(
            "There was a problem starting Jasper. You may have set permissions incorrectly on some part of the filesystem. Please read the documentation to configure your Raspberry Pi."
        )

    except:
        print "BOOT FAILURE"
        fail(
            "There was a problem starting Jasper. Please read the documentation to configure your Raspberry Pi."
        )
예제 #4
0
def configure():
    print "COMPILING DICTIONARY"
    vocabcompiler.compile("../client/sentences.txt",
                          "../client/dictionary.dic",
                          "../client/languagemodel.lm")

    print "STARTING CLIENT PROGRAM"
    os.system("/home/pi/jasper/client/start.sh &")
예제 #5
0
def configure():
    try:
        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile("../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")

        print "STARTING CLIENT PROGRAM"
        os.system("$JASPER_HOME/jasper/client/start.sh &")

    except:
        print "COULD NOT CONNECT TO NETWORK"
        traceback.print_exc()
        speaker.say("Witaj, nie udało mi się połączyć z internetem. Muszę, więc zakończyć.")
예제 #6
0
def configure():
    try:
        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile("../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")

        print "STARTING CLIENT PROGRAM"
        os.system("$JASPER_HOME/jasper/client/start.sh &")

    except:
        print "COULD NOT CONNECT TO NETWORK"
        traceback.print_exc()
        speaker.say("Hello, I could not connect to a network. Please read the documentation to configure your Raspberry Pi.")
예제 #7
0
def configure():
    try:
        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile("../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")

        print "STARTING CLIENT PROGRAM"
        os.system("$JASPER_HOME/jasper/client/start.sh &")

    except:
        print "COULD NOT CONNECT TO NETWORK"
        traceback.print_exc()
        speaker.say("Hello, I could not connect to a network. Please read the documentation to configure your Raspberry Pi.")
예제 #8
0
def best_sphinx_speech_result(pyaudio, wav_name, profile):
  if not have_sphinx_dictionary:
    if not profile.has_key("words"):
      raise(KeyError("Pass the possible words in in profile"))
    compile("sentences.txt", "dictionary.dic", "language_model.lm", profile["words"])
    global have_sphinx_dictionary
    have_sphinx_dictionary = True

  wav_file = file(wav_name, 'rb')
  speechRec = Decoder(
    hmm  = "/usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k",
    lm   = "language_model.lm",
    dict = "dictionary.dic"
  )

  speechRec.decode_raw(wav_file)
  results = speechRec.get_hyp()
  return results[0]
예제 #9
0
def configure():
    try:

        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile()

        print "STARTING CLIENT PROGRAM"

        try:
            os.system("sudo -u pi /home/pi/jasper/client/start.sh &")
        except Exception, e:
            print(repr(e))
            os.system("/home/pi/jasper/backup/start.sh &")
        finally:
            return
예제 #10
0
def configure():
    try:
        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile("../client/sentences.txt",
                              "../client/dictionary.dic",
                              "../client/languagemodel.lm")

        print "STARTING CLIENT PROGRAM"
        os.system("$JASPER_HOME/jasper/client/start.sh &")

    except:
        print "COULD NOT CONNECT TO NETWORK"
        traceback.print_exc()
        speaker.say(
            "Witaj, nie udało mi się połączyć z internetem. Muszę, więc zakończyć."
        )
예제 #11
0
def configure():
    try:

        urllib2.urlopen("http://www.google.com").getcode()
        say("Internet connected")

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile()

        print "STARTING CLIENT PROGRAM"

        try:
            os.system("/home/pi/jasper/client/start.sh")
        except:
            os.system("/home/pi/jasper/backup/start.sh")
        finally:
            return

    except:
        say("it failed, try again")
예제 #12
0
def configure():
    try:
        print "COMPILING DICTIONARY"
        vocabcompiler.compile(
            "../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")
        print "STARTING CLIENT PROGRAM"
        os.system("$JASPER_HOME/jasper/client/start.sh &")

    except OSError:
        print "BOOT FAILURE: OSERROR"
        fail(
            "There was a problem starting Jasper. You may be missing the language model and associated files. Please read the documentation to configure your Raspberry Pi.")

    except IOError:
        print "BOOT FAILURE: IOERROR"
        fail(
            "There was a problem starting Jasper. You may have set permissions incorrectly on some part of the filesystem. Please read the documentation to configure your Raspberry Pi.")

    except:
        print "BOOT FAILURE"
        fail(
            "There was a problem starting Jasper. Please read the documentation to configure your Raspberry Pi.")
예제 #13
0
    def testWordExtraction(self):
        sentences = "temp_sentences.txt"
        dictionary = "temp_dictionary.dic"
        languagemodel = "temp_languagemodel.lm"

        words = [
            'HACKER', 'LIFE', 'FACEBOOK', 'THIRD', 'NO', 'JOKE',
            'NOTIFICATION', 'MEANING', 'TIME', 'TODAY', 'SECOND',
            'BIRTHDAY', 'KNOCK KNOCK', 'INBOX', 'OF', 'NEWS', 'YES',
            'TOMORROW', 'EMAIL', 'WEATHER', 'FIRST', 'MUSIC', 'SPOTIFY'
        ]

        with patch.object(g2p, 'translateWords') as translateWords:
            with patch.object(vocabcompiler, 'text2lm') as text2lm:
                vocabcompiler.compile(sentences, dictionary, languagemodel)

                # 'words' is appended with ['MUSIC', 'SPOTIFY']
                # so must be > 2 to have received WORDS from modules
                translateWords.assert_called_once_with(UnorderedList(words))
                self.assertTrue(text2lm.called)
        os.remove(sentences)
        os.remove(dictionary)
예제 #14
0
    def testWordExtraction(self):
        sentences = "temp_sentences.txt"
        dictionary = "temp_dictionary.dic"
        languagemodel = "temp_languagemodel.lm"

        words = [
            'HACKER', 'LIFE', 'FACEBOOK', 'THIRD', 'NO', 'JOKE',
            'NOTIFICATION', 'MEANING', 'TIME', 'TODAY', 'SECOND', 'BIRTHDAY',
            'KNOCK KNOCK', 'INBOX', 'OF', 'NEWS', 'YES', 'TOMORROW', 'EMAIL',
            'WEATHER', 'FIRST', 'MUSIC', 'SPOTIFY'
        ]

        with patch.object(g2p, 'translateWords') as translateWords:
            with patch.object(vocabcompiler, 'text2lm') as text2lm:
                vocabcompiler.compile(sentences, dictionary, languagemodel)

                # 'words' is appended with ['MUSIC', 'SPOTIFY']
                # so must be > 2 to have received WORDS from modules
                translateWords.assert_called_once_with(UnorderedList(words))
                self.assertTrue(text2lm.called)
        os.remove(sentences)
        os.remove(dictionary)
예제 #15
0
def configure():
    print "COMPILING DICTIONARY"
    vocabcompiler.compile("../client/sentences.txt", "../client/dictionary.dic", "../client/languagemodel.lm")

    print "STARTING CLIENT PROGRAM"
    os.system("/home/pi/jasper/client/start.sh &")
예제 #16
0
        networks = yaml.safe_load(open("networks.yml", "r"))

        wifi = Wifi()

        for network in networks:
            wifi.set_default_wifi(network['SSID'], network['KEY'])
            say("Attempting to connect to network " + network['SSID'])

            try:

                urllib2.urlopen("http://www.google.com").getcode()

                print "CONNECTED TO INTERNET"
                print "COMPILING DICTIONARY"
                vocabcompiler.compile()

                print "STARTING CLIENT PROGRAM"

                try:
                    os.system("/home/pi/jasper/client/start.sh &")
                except:
                    os.system("/home/pi/jasper/backup/start.sh &")
                finally:
                    return

            except:
                pass

        print "NOT CONNECTED TO INTERNET. RUNNING AD HOC NETWORK."
예제 #17
0
def configure():
    try:

        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile()

        print "STARTING CLIENT PROGRAM"

        try:
            os.system(jasper_home + "/jasper-client/client/start.sh &")
        except:
            os.system(jasper_home + "/jasper-client/backup/start.sh &")
        finally:
            return

    except:

        networks = yaml.safe_load(open("networks.yml", "r"))

        wifi = Wifi()

        for network in networks:
            wifi.set_default_wifi(network['SSID'], network['KEY'])
            say("Attempting to connect to network " + network['SSID'])

            try:

                urllib2.urlopen("http://www.google.com").getcode()

                print "CONNECTED TO INTERNET"
                print "COMPILING DICTIONARY"
                vocabcompiler.compile()

                print "STARTING CLIENT PROGRAM"

                try:
                    os.system("/home/pi/jasper/client/start.sh &")
                except:
                    os.system("/home/pi/jasper/backup/start.sh &")
                finally:
                    return

            except:
                pass

        print "NOT CONNECTED TO INTERNET. RUNNING AD HOC NETWORK."

        wifi.setup_adhoc()

        os.system("sudo app/app.sh &")
        say("Hello.... I could not connect to a wifi network... Please log in with your computer to help me")

        original = open("networks.yml",'r').readlines()
        while True:
            list = open("networks.yml",'r').readlines()
            if list != original:
                break

        say("Thank you for adding a wifi network. Just give me a few minutes to restart.")
        os.system("sudo shutdown -r now")
예제 #18
0
파일: boot.py 프로젝트: mruba/jasper-client
def configure():
    try:

        urllib2.urlopen("http://www.google.com").getcode()

        print "CONNECTED TO INTERNET"
        print "COMPILING DICTIONARY"
        vocabcompiler.compile()

        print "STARTING CLIENT PROGRAM"

        try:
            os.system("/home/pi/jasper/client/start.sh &")
        except:
            os.system("/home/pi/jasper/backup/start.sh &")
        finally:
            return

    except:

        networks = yaml.safe_load(open("networks.yml", "r"))

        wifi = Wifi()

        for network in networks:
            wifi.set_default_wifi(network['SSID'], network['KEY'])
            say("Attempting to connect to network " + network['SSID'])

            try:

                urllib2.urlopen("http://www.google.com").getcode()

                print "CONNECTED TO INTERNET"
                print "COMPILING DICTIONARY"
                vocabcompiler.compile()

                print "STARTING CLIENT PROGRAM"

                try:
                    os.system("/home/pi/jasper/client/start.sh &")
                except:
                    os.system("/home/pi/jasper/backup/start.sh &")
                finally:
                    return

            except:
                pass

        print "NOT CONNECTED TO INTERNET. RUNNING AD HOC NETWORK."

        wifi.setup_adhoc()

        os.system("sudo app/app.sh &")
        say("Hello.... I could not connect to a wifi network... Please log in with your computer to help me"
            )

        original = open("networks.yml", 'r').readlines()
        while True:
            list = open("networks.yml", 'r').readlines()
            if list != original:
                break

        say("Thank you for adding a wifi network. Just give me a few minutes to restart."
            )
        os.system("sudo shutdown -r now")