Esempio n. 1
0
def checkReminders(verbose=False):

    from timeParsing import getTimeVec
    from determineFunction import updateContext
    from emotions import getFace

    rotateCircle(index=2, angle=30)

    #print "LOADING"
    REMINDERS = load(DATA_DIR + "reminders.txt", LPC=1)
    REMINDERS = [s[0] for s in REMINDERS]
    #print "LOADING... DONE"

    #nowTime = getTimeVec("now")
    updateReminders = False

    NowTime = datetime.datetime.now()
    NowTotalSecs = (NowTime - datetime.datetime(1970, 1, 1)).total_seconds()

    dueInFuture = 0  # track how many are due in future

    textStr = ""

    for i in range(len(REMINDERS)):
        item = REMINDERS[i]

        if item[1] != [] and item[2] != True:

            # see if the time has passes:

            NoteTime = datetime.datetime(year=item[1][0],
                                         month=item[1][1],
                                         day=item[1][2],
                                         hour=item[1][3],
                                         minute=item[1][4],
                                         second=item[1][5])
            NoteTotalSecs = (NoteTime -
                             datetime.datetime(1970, 1, 1)).total_seconds()

            timePassed = (NowTotalSecs >= NoteTotalSecs)

            if not timePassed:
                dueInFuture += 1
                #say("Future: "+item[0], more=True, speak=setting("SPEAK"), moodUpdate=True)

            if timePassed:

                noteTD = toDict(item[1])

                diffStr = timeDiff(noteTD)

                rStr = "Reminder: " + item[0] + " (due " + diffStr + ")"

                say(rStr,
                    more=(not setting('SEND_TEXT')),
                    speak=setting("SPEAK"),
                    moodUpdate=True)
                #say("Reminder: "+item[0], more=True, speak=setting("SPEAK"), moodUpdate=True)

                REMINDERS[i] = (item[0], item[1], True)
                updateContext(inStr=item[0])
                updateReminders = True

                textStr = textStr + " <" + item[0] + ">"

    if setting('SEND_TEXT') and not textStr == "":
        face = getFace(GLOB['MOOD'])
        moodStr = ""
        if face[0] == "":
            moodStr = "(" + getFace(
                GLOB['MOOD'])[2] + ")"  # use the description
        else:
            moodStr = getFace(GLOB['MOOD'])[0]  # use the emoticon

        textStr = setting(
            "YOUR_NAME") + " " + moodStr + " REMINDER: " + textStr
        say("Sending text...", more=True, speak=False, moodUpdate=True)
        sendText(textStr)

    if verbose and not updateReminders:
        dueStr = "(" + ('%s' % dueInFuture) + " due in future)"
        say("No new reminders. " + dueStr,
            more=False,
            speak=setting("SPEAK"),
            moodUpdate=True)
        updateContext(inStr="reminders")
        return "new prompt"

    # want to overwrite ingestions file
    if updateReminders:
        f = open(DATA_DIR + 'reminders.txt', 'w')
        for item in REMINDERS:
            userStr = k.cleanWord(item[0], cleanType=1)
            f.write("\'%s\', %s, %s\n" % (userStr, item[1], item[2]))
        f.close()

    return "no prompt"
