Esempio n. 1
0
def next_state():
    global PHASE, CURRENT_TIME, LIMIT,days, sound_str, YOU_SELECTED_WAV, picked_day,picked_hour,picked_minutes

    # Transition to Hour phase
    if PHASE == 0:
        # Get and combine selected day to announce to user
        day = day_path + days[CURRENT_TIME] + "_f.wav"
        sound.combine_wav_files(sound_str, YOU_SELECTED_WAV,day,nav_path+"Set_hour_f.wav")
        picked_day = day
        PHASE = 1
        CURRENT_TIME = 0
        LIMIT = 24
        sound.Play(sound_str)
    # Transition to Minute phase
    elif PHASE == 1:
        # Get and combine selected hour and announce to user
        selected_hour = get_hour(CURRENT_TIME)
        sound.combine_wav_files(sound_str,YOU_SELECTED_WAV,selected_hour,nav_path + "Set_minutes_f.wav")
        picked_hour = CURRENT_TIME
        PHASE = 2
        CURRENT_TIME = 0
        LIMIT = 60
        sound.Play(sound_str)
    # Transition to End phase
    elif PHASE == 2:
        selected_minutes = get_minutes(CURRENT_TIME)
        picked_minutes = selected_minutes
        get_final_time(picked_day,picked_hour,picked_minutes)
        PHASE = 3
        return 1
    return 0
Esempio n. 2
0
 def setMin(self, select, k, j):
     if (select == -1):
         select = 59
         j = 58
         k = 0
     elif (select == self.min_limit):
         select = 0
         k = 1
         j = 59
     if (k == self.min_limit):
         k = 0
     if (j == -1):
         j = 59
     self.current_min = select
     # Need to check if single digit because wav file require "0" in front of number
     if (select < 10):
         self.selection["text"] = str(select)
         self.k_index["text"] = str(k)
         self.j_index["text"] = str(j)
         sound.combine_wav_files(self.time_sound,
                                 num_path + "0" + str(select) + "_f.wav")
         sound.Play(self.time_sound)
         self.min_selection = "0" + str(
             self.current_min)  # Set final min_selection
     elif (select >= 10):
         self.selection["text"] = str(select)
         self.k_index["text"] = str(k)
         self.j_index["text"] = str(j)
         sound.combine_wav_files(self.time_sound,
                                 num_path + str(select) + "_f.wav")
         sound.Play(self.time_sound)
         self.min_selection = str(self.current_min)
 def play_current_minute(self):
     # Minute selected is zero, play 'oh oh'
     if (self._minute == 0):
         sound.combine_wav_files(self.TMP_FILE_WAV, self.OH_WAV, self.OH_WAV)
         sound.Play(self.TMP_FILE_WAV)
     # Minute selected is 1-9, play 'oh' followed by the minute
     elif ((self._minute * 5) <= 9):
         sound.combine_wav_files(self.TMP_FILE_WAV, self.OH_WAV, self.TIME_WAV_DIR + \
             str("{:02}".format(self._minute * 5)) + "_f.wav")
         sound.Play(self.TMP_FILE_WAV)
     # Minute selected is 11-59, simply play corresponding file
     else:
         sound.Play(self.TIME_WAV_DIR + str(self._minute * 5) + "_f.wav")
def play_current_minute(minute):
    # Minute selected is zero, play 'oh oh'
    if (minute == 0):
        sound.combine_wav_files(TMP_FILE_WAV, OH_WAV, OH_WAV)
        sound.Play(TMP_FILE_WAV)
    # Minute selected is 1-9, play 'oh' followed by the minute
    elif (minute >= 1 and minute <= 9):
        sound.combine_wav_files(TMP_FILE_WAV, OH_WAV,
                                TIME_WAV_DIR + str(minute) + ".wav")
        sound.Play(TMP_FILE_WAV)
    # Minute selected is 11-59, simply play corresponding file
    elif (minute >= 10 and minute <= 59):
        sound.Play(TIME_WAV_DIR + str(minute) + ".wav")
Esempio n. 5
0
 def select(self, event):
     if self.location[0] == 0:
         if self.location[1] == 3:
             self.myRoot.destroy()
         self.hl(self.UIlist[self.location[0]][self.location[1]])
         self.memory[0] = self.location
         self.location = self.memory[self.location[1] + 1]
         self.mark(self.UIlist[self.location[0]][self.location[1]])
         if self.location[0] == 2:
             if self.location[1] < 12:
                 sound.combine_wav_files(self.specialsounds[0],
                                         self.sounds[2][self.location[1]],
                                         self.specialsounds[2])
                 sound.Play(self.specialsounds[0])
             else:
                 sound.combine_wav_files(self.specialsounds[0],
                                         self.sounds[2][self.location[1]],
                                         self.specialsounds[3])
                 sound.Play(self.specialsounds[0])
         else:
             sound.Play(self.sounds[self.location[0]][self.location[1]])
     else:
         self.hl(self.UIlist[self.location[0]][self.location[1]])
         self.memory[self.location[0]] = self.location
         selection = self.location
         self.location = self.memory[0]
         self.mark(self.UIlist[self.location[0]][self.location[1]])
         if selection[0] == 2:
             if selection[1] < 12:
                 sound.combine_wav_files(self.specialsounds[0],
                                         self.specialsounds[1],
                                         self.sounds[2][selection[1]],
                                         self.specialsounds[2],
                                         self.sounds[0][self.location[1]])
             else:
                 sound.combine_wav_files(self.specialsounds[0],
                                         self.specialsounds[1],
                                         self.sounds[2][selection[1]],
                                         self.specialsounds[3],
                                         self.sounds[0][self.location[1]])
             sound.Play(self.specialsounds[0])
         else:
             sound.combine_wav_files(
                 self.specialsounds[0], self.specialsounds[1],
                 self.sounds[selection[0]][selection[1]],
                 self.sounds[0][self.location[1]])
             sound.Play(self.specialsounds[0])
     self.update()
def play_help(state):
    if (state == 0):
        # User in weekday state, precede help message with 'Set day of week'
        sound.combine_wav_files(TMP_FILE_WAV, SET_WEEKDAY_WAV, HELP_WAV)
    elif (state == 1):
        # User in hour state, precede help message with 'Set hour'
        sound.combine_wav_files(TMP_FILE_WAV, SET_HOUR_WAV, HELP_WAV)
    elif (state == 2):
        # User in minute state, precede help message with 'Set minute'
        sound.combine_wav_files(TMP_FILE_WAV, SET_MINUTE, HELP_WAV)
    elif (state == 3):
        # User in AM/PM state, plays 'Set AM PM'
        sound.combine_wav_files(TMP_FILE_WAV, SET_AM_PM, HELP_WAV)
    else:
        # Otherwise, just play help message by itself
        sound.combine_wav_files(TMP_FILE_WAV, HELP_WAV)
    sound.Play(TMP_FILE_WAV)  # Play full help message
Esempio n. 7
0
 def backward(self, event):
     self.ll(self.UIlist[self.location[0]][self.location[1]])
     self.location[1] -= 1
     if self.location[1] == -1:
         self.location[1] = len(self.UIlist[self.location[0]]) - 1
     self.mark(self.UIlist[self.location[0]][self.location[1]])
     if self.location[0] == 2:
         if self.location[1] < 12:
             sound.combine_wav_files(self.specialsounds[0],
                                     self.sounds[2][self.location[1]],
                                     self.specialsounds[2])
             sound.Play(self.specialsounds[0])
         else:
             sound.combine_wav_files(self.specialsounds[0],
                                     self.sounds[2][self.location[1]],
                                     self.specialsounds[3])
             sound.Play(self.specialsounds[0])
     else:
         sound.Play(self.sounds[self.location[0]][self.location[1]])
Esempio n. 8
0
def verify_sound_filenames():
    sound.Play(PRESS_AGAIN_TO_QUIT_WAV)
    sound.Play(EXITING_PROGRAM_WAV)
    sound.Play(YOU_SELECTED_WAV)
    for x in range(60):
        sound.Play(NUMBERS_WAV[x])
    for x in range(7):
        sound.Play(WEEKDAYS_WAV[x])
    sound.Play(SET_DAY_OF_WEEK_WAV)
    sound.Play(SET_HOUR_WAV)
    sound.Play(SET_MINUTES_WAV)
    sound.Play(OH_WAV)
    sound.Play(O_CLOCK_WAV)
    sound.Play(SET_DATE_AND_TIME_WAV)

    # First sound we want is a concatenation
    sound.combine_wav_files(TMP_FILE_WAV,
            SET_DATE_AND_TIME_WAV,
            SET_DAY_OF_WEEK_WAV,
            WEEKDAYS_WAV[0])
    sound.Play(TMP_FILE_WAV)
Esempio n. 9
0
def play_result_and_quit():
    #End of selection process, program will now repeat back all selections

    #Top of the hour, disregard minute
    if CURRENT_MINUTE == 0:
        sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                DAYS_WAV[CURRENT_DAY], HOURS_WAV[CURRENT_HOUR],
                                AMPM_WAV[CURRENT_AMPM])

    #Single digit minute, use OH_WAV
    elif CURRENT_MINUTE >= 1 and CURRENT_MINUTE < 10:
        sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                DAYS_WAV[CURRENT_DAY], HOURS_WAV[CURRENT_HOUR],
                                OH_WAV, MINUTES_WAV[CURRENT_MINUTE],
                                AMPM_WAV[CURRENT_AMPM])

    else:
        sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                DAYS_WAV[CURRENT_DAY], HOURS_WAV[CURRENT_HOUR],
                                MINUTES_WAV[CURRENT_MINUTE],
                                AMPM_WAV[CURRENT_AMPM])

    sound.Play(TMP_FILE_WAV)
    time.sleep(4.8)

    sound.Play(EXITING_PROGRAM_WAV)
    # A delay is needed so the sound gets played before quitting.
    time.sleep(EXITING_PROGRAM_WAV_DURATION)
    sound.cleanup()
