def preprocess_transcript(response):
    global conversation_over
    if "Result" in response['AllResults'][0]:
        print(response['AllResults'][0]['Result'])
        if "move_motor" in response['AllResults'][0]['Result']:
            print("MOVING ROTOR HERE")
            rotor_move_func()
        if "end_convo" in response['AllResults'][0]['Result']:
            print("ITS OVER")
            conversation_over = True
        if 'silent_response' in response['AllResults'][0]['Result']:
            print("QUIET TIME")
            print(response['AllResults'][0]['Result']["silent_response"])
            tclient = houndify.TextHoundClient(clientId, clientKey,
                                               "test_user", requestInfo)
            rep = tclient.query(
                user_id +
                response['AllResults'][0]['Result']["silent_response"] +
                response['AllResults'][0]["SpokenResponse"])
            print("LMFAO")
            if "Result" in rep['AllResults'][0]:
                print(rep['AllResults'][0]['Result'])
                if "move_motor" in rep['AllResults'][0]['Result']:
                    print("MOVING ROTOR HERE")
                    rotor_move_func()
                if "end_convo" in rep['AllResults'][0]['Result']:
                    print("ITS OVER")
                    conversation_over = True
            #if "AllResults" in rep:
            response = rep
    say_aloud(response)
Beispiel #2
0
def searchresults():
    client = houndify.TextHoundClient(clientId, clientKey, userId)
    response = client.query(request.form.get("query"))
    listresults = response["AllResults"]
    dictresults = listresults[0]
    dictresults = dictresults["HTMLData"]
    stringResults = dictresults["LargeScreenHTML"]
    return render_template("results.html", htmlcode=stringResults)
Beispiel #3
0
    def __hound_action(self, speech=None):
         if speech is not None:
            clientId = "" #get client id from houndify
            clientKey = "" #insert client key
            userId = "test_user"
            requestInfo = {
              "Latitude": 18.5679, 
              "Longitude": 73.9143
            }

            client = houndify.TextHoundClient(clientId, clientKey, userId, requestInfo)
            response = client.query(speech)
            #conversationState = response["AllResults"][0]["ConversationState"]
            #client.setConversationState(conversationState)
            command = response["AllResults"][0]["WrittenResponseLong"]
            
           
            spoken = response["AllResults"][0]["SpokenResponseLong"]
             
            name = []
            rating = []
            avgcost = []    
            url = []  
            print 
            if "Template" in response["AllResults"][0]["ViewType"]:
                if len(response["AllResults"][0]["TemplateData"]["Items"]) > 8:
                    for item in range(0,10):
                        if 'Title' in response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]:
                            name.append(response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]["Title"])
                        if 'Subtitle' in response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]:
                            rating.append(response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]["Subtitle"])
                        if 'BodyText' in response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]:    
                            avgcost.append(response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]["BodyText"])
                        if 'URL' in response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]["Image"]:    
                            url.append(response["AllResults"][0]["TemplateData"]["Items"][item]["TemplateData"]["Image"][ "URL"])


                    hound_data = {"title": name, 'subtitle': rating, "details": avgcost, "url": url, "command": command}
                    requests.post("http://localhost:8080/other", data=json.dumps(hound_data))
                else:   
                    requests.post("http://localhost:8080/other", data=json.dumps(command))
                    

            #requests.get("http://localhost:8080/statement?text=%s" % text)
            #self.speech.synthesize_text(text)
            
            else:
                requests.post("http://localhost:8080/other", data=json.dumps(command))

            self.speech.synthesize_text(spoken)
            self.decide_action()
def start_chat():  # call this when button pressed
    global user_id, conversation_over
    tclient = houndify.TextHoundClient(clientId, clientKey, "test_user",
                                       requestInfo)
    greeting = tclient.query("000nouser_say_hi")
    say_aloud(greeting)
    user_id = str(card_scan_func())
    # TODO ADD TIME OUT HERE
    welcome = tclient.query(user_id + "welcome_user_specific")
    say_aloud(welcome)

    while (conversation_over != True):
        listen_for_response(False, user_id)

    goodbye = tclient.query(user_id + "bye_user_specific")
    conversation_over = False
    say_aloud(goodbye)
Beispiel #5
0
def getHoundifyTextFlag(textIn, ID, Key):

	QUERY = textIn

	requestInfo = {
	  ## We are at MBRDNA headquarters!
	  'Latitude': 37.386431, 
	  'Longitude': -122.034832
	}

	# Set the Houndify Client
	client = houndify.TextHoundClient(ID, Key, "test_user", requestInfo)

	# Send the text query and receive response from Houndify custom application
	response = client.query(QUERY)
	responseDecoded = response.decode("utf-8")
	responseJSON = json.loads(responseDecoded)

	return responseJSON
Beispiel #6
0
if __name__ == '__main__':
    if len(sys.argv) < 4:
        print "Usage: %s <CLIENT_ID> <CLIENT_KEY> '<QUERY>'" % sys.argv[0]
        sys.exit(0)

    CLIENT_ID = sys.argv[1]
    CLIENT_KEY = sys.argv[2]
    query = sys.argv[3]

    requestInfo = {
        ## Pretend we're at SoundHound HQ.  Set other fields as appropriate
        'Latitude': 37.388309,
        'Longitude': -121.973968
    }

    client = houndify.TextHoundClient(CLIENT_ID, CLIENT_KEY, "test_user",
                                      requestInfo)

    ## Uncomment the lines below to see an example of using a custom
    ## grammar for matching.  Use the file 'turnthelightson.wav' to try it.
    # clientMatches = [ {
    #   "Expression" : '([1/100 ("can"|"could"|"will"|"would")."you"].[1/10 "please"].("turn"|"switch"|(1/100 "flip"))."on".["the"].("light"|"lights").[1/20 "for"."me"].[1/20 "please"])|([1/100 ("can"|"could"|"will"|"would")."you"].[1/10 "please"].[100 ("turn"|"switch"|(1/100 "flip"))].["the"].("light"|"lights")."on".[1/20 "for"."me"].[1/20 "please"])|((("i".("want"|"like"))|((("i".["would"])|("i\'d")).("like"|"want"))).["the"].("light"|"lights").["turned"|"switched"|("to"."go")|(1/100"flipped")]."on".[1/20"please"])"',
    #   "Result" : { "Intent" : "TURN_LIGHT_ON" },
    #   "SpokenResponse" : "Ok, I\'m turning the lights on.",
    #   "SpokenResponseLong" : "Ok, I\'m turning the lights on.",
    #   "WrittenResponse" : "Ok, I\'m turning the lights on.",
    #   "WrittenResponseLong" : "Ok, I\'m turning the lights on."
    # } ]
    # client.setHoundRequestInfo('ClientMatches', clientMatches)

    response = client.query(query)
    print response
Beispiel #7
0
#!/usr/bin/env python
import houndify
import sys
from config_contents import *
import time
import os

client = houndify.TextHoundClient("test_user")
print "Enter the query : "
query = raw_input()

start = time.time()
response = client.query(query)
stop = time.time()

print "Response : ", response['AllResults'][0]['WrittenResponse']
print "Time : {} \n".format(stop - start)
cmd_line = 'python3 tts.py "{}"'.format(
    response['AllResults'][0]['SpokenResponseLong'])
print cmd_line

os.system(cmd_line)

# for key in response.keys():
#     print key," :  ", response[key]