def index(self):
		wit.init()
		response = wit.voice_query_auto(access_token)
		cherrypy.response.headers['Access-Control-Allow-Origin'] = '*' #
		cherrypy.response.headers['Content-Type'] = 'application/json'
		wit.close()
		return response
Example #2
0
def main():
  audio = pyaudio.PyAudio()
  hue = phue.Bridge('172.17.172.101')

  token = harmony.auth.login('*****@*****.**', '1yD27amH1')
  session_token = harmony.auth.swap_auth_token('172.17.172.100', 5222, token)
  harmony_client = harmony.client.create_and_connect_client('172.17.172.100', 5222, session_token)

  config = harmony_client.get_config()
  activity_map = {act['label']: act['id'] for act in config['activity']}

  while True:
    #triggered = listen_for_trigger(audio, 'Eddie')
    triggered = True
    if triggered:
      say('What can I do for you?')
      wit.init()

      query = wit.voice_query_auto(WIT_TOKEN)

      query = json.loads(query)

      process_query(hue, query, harmony_client, activity_map)

      # Wrapping up
      wit.close()
    def application(self, message):
        """
    Main application logic of the module.

    Args:
      message (dict): received data as a dictionary

    Returns:
      dict: data to send back as dictionary
    """
        action = message['action']
        if action == 'listen':
            wit.init()
            response = wit.voice_query_auto(self.access_token)

            print('Response: {}'.format(response))
            print('msg_id')
            jresponse = json.loads(response)
            print(jresponse["_text"])
            wit.close()
            data = {'request': jresponse["_text"], 'JSON': response}

            # return result
            return data
        else:
            return False
Example #4
0
def get_response():
	wit.init()
	wit.voice_query_start('I5FO3XJWG7M5NYLBTDIN44VUQ6YEOBGI') # start recording
	time.sleep(2) # let's speak for 2 seconds
	a = json.loads(wit.voice_query_stop())
	wit.close()
	print(a)
Example #5
0
def main():
    audio = pyaudio.PyAudio()
    hue = phue.Bridge('172.17.172.101')

    token = harmony.auth.login('*****@*****.**', '1yD27amH1')
    session_token = harmony.auth.swap_auth_token('172.17.172.100', 5222, token)
    harmony_client = harmony.client.create_and_connect_client(
        '172.17.172.100', 5222, session_token)

    config = harmony_client.get_config()
    activity_map = {act['label']: act['id'] for act in config['activity']}

    while True:
        #triggered = listen_for_trigger(audio, 'Eddie')
        triggered = True
        if triggered:
            say('What can I do for you?')
            wit.init()

            query = wit.voice_query_auto(WIT_TOKEN)

            query = json.loads(query)

            process_query(hue, query, harmony_client, activity_map)

            # Wrapping up
            wit.close()
  def application(self, message):
    """
    Main application logic of the module.

    Args:
      message (dict): received data as a dictionary

    Returns:
      dict: data to send back as dictionary
    """
    action = message['action']
    if action == 'listen':
        wit.init()
        response = wit.voice_query_auto(self.access_token)

        print('Response: {}'.format(response))
        print('msg_id')
        jresponse = json.loads(response)
        print(jresponse["_text"])
        wit.close()
        data = {'response': jresponse["_text"], 'JSON': response}

        # return result
        return data
    else:
        return False
Example #7
0
def ask_wit(message):
    access_token = 'PWKWIJSS4XX3EJDMC6AHHI6N7VQ5JJXW'
    wit.init()
    # response = wit.voice_query_auto(access_token)

    response = wit.text_query(message, access_token)
    wit.close()
    return 'Response: {}'.format(response)
def take_command():
	tts.textToSpeech("How may I help you?")
	wit.init()
	commandJSON = json.loads('{}'.format(wit.voice_query_auto(tok)))

	parsed = jsonparser.parse(commandJSON)
	verify(parsed)
	wit.close()