Esempio n. 10
0
def introduce_stage(stage):
    if stage == 0:
        # Stage is 'Set Day of Week'
        sound.combine_wav_files(TMP_FILE_WAV,
            SET_DATE_AND_TIME_WAV,
            SET_DAY_OF_WEEK_WAV,
            WEEKDAYS_WAV[TIME_VAL[0]])
    elif stage == 1:
        # Stage is 'Set Hour'
        sound.combine_wav_files(TMP_FILE_WAV,
            SET_HOUR_WAV,
            NUMBERS_WAV[TIME_VAL[1]])
    elif stage == 2:
        # Stage is 'Set Minute'
        sound.combine_wav_files(TMP_FILE_WAV,
            SET_MINUTES_WAV,
            NUMBERS_WAV[TIME_VAL[2]])
    sound.Play(TMP_FILE_WAV)
Esempio n. 11
0
def play_complete_time(day, hour, minute, is_AM):
    # Checks which am/pm file to play; assigns to 'am.wav' or 'pm.wav'
    am_pm_wav = PM_WAV
    if is_AM:
        am_pm_wav = AM_WAV
    # If the minute is 0, play the hour followed by 'o clock'
    # For example: 'Thursday, 12 o clock PM'
    if (minute == 0):
        sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV, WEEKDAYS_WAV[day],\
                                TIME_WAV_DIR + str(hour) + ".wav", OH_CLOCK_WAV, am_pm_wav)
    # Else if the minute is 1-9, play 'oh' before the minute
    # For example: 'Thursday, 12 oh 5 PM'
    elif (minute >= 1 and minute <= 9):
        sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV, WEEKDAYS_WAV[day],\
                                TIME_WAV_DIR + str(hour) + ".wav", OH_WAV,\
                                TIME_WAV_DIR + str(minute) + ".wav", am_pm_wav)
    # Otherwise, play the corresponding numbered file (e.g. 34 plays '34.wav')
    else:
        sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV, WEEKDAYS_WAV[day],\
                                TIME_WAV_DIR + str(hour) + ".wav", TIME_WAV_DIR + str(minute) + ".wav",\
                                am_pm_wav)
    sound.Play(TMP_FILE_WAV)  # Play the complete time file
Esempio n. 12
0
 def play_complete_time(self):
     # Checks which am/pm file to play; assigns to 'am.wav' or 'pm.wav'
     am_pm_wav = self.PM_WAV
     if self._isAM:
         am_pm_wav = self.AM_WAV
     # If the minute is 0, play the hour followed by 'o clock'
     # For example: 'Thursday, 12 o clock PM'
     if (self._minute == 0):
         sound.combine_wav_files(self.TMP_FILE_WAV, self.YOU_SELECTED_WAV, self.WEEKDAYS_WAV[self._day],\
                                 self.TIME_WAV_DIR + str(self._hour + 1) + ".wav", self.OH_CLOCK_WAV, am_pm_wav)
     # Else if the minute is 1-9, play 'oh' before the minute
     # For example: 'Thursday, 12 oh 5 PM'
     elif ((self._minute * 5) <= 9):
         sound.combine_wav_files(self.TMP_FILE_WAV, self.YOU_SELECTED_WAV, self.WEEKDAYS_WAV[self._day],\
                                 self.TIME_WAV_DIR + str(self._hour + 1) + ".wav", self.OH_WAV,\
                                 self.TIME_WAV_DIR + str(self._minute * 5) + ".wav", am_pm_wav)
     # Otherwise, play the corresponding numbered file (e.g. 34 plays '34.wav')
     else:
         sound.combine_wav_files(self.TMP_FILE_WAV, self.YOU_SELECTED_WAV, self.WEEKDAYS_WAV[self._day],\
                                 self.TIME_WAV_DIR + str(self._hour + 1) + ".wav", self.TIME_WAV_DIR + str(self._minute * 5) + ".wav",\
                                 am_pm_wav)
     sound.Play(self.TMP_FILE_WAV)  # Play the complete time file
Esempio n. 13
0
def set_day():
    global CURRENT_TIME
    global CURRENT_DAY

    CURRENT_TIME = 0

    #Play the entering state audio
    sound.Play(SET_DAY_WAV)
    time.sleep(1.4)

    #Play current day selection
    sound.combine_wav_files(TMP_FILE_WAV, CURRENT_DAY_WAV,
                            DAYS_WAV[CURRENT_TIME])
    sound.Play(TMP_FILE_WAV)
    time.sleep(3)

    # Get the first keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the SELECT_KEY or the QUIT_KEY
    while True:

        # Respond to the user's input.
        if c == FORWARD_KEY:

            # Advance the time, looping back around to the start.
            CURRENT_TIME += 1
            if CURRENT_TIME == len(DAYS_WAV):
                CURRENT_TIME = 0

            # Concatenate two audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, DAYS_WAV[CURRENT_TIME])

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # Backward key
        if c == BACKWARD_KEY:

            # Move backward, looping around
            CURRENT_TIME -= 1
            if CURRENT_TIME == -1:
                CURRENT_TIME = len(DAYS_WAV) - 1

            # Concatenate two audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, DAYS_WAV[CURRENT_TIME])

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # Selects current time
        if c == SELECT_KEY:
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    DAYS_WAV[CURRENT_TIME])

            # Save the hour selection
            CURRENT_DAY = CURRENT_TIME

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)
            time.sleep(2.8)

            #Go to set hour state
            set_hour()
            break

        #User presses help key
        if c == HELP_KEY:

            # Notify the user that another HELP_KEY will play the help menu
            sound.Play(PRESS_AGAIN_FOR_HELP_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed HELP_KEY, play key options
            if c == HELP_KEY:
                sound.combine_wav_files(TMP_FILE_WAV, QUIT_WAV, HELP_WAV,
                                        DOWN_WAV, UP_WAV, SELECT_WAV)
                sound.Play(TMP_FILE_WAV)

        # User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break

        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 14
0
	def Right_Click(self, event):
		report_event(event)        ### (3)
		event_time =  str(event.time)
		self.trial_data.append([event_time, event.char])
		self.keyCount = self.keyCount + 1

		if self.MM_Label["background"] ==  self.mm_HC:
			if self.Set_Day["background"] ==  self.cursor_Col:
				self.Set_Day["background"] = "#ffffff"
				self.Set_Hour["background"] = self.cursor_Col
				sound.Play(MISC_PATH + "Set_hour_f.wav")
			elif self.Set_Hour["background"] ==  self.cursor_Col:
				self.Set_Hour["background"] = "#ffffff"
				self.Set_Min["background"] = self.cursor_Col
				sound.Play(MISC_PATH + "Set_minute_f.wav")
			elif self.Set_Min["background"] ==  self.cursor_Col:
				self.Set_Min["background"] = "#ffffff"
				self.Reset["background"] = self.cursor_Col
				sound.Play("extra_wav/reset.wav")
			elif self.Reset["background"] ==  self.cursor_Col:
				self.Reset["background"] = "#ffffff"
				self.Set_Day["background"] = self.cursor_Col
				sound.Play(MISC_PATH + "Set_day_f.wav")
		elif self.Set_Day["background"] == self.mm_HC:
				self.D_LEFT["text"] = self.D_MID["text"]
				self.D_MID["text"] = self.D_RIGHT["text"]
				if self.D_RIGHT["text"] == "Monday":
					self.D_RIGHT["text"] = "Tuesday"
					sound.Play(DAYS_PATH + "monday_f.wav")
				elif self.D_RIGHT["text"] == "Tuesday":
					self.D_RIGHT["text"] = "Wednesday"
					sound.Play(DAYS_PATH + "tuesday_f.wav")
				elif self.D_RIGHT["text"] == "Wednesday":
					self.D_RIGHT["text"] = "Thursday"
					sound.Play(DAYS_PATH + "wednesday_f.wav")
				elif self.D_RIGHT["text"] == "Thursday":
					self.D_RIGHT["text"] = "Friday"
					sound.Play(DAYS_PATH + "thursday_f.wav")
				elif self.D_RIGHT["text"] == "Friday":
					self.D_RIGHT["text"] = "Saturday"
					sound.Play(DAYS_PATH + "friday_f.wav")
				elif self.D_RIGHT["text"] == "Saturday":
					self.D_RIGHT["text"] = "Sunday"
					sound.Play(DAYS_PATH + "saturday_f.wav")
				elif self.D_RIGHT["text"] == "Sunday":
					self.D_RIGHT["text"] = "Monday"
					sound.Play(DAYS_PATH + "sunday_f.wav")

				# self.D_RIGHT.config(relief=tk.SUNKEN, background=self.cursor_Col)
				# self.D_RIGHT.after(150, lambda: self.D_RIGHT.config(relief=tk.SOLID, background="#ffffff"))

		elif self.Set_Hour["background"] == self.mm_HC:
			for i in range(0,len(self.hour_ARR)):
				if self.hour_ARR[i] == 23:
					self.hour_ARR[i] = 0
				else:
					self.hour_ARR[i] = self.hour_ARR[i] + 1
			self.H_LEFT["text"] = self.hour_Str_ampm(self.hour_ARR[0])
			self.H_RIGHT["text"] = self.hour_Str_ampm(self.hour_ARR[2])
			# index 2 goes last to ensure consistent am-pm with user chouice
			self.H_MID["text"] = self.hour_Str_ampm(self.hour_ARR[1])
			sound.combine_wav_files(self.TMP_WAV, NUM_PATH + self.hour_Str(self.hour_ARR[1]) + '_f.wav', MISC_PATH + self.ampm + '_f.wav')
			sound.Play(self.TMP_WAV)

			# self.H_RIGHT.config(relief=tk.SUNKEN, background=self.cursor_Col)
			# self.H_RIGHT.after(150, lambda: self.H_RIGHT.config(relief=tk.SOLID, background="#ffffff"))
		elif self.Set_Min["background"] == self.mm_HC:
			for i in range(0,len(self.min_ARR)):
				if self.min_ARR[i] == 59:
					self.min_ARR[i] = 0
				else:
					self.min_ARR[i] = self.min_ARR[i] +  1
			self.M_LEFT["text"] = self.min_Str(self.min_ARR[0])
			self.M_RIGHT["text"] = self.min_Str(self.min_ARR[2])
			# index 2 goes last to ensure consistent am-pm with user chouice
			self.M_MID["text"] = self.min_Str(self.min_ARR[1])
			sound.Play(NUM_PATH + self.min_Str(self.min_ARR[1]) + '_f.wav')

			# self.M_RIGHT.config(relief=tk.SUNKEN, background=self.cursor_Col)
			# self.M_RIGHT.after(150, lambda: self.M_RIGHT.config(relief=tk.SOLID, background="#ffffff"))

		self.button2.config(relief=tk.SUNKEN, background=self.cursor_Col)
		self.button2.after(150, lambda: self.button2.config(relief=tk.SOLID, background="#ffffff"))
Esempio n. 15
0
def run_menu():

    global CURRENT_TIME
    global CURRENT_DAY 
    global CURRENT_HOUR
    global CURRENT_MINUTE

    #boolean for switching from days to hours
    days_selection = True

    #boolean for switching from hours to minutes if a developer should extend program for minutes
    hour_selection = False

    #booleans for switching from am to pm
    am = True
    pm = False
    
    # Provide a minimal indication that the program has started.
    print(MINIMAL_HELP_STRING)
    # Indicate program has started and list options for user
    sound.Play(INTRO_WAV)
     
    # Get the first keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the QUIT_MENU_KEY or SET_KEY the second time.
    while True:
        
        #this now should loop though days
        if c == BACKWARD_KEY and days_selection == True:
            if CURRENT_DAY == 0:
                CURRENT_DAY = len(DAYS_WAV)-1
            else:
                CURRENT_DAY -= 1
           

            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    DAYS_WAV[CURRENT_DAY])
            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # Respond to the user's input. If the day selection is true
        # means if the user has not yet selected a day.
        if c == FORWARD_KEY and days_selection == True:

            # Advance the time, looping back around to the start.
            CURRENT_DAY += 1
            if CURRENT_DAY == len(DAYS_WAV):
                CURRENT_DAY = 0

            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    DAYS_WAV[CURRENT_DAY])
            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)
        
        # repeat intro if the user hasnt set the day yet
        if c == REPEAT_KEY and days_selection == True:
            sound.Play(INTRO_WAV)
        # repeat set time instruction if days have been selected
        if c == REPEAT_KEY and days_selection == False:
            sound.Play(SET_HOUR_WAV)
        

        # this now should loop though hours
        # since day selection is false the user already selected a day.
        if c == BACKWARD_KEY and days_selection == False:
            
            # boolean variable for converting am to pm and vice versa
            convert = False

            if CURRENT_TIME == 0:
                CURRENT_TIME = 11

                # change from am to pm or vice versa
                convert = True

            else:
                CURRENT_TIME -= 1
         
            #configure am and pm
            if(convert):
                if am == True:
                    am = False
                    pm = True
                    convert = False
                else:
                    am = True
                    pm = False
                    convert = False

            if am == True:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], AM_WAV)
            else:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], PM_WAV)

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)   
        # selecting hour
        if c == FORWARD_KEY and days_selection == False:

            # variable for converting am to pm and vice versa
            convert = False
            
            # Advance the time, looping back around to the start.
            if (CURRENT_TIME) > 10:
                CURRENT_TIME = 0
                # change from am to pm or vice versa
                convert = True
            else:
                CURRENT_TIME += 1
            

            #configure am and pm
            if(convert):
                if am == True:
                    am = False
                    pm = True
                    convert = False
                else:
                    am = True
                    pm = False
                    convert = False

            if am == True:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], AM_WAV)
            else:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], PM_WAV)

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)    
        

        if c == SET_KEY:

            # second time being pressed
            if days_selection == False:
                # audio recognition of hours being selected
                sound.Play(HOUR_SET_WAV)
                # pause to play next sound
                time.sleep(PAUSING_BETWEEN_AUDIO_FILE_DURATION)
                # informing exit
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break
            else:
                # disable day conditions
                days_selection = False
                sound.Play(DAY_SET_WAV)
                time.sleep(PAUSING_BETWEEN_AUDIO_FILE_DURATION)
                #indicate switch from days to hours
                sound.Play(SET_HOUR_WAV)
                        
                #listen for user input
                c = readchar.readchar() 

        # User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break

        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 16
