Example #1
0
def analize(text):
    # valid command list

    commandset = commands.givecommands()
    sounder = Sounder(commandset)
    index = sounder.search(text.lower().split())
    command = " ".join(commandset[index])
    return command
Example #2
0
class TextLearner:
    def __init__(self):
        self.modules = self.get_modules()
        self.chances = []
        self.searcher = Sounder()

    def set_modules(self, modules):
        self.modules = modules
        return self

    def learn(self, key_words):
        module_func = self.understand(key_words)
        print(module_func)
        return module_func

    @staticmethod
    def get_modules():
        c = config
        return c.get_modules()

    def understand(self, keywords):
        print(keywords)
        dataset = []
        for x in self.modules:
            dataset.append(x[1])
        return self.modules[self.searcher.set_dataset(dataset).search(keywords)]
Example #3
0
class TextLearner:
    def __init__(self):
        self.modules = self.get_modules()
        self.chances = []
        self.searcher = Sounder()

    def set_modules(self, modules):
        self.modules = modules
        return self

    def learn(self, key_words):
        module_func = self.understand(key_words)
        print(module_func)
        return module_func

    @staticmethod
    def get_modules():
        c = config
        return c.get_modules()

    def understand(self, keywords):
        print(keywords)
        dataset = []
        for x in self.modules:
            dataset.append(x[1])
        return self.modules[self.searcher.set_dataset(dataset).search(
            keywords)]
class ActivitySearch:
    def __init__(self):
        self.sounder = Sounder()

    def get_probability(self, given_keywords, user_keywords):
        info = self.sounder.probability(query=user_keywords, dataset=given_keywords, 
                                        prediction=True, metaphone=True, detailed=True)
        return info['chances']
Example #5
0
class ActivitySearch:
    def __init__(self):
        self.sounder = Sounder()

    def get_probability(self, given_keywords, user_keywords):
        info = self.sounder.probability(query=user_keywords,
                                        dataset=given_keywords,
                                        prediction=True,
                                        metaphone=True,
                                        detailed=True)
        return info['chances']
Example #6
0
def main(opts):
    if not opts.demo:
        from reader import Reader

    global q
    delay = .001
    lights = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0}

    print opts
    if not opts.demo:
        reader = Reader(lights)

    sounder = Sounder()
    player = Player(sounder)
    songs = ["breathe", "hotrs", "wishhere", "polly", "ripple"]

    for song in cycle(songs):
        #time.sleep(.5)
        q = player.song(song)

        while True:
            debug_str = ""
            time.sleep(delay)

            if not opts.demo:
                reader.fetch()

            if not q["play"].empty():
                player.chord(q["play"].get_nowait())

            for ch in lights:
                debug_str += "{}:{} ".format(ch, lights[ch])
                if lights[ch] < 650 or opts.demo:
                    sounder.start(get_str(ch))
                else:
                    sounder.stop(get_str(ch))

            print(debug_str)
            time.sleep(delay)

            if q["sig"] == "stopped":
                print "caught sig... stopping song"
                sounder.mute()
                break
Example #7
0
def main(opts):
    if not opts.demo:
        from reader import Reader

    global q
    delay = 0.001
    lights = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0}

    print opts
    if not opts.demo:
        reader = Reader(lights)

    sounder = Sounder()
    player = Player(sounder)
    songs = os.listdir("./songs/")
    songs = filter(lambda x: x.endswith(".js"), songs)

    numpy.random.shuffle(songs)
    print ("Loaded songs:")
    print (songs)

    for song in cycle(songs):
        # time.sleep(.5)
        q = player.song(song)

        while True:
            debug_str = ""
            time.sleep(delay)

            if not opts.demo:
                reader.fetch()

            if not q["play"].empty():
                player.chord(q["play"].get_nowait())

            for ch in lights:
                debug_str += "{}:{} ".format(ch, lights[ch])
                if lights[ch] < 650 or opts.demo:
                    sounder.start(get_str(ch))
                else:
                    sounder.stop(get_str(ch))

            # print(debug_str)
            time.sleep(delay)

            if q["sig"] == "stopped":
                print "caught sig... stopping song"
                sounder.mute()
                break