Example #9
0
def search_text(_text):
    wit.init()
    result = wit.text_query(_text, 'VAVQDA6WFDRZBY7W62HER5QTDTEHOOR2')
    j = json.loads(result)
    #print j
    #print json.dumps(j, sort_keys=True, indent = 4 ,  separators = (',',': '))
    wit.close()
    return j['outcomes'][0]['entities']
Example #10
0
def search_text(_text):
    wit.init()
    result = wit.text_query(_text, 'VAVQDA6WFDRZBY7W62HER5QTDTEHOOR2')
    j = json.loads(result)
    #print j
    #print json.dumps(j, sort_keys=True, indent = 4 ,  separators = (',',': '))
    wit.close()
    return j['outcomes'][0]['entities']
Example #11
0
def query():
    access_token = ACCESS_TOKEN
    wit.init()
    response = json.loads(
        wit.voice_query_auto(access_token)
    )
    print('Response: {}'.format(response))
    wit.close()

    return response
Example #12
0
def get_wit_response():
    wit.init()
    response = wit.voice_query_auto(access_token)
    print('Raw: {}'.format(response))
    wit.close()
    if not response:
        return None
    response = json.loads(response)
    response = get_outcome_response(response)
    return response
def getRequest(_text):
    wit.init()
    result = wit.text_query(_text.lower(), 'VAVQDA6WFDRZBY7W62HER5QTDTEHOOR2')
    j = json.loads(result)
    data = j['outcomes'][0]['entities']['how_to_text'][0]
    wit.close()
    #check if exist the value
    if data.has_key('value'):
        return data['value']
    else:
        return None
Example #14
0
def getRequest(_text):
    wit.init()
    result = wit.text_query(_text.lower(), 'VAVQDA6WFDRZBY7W62HER5QTDTEHOOR2')
    j = json.loads(result)
    data = j['outcomes'][0]['entities']['how_to_text'][0]
    wit.close()
#check if exist the value
    if data.has_key('value'):
        return data['value']
    else:
        return None
Example #15
0
def main():            
    # initialize WIT.AI
    wit.init()

    wit.voice_query_start(WIT_AI_KEY)

    time.sleep(3)

    response = wit.voice_query_stop()
    wit.close()

    # case for the keyword voice command
    checkStartup(getIntent(response))
Example #16
0
def mainQuery():            
    # initialize WIT.AI
    wit.init()

    try:
        response = wit.voice_query_auto(WIT_AI_KEY)
        chooseIntent(response)
    except TypeError:
        main()
        wit.close()
        return

    wit.close()
def text_command(text):
	import wit
  	wit.init()

  	# Let's hack!
  	commandJSON = json.loads('{}'.format(wit.text_query(text, tok)))
  	wit.close()

	parsed = jsonparser.parseAlt(text,commandJSON)

	#if confidence is low
	if parsed[1] < .5:
		take_command()
	else:
		verify(parsed)
Example #18
0
    def run(self, text, application=None):
        if not application and self._default_application:
            app = self._default_application
        elif application:
            app = application
        else:
            raise Exception('Unknown application: %s' % application)

        access_token = self._applications.get(app, None)
        if not access_token:
            raise Exception('Missing API key for application %s' % application)

        wit.init()
        response = wit.text_query(text, access_token)
        wit.close()

        return json.loads(response)
Example #19
0
def main(interval=2):
	i=0
	total_fucks=0
	while i<interval:
		access_token = '5OOPLQECDO32JWXIAN5TAPE7JZ7J4UHX'
		wit.init()
		response = wit.voice_query_auto(access_token)
		parse_for_fucks = json.loads(response)



		
		total_fucks = total_fucks +count_fucks(parse_for_fucks)

		wit.close()
		i = i + 1

	return total_fucks
Example #20
0
	def close_connection(self):
		wit.close()
Example #21
0
import wit