0
def run_menu():

    global CURRENT_MINUTE, CURRENT_HOUR, CURRENT_DAY

    # Provide a minimal indication that the program has started.
    print(MINIMAL_HELP_STRING)

    # Get the first keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the QUIT_MENU_KEY.
    while True:

        # Respond to the user's input.
        if c == START_KEY:
            CURRENT_DAY = 0
            CURRENT_HOUR = 1
            CURRENT_MINUTE = 0

            #Print the set of instructions for setting the day
            print(BACKWARD_AND_FORWARD_INSTRUCTIONS_DAY)
            sound.Play(SELECT_DAY_OF_THE_WEEK)
            time.sleep(EXITING_PROGRAM_WAV_DURATION)
            sound.Play(DAYS_OF_WEEK_WAV[CURRENT_DAY])
            c = readchar.readchar()

            # Following loop allows the user to choose the day, it breaks when the user presses the SET_KEY
            while True:

                if c == FORWARD_KEY:  #increments or resets the current_day value
                    if CURRENT_DAY != 6:
                        CURRENT_DAY += 1
                    else:
                        CURRENT_DAY = 0
                    sound.Play(DAYS_OF_WEEK_WAV[CURRENT_DAY])
                    c = readchar.readchar()

                elif c == BACKWARD_KEY:  #decrements or resets the current_day value

                    if CURRENT_DAY != 0:
                        CURRENT_DAY -= 1
                    else:
                        CURRENT_DAY = 6
                    sound.Play(
                        DAYS_OF_WEEK_WAV[CURRENT_DAY]
                    )  #plays the sound file corresponding to the index of array containing the day of the week sound files
                    c = readchar.readchar()
                elif c == SET_KEY:
                    break
                else:
                    # Get the user's next keystroke.
                    c = readchar.readchar()
            #end while

            #Print the set of instructions for setting the hour
            print(BACKWARD_AND_FORWARD_INSTRUCTIONS_HOUR)
            sound.Play(SET_HOUR)
            time.sleep(EXITING_PROGRAM_WAV_DURATION)
            sound.Play(NUMBERS_WAV[CURRENT_HOUR])
            c = readchar.readchar()

            #The following loop is for setting hour, the hours ranges from 0-23, it exits the loop by pressing 'set' or 'quit.'
            while True:

                if c == FORWARD_KEY:

                    if CURRENT_HOUR != 23:
                        CURRENT_HOUR += 1
                    else:
                        CURRENT_HOUR = 0

                    sound.Play(NUMBERS_WAV[CURRENT_HOUR])
                    c = readchar.readchar()
                elif c == BACKWARD_KEY:

                    if CURRENT_HOUR != 0:
                        CURRENT_HOUR -= 1
                    else:
                        CURRENT_HOUR = 23

                    sound.Play(NUMBERS_WAV[CURRENT_HOUR])
                    c = readchar.readchar()
                elif c == SET_KEY:
                    break
                else:
                    c = readchar.readchar()
            #end while

            #Print the set of instructions for setting the minutes
            print(BACKWARD_AND_FORWARD_INSTRUCTIONS_MINS)
            sound.Play(SET_MIN)
            time.sleep(EXITING_PROGRAM_WAV_DURATION)
            sound.Play(NUMBERS_WAV[CURRENT_MINUTE])
            c = readchar.readchar()

            #The following loop is for setting minutes, the minutes ranges from 0-59, it exits the loop by pressing 'set' or 'quit.'
            while True:
                if c == FORWARD_KEY:

                    if CURRENT_MINUTE != 59:
                        CURRENT_MINUTE += 1
                    else:
                        CURRENT_MINUTE = 0

                    sound.Play(NUMBERS_WAV[CURRENT_MINUTE])
                    c = readchar.readchar()
                elif c == BACKWARD_KEY:

                    if CURRENT_MINUTE != 0:
                        CURRENT_MINUTE -= 1
                    else:
                        CURRENT_MINUTE = 59

                    sound.Play(NUMBERS_WAV[CURRENT_MINUTE])
                    c = readchar.readchar()
                elif c == SET_KEY:
                    break
                else:
                    c = readchar.readchar()

            #if the time is in the AM
            if CURRENT_HOUR <= 12:
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                        DAYS_OF_WEEK_WAV[CURRENT_DAY],
                                        NUMBERS_WAV[CURRENT_HOUR],
                                        NUMBERS_WAV[CURRENT_MINUTE], AM_WAV)
                sound.Play(TMP_FILE_WAV)

            # if the time is in the PM
            if CURRENT_HOUR > 12:
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                        DAYS_OF_WEEK_WAV[CURRENT_DAY],
                                        NUMBERS_WAV[CURRENT_HOUR - 12],
                                        NUMBERS_WAV[CURRENT_MINUTE], PM_WAV)
                sound.Play(TMP_FILE_WAV)

            #Making the program sleep until the combined wav files is done being reported
            time.sleep(EXITING_PROGRAM_WAV_DURATION)
            time.sleep(EXITING_PROGRAM_WAV_DURATION)
            time.sleep(EXITING_PROGRAM_WAV_DURATION)
            time.sleep(EXITING_PROGRAM_WAV_DURATION)

            #Intructions for starting over or exiting the program
            sound.Play(INTRO_WAV)
            print(MINIMAL_HELP_STRING)
            c = readchar.readchar()

        # User quits.
        elif c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break

        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 17