Esempio n. 2
0
def say(inStr,
        more=True,
        speak=False,
        moodUpdate=True,
        fromAuto=False,
        describeFace=False,
        location="history",
        PAUSE_SEND=False):
    from emotions import getFace, getMood, updateMood

    MOOD = GLOB['MOOD']
    PREVMOOD = GLOB['PREVMOOD']

    toSay = inStr
    if toSay == "" and not GLOB['onQuery']:
        return

    if moodUpdate:
        newMood = getMood(toSay)
        GLOB['PREVMOOD'] = copy.deepcopy(GLOB['MOOD'])

        # more confident -> more weight on what he says
        mWeight = 0.5 * (1.0 + GLOB['MOOD'][2])
        mWeight = [mWeight] * 3 + [0] * (GLOB['MOODDIM'] - 3)

        GLOB['MOOD'] = updateMood(newMood, weight=mWeight)

    # calculate mood string
    face = getFace(MOOD)
    moodStr = ""
    if face[0] == "":
        moodStr = "(" + getFace(MOOD)[2] + ")"  # use the description
    else:
        moodStr = getFace(MOOD)[0]  # use the emoticon

    if describeFace:
        moodStr = moodStr + " - (" + face[2] + ")"

    #print ("\n["+setting("YOUR_NAME")+" "+moodStr+"] "),
    setFace(face=face[2])
    #tkHistCat("["+setting("YOUR_NAME")+" "+moodStr+"] ")

    toWriteStr = ""

    if location != "top":
        #writeToLocation("["+setting("YOUR_NAME")+"] ", location)
        toWriteStr += "[" + setting("YOUR_NAME") + "] "

    if speak == True:
        pitchMod = int(30.0 * MOOD[0])  # happiness
        speedMod = int(50.0 * MOOD[1])  # excitement
        if setting("YOUR_GENDER") == "female":
            speed = 190 + speedMod  #arousal value
            pitch = 70 + pitchMod  #valence value
            voice = "-a 20 -v english_rp+f5 -p " + '%s' % pitch + " -s " + '%s' % speed
        else:
            speed = 190 + speedMod  #arousal value
            pitch = 30 + pitchMod  #valence value
            voice = "-a 20 -v english_rp+m5 -p " + '%s' % pitch + " -s " + '%s' % speed

        cmd = "echo \"" + inStr + "\" > toSay.txt; espeak " + voice + " -f toSay.txt >/dev/null 2>&1 &"
        subprocess.call(cmd, shell=True)

    if setting("SLOW_TYPE"):
        slowType(toSay)
    else:
        #writeToLocation(toSay+'\n', location)
        toWriteStr += toSay + '\n'
        writeToLocation(toWriteStr, location, PAUSE_SEND=PAUSE_SEND)

    rotateCircle(index=1, angle=30)
Esempio n. 3
0
def say(inStr, more=True, speak=False, moodUpdate=True, fromAuto=False, describeFace=False, location="history", PAUSE_SEND=False):
	from emotions import getFace, getMood, updateMood

	MOOD = GLOB['MOOD']
	PREVMOOD = GLOB['PREVMOOD']

	toSay=inStr
	if toSay == "" and not GLOB['onQuery']:
		return
	
	if moodUpdate:
		newMood = getMood(toSay)
		GLOB['PREVMOOD']=copy.deepcopy(GLOB['MOOD'])

		# more confident -> more weight on what he says
		mWeight = 0.5*(1.0 + GLOB['MOOD'][2])
		mWeight = [mWeight]*3+[0]*(GLOB['MOODDIM']-3)

		GLOB['MOOD']=updateMood(newMood, weight= mWeight)

	# calculate mood string
	face=getFace(MOOD)
	moodStr=""
	if face[0]=="":
		moodStr="("+getFace(MOOD)[2]+")" # use the description
	else: 		
		moodStr=getFace(MOOD)[0] # use the emoticon

	if describeFace:
		moodStr = moodStr+" - ("+face[2]+")"

	#print ("\n["+setting("YOUR_NAME")+" "+moodStr+"] "),
	setFace(face=face[2])
	#tkHistCat("["+setting("YOUR_NAME")+" "+moodStr+"] ")

	toWriteStr=""

	if location != "top":
		#writeToLocation("["+setting("YOUR_NAME")+"] ", location)
		toWriteStr+="["+setting("YOUR_NAME")+"] "

	if speak == True:
		pitchMod=int(30.0*MOOD[0]) # happiness
		speedMod=int(50.0*MOOD[1]) # excitement
		if setting("YOUR_GENDER") == "female":
			speed=190 + speedMod #arousal value
			pitch=70 +pitchMod #valence value
			voice = "-a 20 -v english_rp+f5 -p "+'%s'%pitch+" -s "+'%s'%speed
		else:
			speed=190 + speedMod #arousal value
			pitch=30 +pitchMod #valence value
			voice = "-a 20 -v english_rp+m5 -p "+'%s'%pitch+" -s "+'%s'%speed
		
		cmd = "echo \""+inStr+"\" > toSay.txt; espeak "+voice+" -f toSay.txt >/dev/null 2>&1 &"
		subprocess.call(cmd, shell=True)

	if setting("SLOW_TYPE"): 
		slowType(toSay)
	else: 
		#writeToLocation(toSay+'\n', location)
		toWriteStr += toSay+'\n'
		writeToLocation(toWriteStr, location, PAUSE_SEND=PAUSE_SEND)

	rotateCircle(index=1, angle=30)