if __name__ == "__main__":
    wit.init()
    response = wit.text_query("turn on the lights in the kitchen",
                              "ACCESS_TOKEN")
    print("Response: {}".format(response))
    wit.close()
Example #22
0
    def activeListenToAllOptions(self, THRESHOLD=None, LISTEN=True,
                                 MUSIC=False):
        """
            Records until a second of silence or times out after 12 seconds
            Returns a list of the matching options or None
        """

        RATE = 16000
        CHUNK = 1024
        LISTEN_TIME = 12

        # check if no threshold provided
        if THRESHOLD is None:
            THRESHOLD = self.fetchThreshold()
        self._logger.warning("playing hi")
        self.speaker.play(jasperpath.data('audio', 'beep_hi.wav'))

        # prepare recording stream
        #stream = self._audio.open(format=pyaudio.paInt16,
        #                          channels=1,
        #                          rate=RATE,
        #                          input=True,
        #                          frames_per_buffer=CHUNK)
	#
	#       frames = []
        # increasing the range # results in longer pause after command
        # generation
        #lastN = [THRESHOLD * 1.2 for i in range(30)]

        #for i in range(0, RATE / CHUNK * LISTEN_TIME):

        #    data = stream.read(CHUNK)
        #    frames.append(data)
        #    score = self.getScore(data)
	#
        #    lastN.pop(0)
        #    lastN.append(score)
	#
        #    average = sum(lastN) / float(len(lastN))
	
            # TODO: 0.8 should not be a MAGIC NUMBER!
        #    if average < THRESHOLD * 0.8:
        #        break
	wit.init()
	response = wit.voice_query_auto(self.token)
	wit.close()

        self.speaker.play(jasperpath.data('audio', 'beep_lo.wav'))
	self._logger.warning("playing lo")

        # save the audio data
        #stream.stop_stream()
        #stream.close()

        #with tempfile.SpooledTemporaryFile(mode='w+b') as f:
        #    wav_fp = wave.open(f, 'wb')
        #    wav_fp.setnchannels(1)
        #    wav_fp.setsampwidth(pyaudio.get_sample_size(pyaudio.paInt16))
        #    wav_fp.setframerate(RATE)
        #    wav_fp.writeframes(''.join(frames))
        #    wav_fp.close()
        #    f.seek(0)	
	#return json.dumps(self.active_stt_engine.transcribe(f))
	return response
Example #23
0
def cleanup_wit():
	wit.close()
Example #24
0
def shutdown():
  wit.close()
Example #25
0
    Przod = "Przod"
    Tyl = "Tyl"
    Prawo = "Prawo"
    Lewo = "Lewo"
    Szybciej = "Szybciej"
    Wolniej  = "Wolniej"
    Stop = "Stop"
    PokazKolory = "PokazKolory"
    i = 0


    while not rospy.is_shutdown(): 
        
    coRob(Tyl)
    time.sleep(1.5)
wit.close()



"""
    coRob(Tyl)
    coRob(Tyl)
    coRob(Tyl)
    coRob(Tyl)
    coRob(Tyl)
    time.sleep(1.5)
    coRob(Lewo)
    time.sleep(1.5)
    coRob(Przod)
    coRob(Przod)
    coRob(Przod)
def fermer_programme(signal, frame):
    parole("Fermeture programme au revoir a bientot")
    wit.close()
    sys.exit(0)
Example #27
0
def shutdown():
    wit.close()
def fermer_programme(signal, frame):
    parole("Fermeture programme au revoir a bientot")
    wit.close()
    sys.exit(0)
Example #29
0
def wit_function(access_token, string):
    wit.init()
    response = json.loads(wit.text_query(string, access_token))
    wit.close()

    return response['outcomes'][0]
Example #30
0
def test_wit():
	wit.init()
	# response = wit.text_query('play music', wit_access_token)
	response = wit.voice_query_auto(wit_access_token)
	print('Response: {}'.format(response))
	wit.close()