0
def run_menu():

    global CURRENT_TIME
    global CURRENT_DAY
    global CURRENT_HOUR
    global CURRENT_MINUTE

    #boolean for switching from days to hours
    days_selection = True

    #boolean for switching from hours to minutes if a developer should extend program for minutes
    hour_selection = False

    #booleans for switching from am to pm
    am = True
    pm = False

    # Provide a minimal indication that the program has started.
    print(MINIMAL_HELP_STRING)
    # Indicate program has started and list options for user
    sound.Play(INTRO_WAV)

    # Get the first keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the QUIT_MENU_KEY or SET_KEY the second time.
    while True:

        #this now should loop though days
        if c == BACKWARD_KEY and days_selection == True:
            if CURRENT_DAY == 0:
                CURRENT_DAY = len(DAYS_WAV) - 1
            else:
                CURRENT_DAY -= 1

            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    DAYS_WAV[CURRENT_DAY])
            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # Respond to the user's input. If the day selection is true
        # means if the user has not yet selected a day.
        if c == FORWARD_KEY and days_selection == True:

            # Advance the time, looping back around to the start.
            CURRENT_DAY += 1
            if CURRENT_DAY == len(DAYS_WAV):
                CURRENT_DAY = 0

            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    DAYS_WAV[CURRENT_DAY])
            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # repeat intro if the user hasnt set the day yet
        if c == REPEAT_KEY and days_selection == True:
            sound.Play(INTRO_WAV)
        # repeat set time instruction if days have been selected
        if c == REPEAT_KEY and days_selection == False:
            sound.Play(SET_HOUR_WAV)

        # this now should loop though hours
        if c == BACKWARD_KEY and days_selection == False and hour_selection == True:

            # boolean variable for converting am to pm and vice versa
            convert = False

            if CURRENT_HOUR <= 1:
                CURRENT_HOUR = 12

                # change from am to pm or vice versa
                convert = True

            else:
                CURRENT_HOUR -= 1

            # configure am and pm
            if (convert):
                if am == True:
                    am = False
                    pm = True
                    convert = False
                else:
                    am = True
                    pm = False
                    convert = False

            if am == True:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                        NUMBERS_WAV[CURRENT_HOUR], AM_WAV)
            else:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                        NUMBERS_WAV[CURRENT_HOUR], PM_WAV)

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # selecting minute
        if c == FORWARD_KEY and days_selection == False and hour_selection == False:

            # advance the time, looping back around to the start.
            if (CURRENT_MINUTE) > 58:
                CURRENT_MINUTE = 0
                # change from am to pm or vice versa
                convert = True
            else:
                CURRENT_MINUTE += 1

            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_MINUTE])
            sound.Play(TMP_FILE_WAV)

        # selecting minute
        if c == BACKWARD_KEY and days_selection == False and hour_selection == False:

            if CURRENT_MINUTE == 1:
                CURRENT_MINUTE = 59
            else:
                CURRENT_MINUTE -= 1
            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_MINUTE])
            sound.Play(TMP_FILE_WAV)

        # selecting hour
        if c == FORWARD_KEY and days_selection == False and hour_selection == True:

            # variable for converting am to pm and vice versa
            convert = False

            # Advance the time, looping back around to the start.
            if (CURRENT_HOUR) > 11:
                CURRENT_HOUR = 1
                # change from am to pm or vice versa
                convert = True
            else:
                CURRENT_HOUR += 1

            #configure am and pm
            if (convert):
                if am == True:
                    am = False
                    pm = True
                    convert = False
                else:
                    am = True
                    pm = False
                    convert = False

            if am == True:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                        NUMBERS_WAV[CURRENT_HOUR], AM_WAV)
            else:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                        NUMBERS_WAV[CURRENT_HOUR], PM_WAV)

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        if c == SET_KEY:

            # second time being pressed
            if hour_selection == True:
                # so if day selection is false then program went through hour cycle already and came back
                hour_selection = False
                # audio recognition of hours being selected
                sound.Play(HOUR_SET_WAV)
                # pause between sounds
                time.sleep(PAUSING_BETWEEN_AUDIO_FILE_DURATION_FASTER)
                # indicate to set minutes
                sound.Play(SET_MINUTES_WAV)

            elif days_selection == True:
                # disable day conditions
                days_selection = False
                hour_selection = True
                sound.Play(DAY_SET_WAV)
                # pause between sounds
                time.sleep(PAUSING_BETWEEN_AUDIO_FILE_DURATION_FASTER)
                #indicate switch from days to hours
                sound.Play(SET_HOUR_WAV)

                #listen for user input
                c = readchar.readchar()

            # minutes == true
            elif days_selection == False and hour_selection == False:

                if am == True:

                    # numbers starting at one and and ending at nine are pronounced: "number oh number" typically
                    # example: 1:10 = "one ten" whereas 1:09= "one oh nine"
                    if (CURRENT_MINUTE < 10 and CURRENT_MINUTE > 0):

                        # audio recognition of minutes being selected and result of all selections
                        # Concatenate three audio files to generate the message.
                        sound.combine_wav_files(TMP_FILE_WAV,
                                                DAYS_WAV[CURRENT_DAY],
                                                NUMBERS_WAV[CURRENT_HOUR],
                                                OH_WAV,
                                                NUMBERS_WAV[CURRENT_MINUTE],
                                                AM_WAV, EXITING_PROGRAM_WAV)
                        sound.Play(TMP_FILE_WAV)

                    # if the minutes are equal to zero then we should not say the minutes, example 1:00 = "1 am" or "1 pm"
                    elif (CURRENT_MINUTE == 0):

                        sound.combine_wav_files(TMP_FILE_WAV,
                                                DAYS_WAV[CURRENT_DAY],
                                                NUMBERS_WAV[CURRENT_HOUR],
                                                AM_WAV)
                        sound.Play(TMP_FILE_WAV)

                    else:
                        # audio recognition of minutes being selected and result of all selections
                        # Concatenate three audio files to generate the message.

                        sound.combine_wav_files(TMP_FILE_WAV,
                                                DAYS_WAV[CURRENT_DAY],
                                                NUMBERS_WAV[CURRENT_HOUR],
                                                NUMBERS_WAV[CURRENT_MINUTE],
                                                AM_WAV, EXITING_PROGRAM_WAV)
                        sound.Play(TMP_FILE_WAV)

                    # giving time for the current audio to finish playing before exiting program.
                    time.sleep(PAUSING_BETWEEN_AUDIO_FILE_DURATION_SLOWER)
                    quit_program()

                # if pm is true and am is false
                else:
                    # numbers starting at one and and ending at nine are pronounced: "number oh number" typically
                    # example: 1:10 = "one ten" whereas 1:09= "one oh nine"
                    if (CURRENT_MINUTE < 10 and CURRENT_MINUTE > 0):
                        # audio recognition of minutes being selected and result of all selections
                        # Concatenate three audio files to generate the message.

                        sound.combine_wav_files(TMP_FILE_WAV,
                                                DAYS_WAV[CURRENT_DAY],
                                                NUMBERS_WAV[CURRENT_HOUR],
                                                OH_WAV,
                                                NUMBERS_WAV[CURRENT_MINUTE],
                                                PM_WAV)
                        sound.Play(TMP_FILE_WAV)

                    # if the minutes are equal to zero then we should not say the minutes, example 1:00 = "1 am" or "1 pm"
                    elif (CURRENT_MINUTE == 0):

                        sound.combine_wav_files(TMP_FILE_WAV,
                                                DAYS_WAV[CURRENT_DAY],
                                                NUMBERS_WAV[CURRENT_HOUR],
                                                AM_WAV)
                        sound.Play(TMP_FILE_WAV)

                    else:
                        # audio recognition of minutes being selected and result of all selections
                        # Concatenate three audio files to generate the message.

                        sound.combine_wav_files(TMP_FILE_WAV,
                                                DAYS_WAV[CURRENT_DAY],
                                                NUMBERS_WAV[CURRENT_HOUR],
                                                NUMBERS_WAV[CURRENT_MINUTE],
                                                PM_WAV)

                        sound.Play(TMP_FILE_WAV)

                    # giving time for the current audio to finish playing before exiting program.
                    time.sleep(PAUSING_BETWEEN_AUDIO_FILE_DURATION_SLOWER)
                    quit_program()

        # User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break

        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 18
0
def get_hour(time):
    hour = "hour.wav"
    # When time is 12 AM
    if time == 0:
        index = num_path + "12_f.wav"
        sound.combine_wav_files(hour, index, AM_WAV)
        sound.Play(hour)
    # When time is 12 PM
    elif time == 12:
        index = num_path + "12_f.wav"
        sound.combine_wav_files(hour, index, PM_WAV)
        sound.Play(hour)
    # When time is after 9 AM and before 12 PM
    elif time > 9 and time < 12:
        index = num_path + str(time) + "_f.wav"
        sound.combine_wav_files(hour, index, AM_WAV)
        sound.Play(hour)
    # When time is after 12 AM and before 10 AM
    elif time < 10 and time > 0:
        index = num_path + "0" + str(time) + "_f.wav"
        sound.combine_wav_files(hour, index, AM_WAV)
        sound.Play(hour)
    # When time is after 12 PM and before 10 PM
    elif time > 12 and time < 22:
        index = num_path + "0" + str(time - 12) + "_f.wav"
        sound.combine_wav_files(hour, index, PM_WAV)
        sound.Play(hour)
    # When time is after 9 PM
    elif time > 21:
        index = num_path + str(time - 12) + "_f.wav"
        sound.combine_wav_files(hour, index, PM_WAV)
        sound.Play(hour)
    return hour