Esempio n. 4
0
def checkReminders(verbose=False):

	from timeParsing import getTimeVec
	from determineFunction import updateContext
	from emotions import getFace

	rotateCircle(index=2, angle=30)

	#print "LOADING"
	REMINDERS=load(DATA_DIR+"reminders.txt", LPC=1)
	REMINDERS=[s[0] for s in REMINDERS]
	#print "LOADING... DONE"


	#nowTime = getTimeVec("now")
	updateReminders=False

	
	NowTime = datetime.datetime.now()
	NowTotalSecs = (NowTime-datetime.datetime(1970,1,1)).total_seconds()

	dueInFuture=0 # track how many are due in future

	textStr=""

	for i in range(len(REMINDERS)):
		item = REMINDERS[i]

		if item[1] != [] and item[2] != True:

			# see if the time has passes:
			
			NoteTime = datetime.datetime(year = item[1][0], month=item[1][1], day=item[1][2], hour=item[1][3], minute=item[1][4], second=item[1][5])
			NoteTotalSecs = (NoteTime-datetime.datetime(1970,1,1)).total_seconds()

			timePassed = (NowTotalSecs >= NoteTotalSecs)
		
			if not timePassed:
				dueInFuture += 1
				#say("Future: "+item[0], more=True, speak=setting("SPEAK"), moodUpdate=True)

			if timePassed:
		
				noteTD = toDict(item[1])
				
				diffStr = timeDiff(noteTD)
		
				rStr = "Reminder: "+item[0]+" (due "+diffStr+")"
		
				say(rStr, more=(not setting('SEND_TEXT')), speak=setting("SPEAK"), moodUpdate=True)
				#say("Reminder: "+item[0], more=True, speak=setting("SPEAK"), moodUpdate=True)

				REMINDERS[i] = (item[0], item[1], True)
				updateContext(inStr=item[0])
				updateReminders=True

				textStr=textStr+" <"+item[0]+">"



				
				
	

	if setting('SEND_TEXT') and not textStr == "":
		face=getFace(GLOB['MOOD'])
		moodStr=""
		if face[0]=="":
			moodStr="("+getFace(GLOB['MOOD'])[2]+")" # use the description
		else:
			moodStr=getFace(GLOB['MOOD'])[0] # use the emoticon
		
		textStr=setting("YOUR_NAME")+" "+moodStr+" REMINDER: "+textStr
		say("Sending text...", more=True, speak=False, moodUpdate=True)
		sendText(textStr)

	if verbose and not updateReminders:
		dueStr = "("+('%s'%dueInFuture)+" due in future)"
		say("No new reminders. "+dueStr, more=False, speak=setting("SPEAK"), moodUpdate=True)
		updateContext(inStr="reminders")
		return "new prompt"

	# want to overwrite ingestions file
	if updateReminders:
		f = open(DATA_DIR+'reminders.txt', 'w')
		for item in REMINDERS:
			userStr =  k.cleanWord(item[0], cleanType=1)
			f.write("\'%s\', %s, %s\n" % (userStr, item[1], item[2]))
		f.close()

	return "no prompt"