Example #1
0
def check_suggested_members_voice(member_name):
    if member_name in sugg_users:
        if (len(sugg_users[member_name]) > 1):
            did_you_mean = "Select which user you want by number:"
            speech.speech_play_test(did_you_mean)
            count = 1
            output = did_you_mean + "\n"
            for suggested_member in sugg_users[member_name]:
                output += count + ": " + suggested_member[0] + "\n"
                output += "   " + suggested_member[1] + "\n"
            return sugg_users[member_name][num - 1][1]
        else:
            return sugg_users[member_name][0][1]
    else:
        return 0
Example #2
0
def check_suggested_members_voice(member_name):
    if member_name in sugg_users:
        if (len(sugg_users[member_name])>1):
            did_you_mean = "Select which user you want by number:"
            speech.speech_play_test(did_you_mean)
            count =1
            output = did_you_mean + "\n"
            for suggested_member in sugg_users[member_name]:
                output += count + ": "+ suggested_member[0] + "\n"
                output += "   " + suggested_member[1] + "\n"
            return sugg_users[member_name][num-1][1]
        else:
            return sugg_users[member_name][0][1]
    else:
        return 0
Example #3
0
def find_members_voice(user, member_input):
    finding_members = "Finding members"
    speech.speech_play_test(finding_members)
    final_member_list = []
    legit_token = "Bearer " + developer_tokens[user]
    search_url = "https://api.ciscospark.com/v1/people"
    for member in member_input:
        headers = {
            'Authorization': legit_token
        }
        params = {
            'displayName': member
        }
        matching_members = requests.get(search_url, headers=headers, params=params).json()
        if len(matching_members['items']) == 0:
            no_members = "No matching members for " + member
            speech.speech_play_test(member)
        elif len(matching_members['items']) == 1:
            final_member_list.append(matching_members['items'][0]['email'])
        elif len(matching_members['items']) > 5:
            found_member = check_suggested_members_voice((member.split())[0])
            if found_member == 0:
                specify_member = "Please specify " + member + "a bit more"
                speech.speech_play_test(member)
            else:
                final_member_list.append(found_member)
        else:
            for matched_member in matching_members['items']:
                print count + ": "+ matched_member
            num = raw_input("Respond with a number: ")
    return final_member_list
Example #4
0
def find_members_voice(user, member_input):
    finding_members = "Finding members"
    speech.speech_play_test(finding_members)
    final_member_list = []
    legit_token = "Bearer " + developer_tokens[user]
    search_url = "https://api.ciscospark.com/v1/people"
    for member in member_input:
        headers = {'Authorization': legit_token}
        params = {'displayName': member}
        matching_members = requests.get(search_url,
                                        headers=headers,
                                        params=params).json()
        if len(matching_members['items']) == 0:
            no_members = "No matching members for " + member
            speech.speech_play_test(member)
        elif len(matching_members['items']) == 1:
            final_member_list.append(matching_members['items'][0]['email'])
        elif len(matching_members['items']) > 5:
            found_member = check_suggested_members_voice((member.split())[0])
            if found_member == 0:
                specify_member = "Please specify " + member + "a bit more"
                speech.speech_play_test(member)
            else:
                final_member_list.append(found_member)
        else:
            for matched_member in matching_members['items']:
                print count + ": " + matched_member
            num = raw_input("Respond with a number: ")
    return final_member_list
Example #5
0
def process(user_input, text, top, user='******'):
    for randomkey in random_keywords:
        if randomkey == user_input.lower():
            if randomkey == 'hello spark' or randomkey == 'hi spark':
                text.set(user_input)
                top.update_idletasks()
                speech.speech_play_test('hello Charu')
            elif randomkey == 'how are you':
                speech.speech_play_test("I'm doing well")
    output = None
    try:
        output = translate_to_commands(user, user_input.lower().split())
    except Exception as e:
        print 'Not summarize or transcript'
    try:
        if output:
            output = output.encode('ascii', 'ignore')
            with open('summary.txt', 'w') as f:
                f.write(output)
            speech.speech_play_test("Ok, wrote summary to summary.txt")
    except Exception as e:
        print output
 
    for words in create_room_keywords:
        if words in user_input.lower():
            room_name_true = False
            room_name = check_name_room_true(user_input)
            added_members_true = False
            added_members = check_add_members_true(user_input)
            if room_name:
                room_name_true = True
            if added_members:
                added_members_true = True
            create_room_dialog(room_name_true, added_members_true, text, top, room_name, added_members)
            break
    for words in schedule_meeting_keywords:
        if words in user_input.lower():
            return schedule_meeting_dialog(text, top)