Esempio n. 19
0
    def okButtonClick(self, event):
        if (
                self.edit_state == 0
        ):  # Relay to user of the setting they chose before going opening edit menu
            self.edit_state = 1
            if (self.state_index == 0):
                self.changeToEdit(self.edit_state, 0)
                sound.combine_wav_files(self.temp_sound, YOU_SELECTED,
                                        nav_path + "Set_day_of_week_f.wav")
                sound.Play(self.temp_sound)
            elif (self.state_index == 1):
                self.changeToEdit(self.edit_state, 1)
                sound.combine_wav_files(self.temp_sound, YOU_SELECTED,
                                        nav_path + "Set_hour_f.wav")
                sound.Play(self.temp_sound)
            elif (self.state_index == 2):
                self.changeToEdit(self.edit_state, 2)
                sound.combine_wav_files(self.temp_sound, YOU_SELECTED,
                                        nav_path + "Set_minutes_f.wav")
                sound.Play(self.temp_sound)
            elif (self.state_index == 3
                  ):  # User is done and wants to confirm their final time
                # checking if minute is zero so o_clock.wav is played
                if (self.current_min == 0):
                    sound.combine_wav_files(
                        self.temp_sound, my_sounds_path + "final_time.wav",
                        days_path + self.day_selection + "_f.wav",
                        num_path + self.hour_selection + "_f.wav",
                        nav_path + "o_clock_f.wav",
                        nav_path + self.ampm_selection + "_f.wav")
                    sound.Play(self.temp_sound)
                    time.sleep(
                        EXIT_TIME
                    )  # Sleep so program has enough time to say final time
                    self.myParent.destroy()  # before closing
                # checking if single digit minute so that oh.wav is played before minute
                elif (self.current_min < 10 and self.current_min > 0):
                    sound.combine_wav_files(
                        self.temp_sound, my_sounds_path + "final_time.wav",
                        days_path + self.day_selection + "_f.wav",
                        num_path + self.hour_selection + "_f.wav",
                        num_path + "oh_f.wav",
                        num_path + self.min_selection + "_f.wav",
                        nav_path + self.ampm_selection + "_f.wav")
                    sound.Play(self.temp_sound)
                    time.sleep(EXIT_TIME)
                    self.myParent.destroy()
                # Any other minute will be played without any extra wav files
                elif (self.current_min >= 10):
                    sound.combine_wav_files(
                        self.temp_sound, my_sounds_path + "final_time.wav",
                        days_path + self.day_selection + "_f.wav",
                        num_path + self.hour_selection + "_f.wav",
                        num_path + self.min_selection + "_f.wav",
                        nav_path + self.ampm_selection + "_f.wav")
                    sound.Play(self.temp_sound)
                    time.sleep(EXIT_TIME)
                    self.myParent.destroy()

        elif (self.edit_state == 1):  # When confirming an edit
            if (self.state_index == 0):  # Confirming an edit of the day
                self.day_selection = self.days_list[self.current_day]
                sound.combine_wav_files(
                    self.temp_sound, YOU_SELECTED,
                    days_path + self.days_list[self.current_day] + "_f.wav")
                sound.Play(self.temp_sound)
            elif (self.state_index == 1):  # Confirming edit of hour
                sound.combine_wav_files(
                    self.temp_sound, YOU_SELECTED,
                    num_path + self.hour_selection + "_f.wav",
                    nav_path + self.ampm_selection + "_f.wav")
                sound.Play(self.temp_sound)
            elif (self.state_index == 2):  # Confirming edit of minute
                sound.combine_wav_files(
                    self.temp_sound, YOU_SELECTED,
                    num_path + self.min_selection + "_f.wav")
                sound.Play(self.temp_sound)

            self.edit_state = 0
            self.changeToEdit(
                self.edit_state,
                self.state_index)  # Change back to main menu state
Esempio n. 20
0
    def setHour(self, select, k, j):
        # Set base cases for when the index goes over or below the limit
        if (select == -1):
            select = 23
            j = 22
            k = 0
        elif (select == self.hour_limit):
            select = 0
            k = 1
            j = 23
        if (k == self.hour_limit):
            k = 0
        if (j == -1):
            j = 23
        self.current_hour = select  # Set the current hour to the new index

        # Need to check if single digit because wav file requires "0" infornt of number
        # Also need index above 12 to correspond to PM and below 12 to AM
        if (select == 0):  # 0 corresponds to 12 AM
            self.selection["text"] = "12 AM"
            sound.combine_wav_files(self.time_sound, num_path + "12_f.wav",
                                    nav_path + "AM_f.wav")
            sound.Play(self.time_sound)
            self.hour_selection = "12"  # set final hour_selection to selected hour
            self.ampm_selection = "AM"  # final AM or PM corresponds to index
        elif (select == 12):  # 12 PM
            self.selection["text"] = "12 PM"
            sound.combine_wav_files(self.time_sound, num_path + "12_f.wav",
                                    nav_path + "PM_f.wav")
            sound.Play(self.time_sound)
            self.hour_selection = "12"
            self.ampm_selection = "PM"
        elif (select > 0 and select < 10):  # Hours between 12 AM and 10 AM
            self.selection["text"] = str(select) + " AM"
            sound.combine_wav_files(self.time_sound,
                                    num_path + "0" + str(select) + "_f.wav",
                                    nav_path + "AM_f.wav")
            sound.Play(self.time_sound)
            self.hour_selection = "0" + str(select)
            self.ampm_selection = "AM"
        elif (select < 12 and select > 9):  # Hours between 10 AM and 12 PM
            self.selection["text"] = str(select) + " AM"
            sound.combine_wav_files(self.time_sound,
                                    num_path + str(select) + "_f.wav",
                                    nav_path + "AM_f.wav")
            sound.Play(self.time_sound)
            self.hour_selection = str(select)
            self.ampm_selection = "AM"
        elif (select > 12 and select < 22):  # Hours between 12 PM and 10 PM
            self.selection["text"] = str(select - 12) + " PM"
            sound.combine_wav_files(
                self.time_sound, num_path + "0" + str(select - 12) + "_f.wav",
                nav_path + "PM_f.wav")
            sound.Play(self.time_sound)
            self.hour_selection = "0" + str(select - 12)
            self.ampm_selection = "PM"
        elif (select > 21):  # Hours between 10 PM and 12 AM
            self.selection["text"] = str(select - 12) + " PM"
            sound.combine_wav_files(self.time_sound,
                                    num_path + str(select - 12) + "_f.wav",
                                    nav_path + "PM_f.wav")
            sound.Play(self.time_sound)
            self.hour_selection = str(select - 12)
            self.ampm_selection = "PM"

        # Making sure the K and J labels correspond correctly to AM and PM
        if (k == 0):
            self.k_index["text"] = "12 AM"
        elif (k == 12):
            self.k_index["text"] = "12 PM"
        elif (k < 12):
            self.k_index["text"] = str(k) + " AM"
        elif (k > 12):
            self.k_index["text"] = str(k - 12) + " PM"

        if (j == 0):
            self.j_index["text"] = "12 AM"
        elif (j == 12):
            self.j_index["text"] = "12 PM"
        elif (j < 12):
            self.j_index["text"] = str(j) + " AM"
        elif (j > 12):
            self.j_index["text"] = str(j - 12) + " PM"
Esempio n. 21
0
def run_fenu():

    global CURRENT_TIME
    global CURRENT_DAY 

    #boolean for switching from days to hours
    days_selection = True

    #boolean for switching from hours to minutes
    hours_selection = False

    #booleans for switching from am to pm
    am = True
    pm = False
    
    # Provide a minimal indication that the program has started.
    print(MINIMAL_HELP_STRING)

    
    # Concatenate three audio files to generate the message.
    sound.combine_wav_files(TMP_FILE_WAV, INTRO_WAV, SET_DAY_WAV)
    # Play the concatenated file.
    sound.Play(TMP_FILE_WAV)

    # Get the 2nd keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the QUIT_MENU_KEY or SET_KEY the second time.
    while True:
          
        
        #this now should loop though days
        if c == BACKWARD_KEY and days_selection == True:
            if CURRENT_DAY == 0:
                CURRENT_DAY = len(DAYS_WAV)-1
            else:
                CURRENT_DAY -= 1
           

            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    DAYS_WAV[CURRENT_DAY])
            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # Respond to the user's input.
        if c == FORWARD_KEY and days_selection == True:

            # Advance the time, looping back around to the start.
            CURRENT_DAY += 1
            if CURRENT_DAY == len(DAYS_WAV):
                CURRENT_DAY = 0

            # Concatenate three audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    DAYS_WAV[CURRENT_DAY])
            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)


        

        # this now should loop though hours
        if c == BACKWARD_KEY and days_selection == False:

            hours_selection = True
            
            # variable for converting am to pm and vice versa
            convert = False

            if CURRENT_TIME == 0:
                CURRENT_TIME = len(NUMBERS_WAV)-1

                # change from am to pm or vice versa
                convert = True

            else:
                CURRENT_TIME -= 1
           

            print(CURRENT_TIME)
            #configure am and pm
            if(convert):
                if am == True:
                    am = False
                    pm = True
                    convert = False
                else:
                    am = True
                    pm = False
                    convert = False

            if am == True:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], AM_WAV)
            else:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], PM_WAV)

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)   

        if c == FORWARD_KEY and days_selection == False:

            hours_selection = True

            # variable for converting am to pm and vice versa
            convert = False
            
            # Advance the time, looping back around to the start.
            if (CURRENT_TIME+1) == len(NUMBERS_WAV):
                CURRENT_TIME = 0
                # change from am to pm or vice versa
                convert = True
            else:
                CURRENT_TIME += 1
            
            print(CURRENT_TIME)

            #configure am and pm
            if(convert):
                if am == True:
                    am = False
                    pm = True
                    convert = False
                else:
                    am = True
                    pm = False
                    convert = False

            if am == True:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], AM_WAV)
            else:
                # Concatenate three audio files to generate the message.
                sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    NUMBERS_WAV[CURRENT_TIME], PM_WAV)

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)    
        

        if c == SET_KEY:

            if days_selection == True:
                # day is selected 
                days_selection = False

                hours_selection = True

                #indicate switch from days to hours
                sound.Play(SET_HOUR_WAV)

                #listen for user input
                c = readchar.readchar() 

            elif hours_selection = True:

                hours_selection = False

            else:
                sound.Play(EXITING_PROGRAM_WAV)
                break

            # second time being pressed
            if days_selection == False:
                sound.Play(EXITING_PROGRAM_WAV)
                break
            else:
                # disable day conditions
                days_selection = False

                #indicate switch from days to hours
                sound.Play(SET_HOUR_WAV)
                        
                #listen for user input
                c = readchar.readchar() 

        # User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break

        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 22