Example #8
0
def main(opts):
  if not opts.demo:
    from reader import Reader

  global q
  delay = .001
  lights = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0}

  print opts
  if not opts.demo:
    reader = Reader(lights)

  sounder = Sounder()
  player = Player(sounder)
  songs = ["breathe", "hotrs", "wishhere", "polly", "ripple"]

  for song in cycle(songs):
    #time.sleep(.5)
    q = player.song(song)

    while True:
      debug_str = ""
      time.sleep(delay)

      if not opts.demo:
        reader.fetch()

      if not q["play"].empty():
        player.chord(q["play"].get_nowait())

      for ch in lights:
        debug_str += "{}:{} ".format(ch, lights[ch])
        if lights[ch] < 650 or opts.demo:
          sounder.start(get_str(ch))
        else:
          sounder.stop(get_str(ch))

      print(debug_str)
      time.sleep(delay)

      if q["sig"] == "stopped":
        print "caught sig... stopping song"
        sounder.mute()
        break
Example #9
0
 def __init__(self):
     self.sounder = Sounder()
Example #10
0
 def __init__(self):
     self.modules = self.get_modules()
     self.chances = []
     self.searcher = Sounder()
Example #11
0
dprint("\nProbabilities:")
if DEBUG:
    for b in B:
        dprint("{0} \nwith e={1} and d={2}".format(b, e_p[b.i], d_p[b.i],
                                                   sum(e_p[b.i].values()),
                                                   sum(d_p[b.i].values())))

# print "\nSafety check:"
# print accent_p(B[7],S[1])
# print duration_p(B[7],S[0])

# Two emission functions
# xpath = viterbi.viterbi(S,B,T,start_p,accent_p,duration_p)
# One emission function
xpath = viterbi.viterbi(S, B, T, start_p, accent_p)

print "\nAnd they said, in great unison, that The Path shalt be:"

sounder = Sounder(5)
sendlist = [(-1, 1, b) for b in range(0, 5)]
for x in xpath:
    print x
    # print "Hidden state, transition values ",T[x.i]
    sendlist[x.origin] = (ra.randint(60, 80), x.duration, x.origin)

print sendlist
sounder.set_notes(sendlist)
sounder.send_notes()
sounder.close()
 def __init__(self):
     self.sounder = Sounder()
Example #13
0
print("Kindly input your command.")

print("\n")

user_string = input()

print("\n")

print("Your command: %s" % user_string)

key_words_array = []
for a in dataset:
    key_words_array.append(a[1])

s = Sounder(key_words_array)


def get_user_words_array(user_string):
    user_array = user_string.split()
    for user_word in user_array:
        if user_word in s.get_reserved_sub_words():
            user_array.remove(user_word)
    return user_array


user_keywords = get_user_words_array(user_string)

print("\n")

index = s.search(user_keywords)
Example #14
0
dprint("\nProbabilities:")
if DEBUG:
    for b in B:  
        dprint("{0} \nwith e={1} and d={2}".format(b,e_p[b.i],d_p[b.i],sum(e_p[b.i].values()),sum(d_p[b.i].values())))


# print "\nSafety check:"
# print accent_p(B[7],S[1])
# print duration_p(B[7],S[0])

# Two emission functions
# xpath = viterbi.viterbi(S,B,T,start_p,accent_p,duration_p)
# One emission function
xpath = viterbi.viterbi(S,B,T,start_p, accent_p)

print "\nAnd they said, in great unison, that The Path shalt be:"

sounder = Sounder(5)
sendlist = [(-1,1,b) for b in range(0,5)]
for x in xpath:
    print x
    # print "Hidden state, transition values ",T[x.i]
    sendlist[x.origin] = (ra.randint(60,80),x.duration,x.origin)

print sendlist
sounder.set_notes(sendlist)
sounder.send_notes()
sounder.close()

Example #15
0
 def __init__(self):
     self.modules = self.get_modules()
     self.chances = []
     self.searcher = Sounder()