Example #6
0
 def respond(self, s):
     self.__update('Sparky: ' + s + '\n\n')
     self.top.update_idletasks()
     speech.speech_play_test(str)
Example #7
0
def schedule_meeting_dialog(text, top, attendees=[]):
    users = [("Charu Dwivedi", "*****@*****.**")]
    ask_when_meeting ="When would you like to schedule the meeting?"
    speech.speech_play_test(ask_when_meeting)
    when_resp = ""
    while not when_resp:
        when_resp = speech.speechrec()
    text.set(when_resp)
    start = get_date(when_resp)
    if start is None:
        start = '2016-08-10T13:00:00'
    end = start[:11] + "%02d" % ((int(start[11:13])+1) % 24) + start[13:]
    print start
    print end
    ask_add_members = "Would you like to add members?"
    speech.speech_play_test(ask_add_members)
    resp = ""
    while not resp:
        resp = speech.speechrec()
    text.set(resp)

    if 'n' in resp.lower():
        no_response = "Ok, meeting has been created"
        ms.schedule(users, start, end)
        speech.speech_play_test(no_response)
    if 'y' in resp.lower():
        yes_response = "Ok, please name your members"
        speech.speech_play_test(yes_response)
        new_members = ''
        while not new_members:
            new_members = speech.speechrec()
        text.set(new_members)
        new_members_array = new_members.split()
        if 'and' in new_members_array:
            new_members_array.remove('and')
        print new_members_array
        new_member_email = uvb.find_members_voice('charu', new_members_array)
        for emails in new_member_email:
            users.append(("filler", emails))
        print new_member_email
        added_members_response = "Members have ben added to meeting"
        speech.speech_play_test(added_members_response)
        ms.schedule(users, start, end)
        speech.speech_play_test("Created meeting.")
        return "Ok, created meeting."
Example #8
0
def create_room_dialog(room_name_added, room_members_added, text, top, room_name="", room_members=[]):
    room_id = ""
    if room_name_added:
        room_id = utils.make_room('charu', room_name)
    else:
        name_prompt = "What would you like to name your room?"
        speech.speech_play_test(name_prompt)
        while not room_name:
            room_name = speech.speechrec()
        text.set(room_name)
        top.update_idletasks()
        room_id = utils.make_room('charu', room_name)
    if room_members_added:
        new_member_email = uvb.find_members_voice('charu', room_members)
        utils.add_members_with_room_id('charu', room_id, new_member_email)
        added_response = "Ok, " + room_name + "has been created with members"
        speech.speech_play_test(added_response)
    else:
        ask_add_members = "Would you like to add members?"
        speech.speech_play_test(ask_add_members)
        resp = ""
        while not resp:
            resp = speech.speechrec()
        text.set(resp)
        top.update_idletasks()
        if 'n' in resp.lower():
            no_response = "Ok, " + room_name + "has been created"
            speech.speech_play_test(no_response)
        if 'y' in resp.lower():
            yes_response = "Ok, please name your members"
            speech.speech_play_test(yes_response)
            new_members = ''
            while not new_members:
                new_members = speech.speechrec()
            text.set(new_members)
            top.update_idletasks()
            new_members_array = new_members.split()
            if 'and' in new_members_array:
                new_members_array.remove('and')
            print new_members_array
            new_member_email = uvb.find_members_voice('charu', new_members_array)
            print new_member_email
            utils.add_members_with_room_id('charu', room_id, new_member_email)
            added_members_response = "Members have ben added to " + room_name
            speech.speech_play_test(added_members_response)