0
def get_final_time(day,hour_num,minute_num):
    final_selection = "final.wav"
    AMPM = 0
    hour_str = ""
    minute_str = ""
    zero_str = nav_path + "o_clock_f.wav"
    oh_str = num_path + "oh_f.wav"
    # Generate the correct string based on the hour of the day
    # Also assigns AMPM = 0 if in the morning or else AMPM = 1 for the afternoon and night
    if (hour_num == 0):
        hour_str = num_path + "12_f.wav"
    elif (hour_num == 12):
        hour_str = num_path + "12_f.wav"
        AMPM = 1
    elif (hour_num  > 9 and hour_num < 12):
        hour_str = num_path + str(hour_num) + "_f.wav"
    elif (hour_num < 10 and hour_num >0):
        hour_str = num_path + "0" + str(hour_num) + "_f.wav"
    elif (hour_num >12 and hour_num < 22):
        hour_str = num_path + "0" + str(hour_num - 12) + "_f.wav"
        AMPM = 1
    elif (hour_num > 21):
        hour_str = num_path + str(hour_num-12) + "_f.wav"
        AMPM = 1

    # If the time is in the AM
    if (AMPM == 0):
        # If the minutes are 0, we need to put "o' clock" at the end
        if (minute_num == 0):
            sound.combine_wav_files(final_selection,YOU_SELECTED_WAV,day,hour_str,zero_str,AM_WAV)
        # If the number is single digit then, we must put the "oh" in front of the minutes when announcing the selection
        elif (minute_num < 10):
            minute_str = num_path + "0" + str(minute_num) + "_f.wav"
            sound.combine_wav_files(final_selection, YOU_SELECTED_WAV, day, hour_str, oh_str,minute_str, AM_WAV)
        # Any other numbers that do not change the way it is said
        else:
            minute_str = num_path + str(minute_num) + "_f.wav"
            sound.combine_wav_files(final_selection, YOU_SELECTED_WAV, day, hour_str, minute_str,AM_WAV)
    # If the time is in the PM
    elif (AMPM == 1):
        # If the minutes are 0, we need to put "o' clock" at the end
        if (minute_num == 0):
            sound.combine_wav_files(final_selection, YOU_SELECTED_WAV, day, hour_str, zero_str, PM_WAV)
        # If the number is single digit then, we must put the "oh" in front of the minutes when announcing the selection
        elif (minute_num < 10):
            minute_str = num_path + "0" + str(minute_num) + "_f.wav"
            sound.combine_wav_files(final_selection, YOU_SELECTED_WAV, day, hour_str, oh_str, minute_str, PM_WAV)
        # Any other numbers that do not change the way it is said
        else:
            minute_str = num_path + str(minute_num) + "_f.wav"
            sound.combine_wav_files(final_selection, YOU_SELECTED_WAV, day, hour_str, minute_str, PM_WAV)

    # Play the final result of day, hour, minutes, and time of day
    sound.Play(final_selection)
Esempio n. 23
0
def run_submenu():
    global CURRENT_SUBMENU_CHOICE
    global CURRENT_MENU_CHOICE
    global CURRENT_DAY
    global CURRENT_HOUR
    global CURRENT_MINUTES
    global CURRENT_AM_PM

    # The following three variables allow the run_submenu() function to operate in a modular fashion.
    current_submenu_wav_collection = None
    current_entering_menu_wav = None
    current_set_to_wav = None

    # If the user selected the 'Set Day' sub-menu from the run_menu() function
    # Then set up the 'modular' sub-menu variables for 'Set Day' operation.
    if CURRENT_MENU_CHOICE == 0:
        CURRENT_SUBMENU_CHOICE = CURRENT_DAY
        current_submenu_wav_collection = DAYS_WAV
        current_entering_menu_wav = ENTERING_DAY_MENU_WAV
        current_set_to_wav = DAY_SET_TO_WAV

    # If the user selected the 'Set Hour' sub-menu from the run_menu() function
    # Then setup the 'modular' sub-menu variables for 'Set Hour' operation.
    elif CURRENT_MENU_CHOICE == 1:
        CURRENT_SUBMENU_CHOICE = CURRENT_HOUR
        current_submenu_wav_collection = HOURS_WAV
        current_entering_menu_wav = ENTERING_HOUR_MENU_WAV
        current_set_to_wav = HOUR_SET_TO_WAV

    # If the user selected the 'Set Minutes' sub-menu from the run_menu() function
    # Then setup the 'modular' sub-menu variables for 'Set Minutes' operation.
    elif CURRENT_MENU_CHOICE == 2:
        CURRENT_SUBMENU_CHOICE = CURRENT_MINUTES
        current_submenu_wav_collection = MINUTES_WAV
        current_entering_menu_wav = ENTERING_MINUTES_MENU_WAV
        current_set_to_wav = MINUTES_SET_TO_WAV

    # If the user selected the 'Set AM/PM' sub-menu from the run_menu() function
    # Then setup the 'modular' sub-menu variables for 'Set Minutes' operation.
    elif CURRENT_MENU_CHOICE == 3:
        CURRENT_SUBMENU_CHOICE = CURRENT_AM_PM
        current_submenu_wav_collection = AM_AND_PM_WAV
        current_entering_menu_wav = ENTERING_AM_PM_MENU_WAV
        current_set_to_wav = AM_PM_SET_TO_WAV

    # Create and play the Sub-menu transition introduction audio
    # "Entering <Selected Sub-menu>. Current selection is <Current Day OR Hour OR Minutes OR AM/PM>. Press the L key for assistance. Press semicolon to return to start."
    sound.combine_wav_files(TMP_FILE_WAV, current_entering_menu_wav, CURRENT_SELECTION_IS_WAV,\
        current_submenu_wav_collection[CURRENT_SUBMENU_CHOICE], PRESS_L_FOR_HELP_WAV, PRESS_SEMICOLON_TO_RETURN_TO_START_MENU_WAV)
    sound.Play(TMP_FILE_WAV)

    # Get the first keystroke.
    c = readchar.readchar()

    while True:
        # Respond to the user's input.
        if c == FORWARD_KEY:

            # Advance the available sub-menu options, looping back around to the start.
            CURRENT_SUBMENU_CHOICE += 1

            if CURRENT_SUBMENU_CHOICE == len(current_submenu_wav_collection):
                CURRENT_SUBMENU_CHOICE = 0

            # Play the sub-menu option the user is currently pointing at. (i.e. "Sunday")
            sound.Play(current_submenu_wav_collection[CURRENT_SUBMENU_CHOICE])

        if c == BACKWARD_KEY:

            # Retreat the available sub-menu options, looping back around to the end.
            CURRENT_SUBMENU_CHOICE -= 1

            if CURRENT_SUBMENU_CHOICE < 0:
                CURRENT_SUBMENU_CHOICE = len(
                    current_submenu_wav_collection) - 1

            # Play the sub-menu option the user is currently pointing at. (i.e. "Sunday")
            sound.Play(current_submenu_wav_collection[CURRENT_SUBMENU_CHOICE])

        if c == SET_KEY:
            # MENU CHOICE KEY: 0 -> Set Day, 1 -> Set Hour, 2 -> Set Minutes, 3 -> Set AM/PM

            # If current sub-menu is: "Set Day" sub-menu
            if CURRENT_MENU_CHOICE == 0:
                # Set the current day to the sub-menu option selected by the user
                CURRENT_DAY = CURRENT_SUBMENU_CHOICE

            # If current sub-menu is: "Set Hour" sub-menu
            elif CURRENT_MENU_CHOICE == 1:
                # Set the current hour to the sub-menu option selected by the user
                CURRENT_HOUR = CURRENT_SUBMENU_CHOICE

            # If current sub-menu is: "Set Minutes" sub-menu
            elif CURRENT_MENU_CHOICE == 2:
                # Set the current minutes to the sub-menu option selected by the user
                CURRENT_MINUTES = CURRENT_SUBMENU_CHOICE

            # If current sub-menu is: "Set AM/PM" sub-menu
            elif CURRENT_MENU_CHOICE == 3:
                # Set the current AM/PM to the sub-menu option selected by the user
                CURRENT_AM_PM = CURRENT_SUBMENU_CHOICE

            # Create and play the Sub-menu exiting transition audio / Start-menu introduction audio:
            # "<Current sub-menu> set to <selected day / time>. It is <Current Day and Time>. Press L for help. Press semicolon to return to start."
            sound.combine_wav_files(TMP_FILE_WAV, current_set_to_wav, current_submenu_wav_collection[CURRENT_SUBMENU_CHOICE],\
                RETURNING_TO_START_MENU_WAV, IT_IS_WAV, DAYS_WAV[CURRENT_DAY],HOURS_WAV[CURRENT_HOUR],MINUTES_WAV[CURRENT_MINUTES],\
                AM_AND_PM_WAV[CURRENT_AM_PM],PRESS_L_FOR_HELP_WAV,PRESS_SEMICOLON_TO_QUIT_WAV)

            sound.Play(TMP_FILE_WAV)

            # Reset the start menu selection pointer to "Set Day"
            CURRENT_MENU_CHOICE = 0

            #return to the starting menu (give control back torun_menu() function)
            return

        if c == HELP_KEY:
            # Create and play the Sub-menu help audio
            # "You are in the <Current sub-menu>. It is <Current Day and Time>. Use the J and K keys... etc."
            sound.combine_wav_files(TMP_FILE_WAV, YOU_ARE_IN_THE_MENU_WAV[CURRENT_MENU_CHOICE], IT_IS_WAV,DAYS_WAV[CURRENT_DAY],\
                HOURS_WAV[CURRENT_HOUR],MINUTES_WAV[CURRENT_MINUTES],AM_AND_PM_WAV[CURRENT_AM_PM],HELP_WAV)

            sound.Play(TMP_FILE_WAV)

        if c == QUIT_KEY:
            # Create and play the Sub-menu quit audio
            # "Returning to the starting menu. It is <Current Day and time>. Press L for help. Press semicolon to quit.
            sound.combine_wav_files(TMP_FILE_WAV, RETURNING_TO_START_MENU_WAV, IT_IS_WAV, DAYS_WAV[CURRENT_DAY],HOURS_WAV[CURRENT_HOUR],\
                MINUTES_WAV[CURRENT_MINUTES],AM_AND_PM_WAV[CURRENT_AM_PM],PRESS_L_FOR_HELP_WAV,PRESS_SEMICOLON_TO_QUIT_WAV)

            sound.Play(TMP_FILE_WAV)

            #Reset the start menu selection pointer to "Set Day"
            CURRENT_MENU_CHOICE = 0
            return

        else:
            c = readchar.readchar()
Esempio n. 24
0
def verify_sound_filenames():
    print("Verifying sound filenames...")
    sound.combine_wav_files(TMP_FILE_WAV,INTRO_WAV,nav_path + "Set_day_of_week_f.wav")
    sound.Play(TMP_FILE_WAV)
Esempio n. 25
0
def set_AMPM():
    global CURRENT_TIME
    global CURRENT_AMPM

    CURRENT_TIME = 0

    #Entering new state, play audio to tell user
    sound.Play(SET_PERIOD_WAV)
    time.sleep(1.5)

    #Play current selection of period
    sound.combine_wav_files(TMP_FILE_WAV, CURRENT_AMPM_WAV,
                            AMPM_WAV[CURRENT_TIME])
    sound.Play(TMP_FILE_WAV)
    time.sleep(2.6)

    # Get the first keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the SELECT_KEY or the QUIT_KEY
    while True:

        # Respond to the user's input.
        if c == FORWARD_KEY:

            # Advance the time, looping back around to the start.
            CURRENT_TIME += 1
            if CURRENT_TIME == 2:
                CURRENT_TIME = 0

            # Concatenate two audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, AMPM_WAV[CURRENT_TIME])

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # Backward key
        if c == BACKWARD_KEY:

            # Move backward, looping around
            CURRENT_TIME -= 1
            if CURRENT_TIME == -1:
                CURRENT_TIME = 1

            # Concatenate two audio files to generate the message.
            sound.combine_wav_files(TMP_FILE_WAV, AMPM_WAV[CURRENT_TIME])

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)

        # Selects current time
        if c == SELECT_KEY:
            sound.combine_wav_files(TMP_FILE_WAV, YOU_SELECTED_WAV,
                                    AMPM_WAV[CURRENT_TIME])

            # Save minute selection
            CURRENT_AMPM = CURRENT_TIME

            # Play the concatenated file.
            sound.Play(TMP_FILE_WAV)
            time.sleep(2)

            #Selected last input, move on to play result and quit
            play_result_and_quit()
            break

        #User presses help key
        if c == HELP_KEY:

            # Notify the user that another HELP_KEY will play the help menu
            sound.Play(PRESS_AGAIN_FOR_HELP_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed HELP_KEY, play key options
            if c == HELP_KEY:
                sound.combine_wav_files(TMP_FILE_WAV, QUIT_WAV, HELP_WAV,
                                        DOWN_WAV, UP_WAV, SELECT_WAV)
                sound.Play(TMP_FILE_WAV)

        # User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break

        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 26
0
def run_menu():

    global TIME_VAL

    CURRENT_VAL = 0    # Current value of time frame being set
    CURRENT_STAGE = 0   # Current time frame being set: 1=Day, 2=Hour, 3=Minute


    # Provide a minimal indication that the program has started.
    print(MINIMAL_HELP_STRING)

    # Get the first keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the QUIT_MENU_KEY.
    while True:

        # Respond to the user's input.
        if c == ADD_KEY:

            # Loop over the right list
            WAV_LOOP = WEEKDAYS_WAV if CURRENT_STAGE == 0 else NUMBERS_WAV

            # Limit possible numbers for hour stage
            MAX = 24 if CURRENT_STAGE == 1 else len(WAV_LOOP)

            # Advance the time, looping back around to the start.
            CURRENT_VAL += 1
            if CURRENT_VAL == MAX:
                CURRENT_VAL = 0

            # Play the concatenated file.
            sound.Play(WAV_LOOP[CURRENT_VAL])

        if c == SUB_KEY:

            # Loop over the right list
            WAV_LOOP = WEEKDAYS_WAV if CURRENT_STAGE == 0 else NUMBERS_WAV

            # Limit possible numbers for hour stage
            MAX = 23 if CURRENT_STAGE == 1 else len(WAV_LOOP) - 1

            # Reduce the time, looping forward around to the end.
            CURRENT_VAL -= 1
            if CURRENT_VAL < 0:
                CURRENT_VAL = MAX

            # Play the concatenated file.
            sound.Play(WAV_LOOP[CURRENT_VAL])

        if c == CONTINUE_KEY:

            # Set the time frame and move on to the next one.
            if CURRENT_STAGE < len(TIME_VAL):
                TIME_VAL[CURRENT_STAGE] = CURRENT_VAL
                CURRENT_STAGE += 1
                CURRENT_VAL = 0 if CURRENT_STAGE == len(TIME_VAL) \
                                else TIME_VAL[CURRENT_STAGE]
                # DEVNOTE: How the hell is one supposed to format a multiline 
                # ternary operator? It's definitely not this.
                introduce_stage(CURRENT_STAGE)

            if CURRENT_STAGE >= len(TIME_VAL):
                # Program is concluded - build result feedback
                RESULT = [ YOU_SELECTED_WAV, WEEKDAYS_WAV[TIME_VAL[0]] ]
                
                if TIME_VAL[1] == 0:
                    RESULT.append(OH_WAV)
                else: 
                    RESULT.append(NUMBERS_WAV[TIME_VAL[1]])

                if TIME_VAL[2] == 0:
                    RESULT.append(O_CLOCK_WAV)
                elif 1 <= TIME_VAL[2] and TIME_VAL[2] <= 9:
                    RESULT.append(OH_WAV)
                    RESULT.append(NUMBERS_WAV[TIME_VAL[2]]) 
                else:
                    RESULT.append(NUMBERS_WAV[TIME_VAL[2]]) 
                
                RESULT.append(EXITING_PROGRAM_WAV)

                sound.combine_wav_files(TMP_FILE_WAV, *RESULT)

                sound.Play(TMP_FILE_WAV)
                time.sleep(5)
                # Quit the program
                break

        if c == UNDO_KEY:

            # Revert the time frame
            if CURRENT_STAGE > 0:
                CURRENT_STAGE -= 1
                CURRENT_VAL = TIME_VAL[CURRENT_STAGE]
                introduce_stage(CURRENT_STAGE)

        # User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break

        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 27
0
    def Select_Click(self, event):
        report_event(event)
        event_time = str(event.time)
        self.trial_data.append([event_time, event.char])
        self.keyCount = self.keyCount + 1

        if self.MM_Label["background"] == self.mm_HC:
            self.MM_Label["background"] = "white"
            self.MM_Label["relief"] = tk.SOLID
            if self.Set_Day["background"] == self.cursor_Col:
                self.Set_Day["background"] = self.mm_HC
                self.Set_Day["relief"] = tk.SUNKEN
                self.D_MID["background"] = self.cursor_Col
                sound.combine_wav_files(self.TMP_WAV,
                                        MISC_PATH + 'you_selected_f.wav',
                                        MISC_PATH + 'Set_day_of_week_f.wav')
                sound.Play(self.TMP_WAV)
            elif self.Set_Hour["background"] == self.cursor_Col:
                self.Set_Hour["background"] = self.mm_HC
                self.Set_Hour["relief"] = tk.SUNKEN
                self.H_MID["background"] = self.cursor_Col
                sound.combine_wav_files(self.TMP_WAV,
                                        MISC_PATH + 'you_selected_f.wav',
                                        MISC_PATH + 'Set_hour_f.wav')
                sound.Play(self.TMP_WAV)
            elif self.Set_Min["background"] == self.cursor_Col:
                self.Set_Min["background"] = self.mm_HC
                self.Set_Min["relief"] = tk.SUNKEN
                self.M_MID["background"] = self.cursor_Col
                sound.combine_wav_files(self.TMP_WAV,
                                        MISC_PATH + 'you_selected_f.wav',
                                        MISC_PATH + 'Set_minute_f.wav')
                sound.Play(self.TMP_WAV)

            ############# RESET BUTTON #############
            elif self.Reset["background"] == self.cursor_Col:

                trial_count = 1
                trial_time = int(self.trial_data[-1][0]) - int(
                    self.trial_data[0][0])

                while (os.path.exists(data_path + "trial_" + str(trial_count) +
                                      ".txt")):
                    trial_count = trial_count + 1

                f = open(data_path + "trial_" + str(trial_count) + ".txt",
                         "w+")
                f.write(str(self.keyCount) + ", " + str(trial_time) + "\n")
                for item in self.trial_data:
                    f.write(str(item[0]) + ", " + str(item[1]) + "\n")

                self.day = "Sunday"  # unused for now
                self.hour = 12
                self.minute = 00
                self.ampm = 'AM'

                self.D_LEFT["text"] = "Saturday"
                self.D_MID["text"] = "Sunday"
                self.D_RIGHT["text"] = "Monday"
                self.hour_ARR = [23, 0, 1]
                self.H_LEFT["text"] = self.hour_Str_ampm(self.hour_ARR[0])
                self.H_RIGHT["text"] = self.hour_Str_ampm(self.hour_ARR[2])
                self.H_MID["text"] = self.hour_Str_ampm(self.hour_ARR[1])

                self.min_ARR = [59, 0, 1]
                self.M_LEFT["text"] = self.min_Str(self.min_ARR[0])
                self.M_RIGHT["text"] = self.min_Str(self.min_ARR[2])
                self.M_MID["text"] = self.min_Str(self.min_ARR[1])

                self.Day["text"] = "Sunday"
                self.Hour["text"] = "12"
                self.Min["text"] = "00"
                self.AM_PM["text"] = "AM"
                self.Reset["background"] = "#ffffff"
                self.Set_Day["background"] = self.cursor_Col
                self.MM_Label["background"] = self.mm_HC
                self.MM_Label["relief"] = tk.SUNKEN

                self.keyCount = 0
                self.trial_data = []
                # sound.Play("extra_wav/reset.wav")
                if (trial_count == 1):

                    self.instructions[
                        "text"] = "Enter the Time:\nSunday 01:12 AM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 2):
                    self.instructions[
                        "text"] = "Enter the Time:\nThursday 06:42 AM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 3):
                    self.instructions[
                        "text"] = "Enter the Time:\nFriday 11:59 PM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 4):
                    self.instructions[
                        "text"] = "Enter the Time:\nWednesday 04:31 PM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 5):
                    self.instructions[
                        "text"] = "Enter the Time:\nTuesday 04:44 AM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 6):
                    self.instructions[
                        "text"] = "Enter the Time:\nSaturday 07:18 PM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 7):
                    self.instructions[
                        "text"] = "Enter the Time:\nMonday 08:30 AM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 8):
                    self.instructions[
                        "text"] = "Enter the Time:\nSunday 00:00 PM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count == 9):
                    self.instructions[
                        "text"] = "Enter the Time:\nWednesday 04:31 PM\n\nWhen you are done,\n Reset the Time"
                    self.instructions.grid(row=0, column=0, padx=10, pady=2)
                elif (trial_count >= 11):
                    sound.Play(MISC_PATH + "Exiting_program_f.wav")
                    try:
                        self.myParent.after(1500, self.myParent.destroy)
                    except:
                        pass
            ########

        ########
        elif self.Set_Day["background"] == self.mm_HC:
            self.Set_Day["relief"] = tk.SOLID
            self.Set_Day["background"] = self.cursor_Col
            self.MM_Label["background"] = self.mm_HC
            self.MM_Label["relief"] = tk.SUNKEN
            tmp = ""
            self.Day["text"] = self.D_MID["text"]
            self.Set_Day["relief"] = tk.SOLID
            self.Set_Day["background"] = self.cursor_Col
            self.MM_Label["background"] = self.mm_HC
            self.MM_Label["relief"] = tk.SUNKEN
            self.D_MID["background"] = "white"
            self.day = self.Day["text"]

            if self.day == "Sunday":
                tmp = "sunday_f"
            elif self.day == "Monday":
                tmp = "monday_f"
            elif self.day == "Tuesday":
                tmp = "tuesday_f"
            elif self.day == "Wednesday":
                tmp = "wednesday_f"
            elif self.day == "Thursday":
                tmp = "thursday_f"
            elif self.day == "Friday":
                tmp = "friday_f"
            elif self.day == "Saturday":
                tmp = "saturday_f"

            sound.combine_wav_files(self.TMP_WAV,
                                    MISC_PATH + 'you_selected_f.wav',
                                    DAYS_PATH + tmp + '.wav')
            sound.Play(self.TMP_WAV)

        elif self.Set_Hour["background"] == self.mm_HC:
            self.Hour["text"] = self.hour_Str(self.hour_ARR[1])
            self.AM_PM["text"] = self.ampm
            self.Set_Hour["relief"] = tk.SOLID
            self.Set_Hour["background"] = self.cursor_Col
            self.MM_Label["background"] = self.mm_HC
            self.MM_Label["relief"] = tk.SUNKEN
            self.H_MID["background"] = "white"
            self.hour = self.hour_ARR[1]
            sound.combine_wav_files(
                self.TMP_WAV, MISC_PATH + 'you_selected_f.wav',
                NUM_PATH + self.hour_Str(self.hour) + '_f.wav',
                MISC_PATH + self.ampm + '_f.wav')
            sound.Play(self.TMP_WAV)
        elif self.Set_Min["background"] == self.mm_HC:
            self.Min["text"] = self.min_Str(self.min_ARR[1])
            self.Set_Min["relief"] = tk.SOLID
            self.Set_Min["background"] = self.cursor_Col
            self.MM_Label["background"] = self.mm_HC
            self.MM_Label["relief"] = tk.SUNKEN
            self.M_MID["background"] = "white"
            self.minute = self.min_ARR[1]
            sound.combine_wav_files(
                self.TMP_WAV, MISC_PATH + 'you_selected_f.wav',
                NUM_PATH + self.min_Str(self.minute) + '_f.wav')
            sound.Play(self.TMP_WAV)
Esempio n. 28
0
def run_menu():

    global CURRENT_DAY
    global CURRENT_HOUR
    global CURRENT_MINUTES
    global CURRENT_AM_PM
    global CURRENT_MENU_CHOICE

    # Play the introduction audio
    sound.Play(INTRO_WAV)

    # Provide a minimal indication that the program has started.
    print(MINIMAL_HELP_STRING)

    # Get the first keystroke.
    c = readchar.readchar()

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the QUIT_MENU_KEY.
    while True:

        # Respond to the user's input.
        if c == FORWARD_KEY:

            # Advance the time, looping back around to the start.
            CURRENT_MENU_CHOICE += 1

            if CURRENT_MENU_CHOICE == len(MENU_CHOICES_WAV):
                CURRENT_MENU_CHOICE = 0

            sound.Play(MENU_CHOICES_WAV[CURRENT_MENU_CHOICE])

        if c == BACKWARD_KEY:

            # Retreat the time, looping back around to the end.
            CURRENT_MENU_CHOICE -= 1

            if CURRENT_MENU_CHOICE < 0:
                CURRENT_MENU_CHOICE = len(MENU_CHOICES_WAV) - 1

            sound.Play(MENU_CHOICES_WAV[CURRENT_MENU_CHOICE])

        if c == SET_KEY:

            #Run the sub-menu function. run_submenu() will determine what specific submenu to run based on the value of CURRENT_MENU_CHOICE
            run_submenu()

        if c == HELP_KEY:

            # Create and play the help audio. Starting with the current day and time.
            sound.combine_wav_files(TMP_FILE_WAV, IT_IS_WAV,
                                    DAYS_WAV[CURRENT_DAY],
                                    HOURS_WAV[CURRENT_HOUR],
                                    MINUTES_WAV[CURRENT_MINUTES],
                                    AM_AND_PM_WAV[CURRENT_AM_PM], HELP_WAV)
            sound.Play(TMP_FILE_WAV)

        # User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                return
        # The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()
Esempio n. 29
0
def run_menu():

    global CURRENT_TIME,LIMIT,days, sound_str,PHASE

    # Provide a minimal indication that the program has started.
    print("Starting program...\n")
    print(MINIMAL_HELP_STRING)

    # Get the first keystroke.
    c = readchar.readchar()

    # Special wav files for instructions
    instr_j = "my_sounds/j_to_quit.wav"
    instr_k = "my_sounds/k_for_up.wav"
    instr_l = "my_sounds/l_for_down.wav"
    semi_help = "my_sounds/semi_for_help.wav"
    space_to = "my_sounds/space_to.wav"
    restart = "my_sounds/restart.wav"
    space_conf = "my_sounds/space_to_confirm.wav"

    LIMIT = 7
    days = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday']
    sound_str = "sound_string.wav"
    index = ""

    # Endless loop responding to the user's last keystroke.
    # The loop breaks when the user hits the QUIT_MENU_KEY.
    while True:

        ##### Respond to the user's input.
        ##### User goes forwards scrolling
        if c == FORWARD_KEY:

            # Advance the time, looping back around to the start.
            CURRENT_TIME += 1
            if CURRENT_TIME == LIMIT:
                CURRENT_TIME = 0

            # Check if in Set Day phase
            if PHASE == 0:
                sound.Play(day_path + days[CURRENT_TIME] + "_f.wav")

            # Check phase to see if Hour Phase
            if PHASE == 1:
                get_hour(CURRENT_TIME)

            #Check if user is in Minute Phase
            if PHASE == 2:
                get_minutes(CURRENT_TIME)


        ##### User Goes backwards scrolling
        if c == BACKWARD_KEY:
            # Decrease the time, looping back around to the start.
            CURRENT_TIME -= 1
            if CURRENT_TIME < 0:
                CURRENT_TIME = LIMIT-1

            # Check if in Set Day phase
            if PHASE == 0:
                sound.Play(day_path + days[CURRENT_TIME] + "_f.wav")

            # Check phase to see if Hour phase
            if PHASE == 1:
                get_hour(CURRENT_TIME)

            # Check if User is in Minute Phase
            if PHASE == 2:
                get_minutes(CURRENT_TIME)

        ##### When user confirms selection
        if c == CONFIRM:
            # Check if user is at the end of the program
            if next_state() == 1:
                time.sleep(4)
                # GIve user choice to restart or quit program
                sound.combine_wav_files(sound_str,instr_j,space_to,restart)
                sound.Play(sound_str)

                # Get user's next key input
                c = readchar.readchar()
                # If the user decides to quit, the program will end
                if (c == QUIT_KEY):
                    sound.Play(EXITING_PROGRAM_WAV)
                    time.sleep(EXITING_PROGRAM_WAV_DURATION)
                    break
                # If the user decides to restart, the program will restart all its values
                # and start the user at setting the day of the week
                elif c == CONFIRM:
                    sound.Play(nav_path + "Set_day_of_week_f.wav")
                    CURRENT_TIME = 0
                    LIMIT = 7
                    PHASE = 0


        #### If the User presses for help
        if c == HELP:
            # Notify the user to press the button again
            sound.Play(nav_path + "Press_again_for_help_f.wav")
            # Get user's next keystroke
            c = readchar.readchar()

            # Give the user instructions of the key functions and current phase
            # of the program the user is in
            if c == HELP:
                if PHASE == 0:
                    help_day = nav_path + "Set_day_of_week_f.wav"
                    sound.combine_wav_files(sound_str,space_conf,instr_j,instr_k,instr_l,semi_help,help_day)
                    sound.Play(sound_str)
                elif PHASE == 1:
                    help_hour = nav_path + "Set_hour_f.wav"
                    sound.combine_wav_files(sound_str,space_conf,instr_j,instr_k,instr_l,semi_help,help_hour)
                    sound.Play(sound_str)
                elif PHASE == 2:
                    help_day = nav_path + "Set_minutes_f.wav"
                    sound.combine_wav_files(sound_str,space_conf,instr_j,instr_k,instr_l,semi_help,help_day)
                    sound.Play(sound_str)

        #### User quits.
        if c == QUIT_KEY:

            # Notify the user that another QUIT_MENU_KEY will quit the program.
            sound.Play(PRESS_AGAIN_TO_QUIT_WAV)

            # Get the user's next keystroke.
            c = readchar.readchar()

            # If the user pressed QUIT_MENU_KEY, quit the program.
            if c == QUIT_KEY:
                sound.Play(EXITING_PROGRAM_WAV)
                # A delay is needed so the sound gets played before quitting.
                time.sleep(EXITING_PROGRAM_WAV_DURATION)
                sound.cleanup()
                # Quit the program
                break


        ##### The user presses a key that will have no effect.
        else:
            # Get the user's next keystroke.
            c = readchar.readchar()