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()
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
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 changeState(self, state): if (state == 0): self.dayButton[ "background"] = "light blue" # Light blue means currently selected self.minButton[ "background"] = "yellow" # yellow means not selected self.hourButton["background"] = "yellow" self.finishButton[ "background"] = "orange" # FINISH button is orange because it is special say_state = nav_path + "Set_day_f.wav" # Announce current state sound.Play(say_state) elif (state == 1): self.hourButton["background"] = "light blue" self.dayButton["background"] = "yellow" self.minButton["background"] = "yellow" self.finishButton["background"] = "orange" say_state = nav_path + "Set_hour_f.wav" sound.Play(say_state) elif (state == 2): self.minButton["background"] = "light blue" self.hourButton["background"] = "yellow" self.dayButton["background"] = "yellow" self.finishButton["background"] = "orange" say_state = nav_path + "Set_minutes_f.wav" sound.Play(say_state) elif (state == 3): self.minButton["background"] = "yellow" self.hourButton["background"] = "yellow" self.dayButton["background"] = "yellow" self.finishButton["background"] = "light blue" say_state = my_sounds_path + "finish.wav" sound.Play(say_state)
def verify_sound_filenames(): sound.Play(PRESS_AGAIN_TO_QUIT_WAV) sound.Play(EXITING_PROGRAM_WAV) sound.Play(YOU_SELECTED_WAV) sound.Play(NUMBERS_WAV[0]) sound.Play(NUMBERS_WAV[1]) sound.Play(NUMBERS_WAV[2]) sound.Play(NUMBERS_WAV[3]) sound.Play(AM_WAV) sound.Play(PM_WAV) sound.Play(INTRO_WAV)
def next_mode(self, event): print("SPACE") if (self._mode == 4 and self._exit): self.root.quit() # Gray out all sections self.dayTextLabel.config(bg="gray95") self.hourTextLabel.config(bg="gray95") self.minuteTextLabel.config(bg="gray95") self.AMPM_TextLabel.config(bg="gray95") self.exit_TextLabel.config(bg="gray95") # Increment the mode, ensure it does not exceed maximum self._mode += 1 if (self._mode > 5): self._mode = 0 # User in weekday mode if (self._mode == 0): print("SET WEEKDAY ***") sound.Play(self.SET_WEEKDAY_WAV) self.dayTextLabel.config(bg="yellow") # User in hour mode elif (self._mode == 1): print("SET HOUR ***") sound.Play(self.SET_HOUR_WAV) self.hourTextLabel.config(bg="yellow") # User in minute mode elif (self._mode == 2): print("SET MINUTE ***") sound.Play(self.SET_MINUTE) self.minuteTextLabel.config(bg="yellow") # User in AM/PM mode elif (self._mode == 3): print("SET AM/PM ***") #sound.Play(self.SET_AM_PM) self.AMPM_TextLabel.config(bg="yellow") elif (self._mode == 4): print("EXIT ***") self.exit_TextLabel.config(bg="yellow") # User in time report mode else: text = "AM" if (not self._isAM): text = "PM" weekdays = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] print(weekdays[self._day] + ",", str(self._hour + 1) + ":" + \ str("{:02}".format(self._minute * 5)), text) self.display_time() self.play_complete_time()
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")
def play_current_state(state): if (state == 0): # Announce state for setting the day of the week sound.Play(SET_WEEKDAY_WAV) elif (state == 1): # Announce state for setting the hour sound.Play(SET_HOUR_WAV) elif (state == 2): # Announce state for setting the minute sound.Play(SET_MINUTE) elif (state == 3): # Announce state for setting AM or PM sound.Play(SET_AM_PM)
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 arrow_init(): self.arrow = PhotoImage(file="arrow.pgm") self.arrowImage = Label(root, image=self.arrow) self.arrowXPosition = 0 self.arrowYPosition = 20 self.arrowImage.place(x=self.arrowXPosition, y=self.arrowYPosition) sound.Play("wav_files_provided/miscellaneous_f/Set_day_f.wav" ) #initial selection
def next_mode(self, event): if (self._mode == 4 and self._exit): self.root.quit() # Gray out all sections self.dayTextLabel.config(bg="gray95") self.hourTextLabel.config(bg="gray95") self.minuteTextLabel.config(bg="gray95") self.AMPM_TextLabel.config(bg="gray95") self.exit_TextLabel.config(bg="gray95") # Increment the mode, ensure it does not exceed maximum self._mode += 1 if (self._mode > 5): self._mode = 0 # Disable forward and backward buttons when in time report mode if (self._mode == 5): self.forwardButton.config(state="disabled") self.backwardButton.config(state="disabled") # Re-enable the buttons otherwise else: self.forwardButton.config(state="normal") self.backwardButton.config(state="normal") # User in weekday mode if (self._mode == 0): sound.Play(self.SET_WEEKDAY_WAV) self.dayTextLabel.config(bg="yellow") # User in hour mode elif (self._mode == 1): sound.Play(self.SET_HOUR_WAV) self.hourTextLabel.config(bg="yellow") # User in minute mode elif (self._mode == 2): sound.Play(self.SET_MINUTE) self.minuteTextLabel.config(bg="yellow") # User in AM/PM mode elif (self._mode == 3): sound.Play(self.SET_AM_PM) self.AMPM_TextLabel.config(bg="yellow") elif (self._mode == 4): self.exit_TextLabel.config(bg="yellow") # User in time report mode else: self.display_time() self.play_complete_time()
def setMinuteButtonClick(self): set_day_button.configure(highlightbackground="white") set_hour_button.configure(highlightbackground="white") set_minute_button.configure(highlightbackground="green") setDay = False setHour = False setMinutes = True MyApp.index_set_settings = 2 sound.Play(voices[2])
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]])
def button3Click(self, event=None): print("space") if self.arrowYPosition == 20: #menu list if self.arrowXPosition == 0: #days self.arrowXPosition = 0 self.arrowYPosition = self.arrowYPosition + 60 #move to day list elif self.arrowXPosition == 100: #hours self.arrowXPosition = 0 self.arrowYPosition = self.arrowYPosition + 120 #move to hour list elif self.arrowXPosition == 200: #minutes self.arrowXPosition = 0 self.arrowYPosition = self.arrowYPosition + 180 #move to minute list elif self.arrowXPosition == 300: #exit #close program sound.Play( "wav_files_provided/miscellaneous_f/Exiting_program_f.wav") #delay before closing window self.myParent.after(1090, lambda: self.myParent.destroy()) self.menuLabels[self.menuX].config( bg="red" ) #menu selection is red while chosing from other lists else: #selecting from one of the lists if self.arrowYPosition == 80: #days for i in range(7): self.dayLabels[i].config( bg="white" ) #if a selection was previously made, change it self.dayLabels[self.day].config( bg="blue") #highlight selection self.day = 0 #reinitialize counter elif self.arrowYPosition == 140: for i in range(24): self.hourLabels[i].config(bg="white") self.hourLabels[self.hour].config(bg="blue") self.hour = 0 else: for i in range(12): self.minuteLabels[i].config(bg="white") self.minuteLabels[self.minute].config(bg="blue") self.minute = 0 #move back to menu list after selection self.arrowXPosition = 0 self.arrowYPosition = 20 self.menuX = 0 for i in range(4): self.menuLabels[i].config(bg="white") #clear highlight self.arrowImage.place(x=self.arrowXPosition, y=self.arrowYPosition) report_event(self, event) ### (4)
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)
def run_menu(): global CURRENT_TIME # Provide a minimal indication that the program has started. print(MINIMAL_HELP_STRING) #Play all key assignments sound.Play(INTRO_WAV) time.sleep(3) sound.Play(HELP_WAV) time.sleep(2) sound.Play(DOWN_WAV) time.sleep(2.5) sound.Play(UP_WAV) time.sleep(2.5) sound.Play(SELECT_WAV) time.sleep(3) #Initialize selection process set_day()
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
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
def k_edit(self, event): select = 0 # values that represent the labels k = 0 # in which the user's index will correspond to j = 0 # When the user wants to edit the day if (self.state_index == 0): select = self.current_day + 1 k = select + 1 j = select - 1 if (select == self.day_limit): select = 0 k = 1 if (k == self.day_limit): k = 0 if (j == -1): j = 6 # Chnage text in labels according to current index self.selection["text"] = self.days_list[select] self.k_index["text"] = self.days_list[k] self.j_index["text"] = self.days_list[j] sound.Play(days_path + self.days_list[select] + "_f.wav") # Announce current day self.current_day = select # Editing the hour elif (self.state_index == 1): select = self.current_hour + 1 k = select + 1 j = select - 1 self.setHour(select, k, j) # Call function to set Hour labels for us # Editing the minutes elif (self.state_index == 2): select = self.current_min + 1 k = select + 1 j = select - 1 self.setMin(select, k, j) # Call function to set minute labels for us # Update GUI to changes made in labels self.selection.update_idletasks() self.k_index.update_idletasks() self.j_index.update_idletasks()
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)
def makesounds(self): mp = "wav_files_provided/miscellaneous_f/" np = "wav_files_provided/numbers_f/" dp = "wav_files_provided/days_of_week_f/" menulist = [ mp + "Set_day_f.wav", mp + "Set_hour_f.wav", mp + "Set_minute_f.wav", mp + "Exit_program_f.wav" ] daylist = [ dp + "monday_f.wav", dp + "tuesday_f.wav", dp + "wednesday_f.wav", dp + "thursday_f.wav", dp + "friday_f.wav", dp + "saturday_f.wav", dp + "sunday_f.wav" ] hourlist = [ np + "01_f.wav", np + "02_f.wav", np + "03_f.wav", np + "04_f.wav", np + "05_f.wav", np + "06_f.wav", np + "07_f.wav", np + "08_f.wav", np + "09_f.wav", np + "10_f.wav", np + "11_f.wav", np + "12_f.wav", np + "01_f.wav", np + "02_f.wav", np + "03_f.wav", np + "04_f.wav", np + "05_f.wav", np + "06_f.wav", np + "07_f.wav", np + "08_f.wav", np + "09_f.wav", np + "10_f.wav", np + "11_f.wav", np + "12_f.wav" ] minutelist = [ np + "00_f.wav", np + "01_f.wav", np + "02_f.wav", np + "03_f.wav", np + "04_f.wav", np + "05_f.wav", np + "06_f.wav", np + "07_f.wav", np + "08_f.wav", np + "09_f.wav", np + "10_f.wav", np + "11_f.wav", np + "12_f.wav", np + "13_f.wav", np + "14_f.wav", np + "15_f.wav", np + "16_f.wav", np + "17_f.wav", np + "18_f.wav", np + "19_f.wav", np + "20_f.wav", np + "21_f.wav", np + "22_f.wav", np + "23_f.wav", np + "24_f.wav", np + "25_f.wav", np + "26_f.wav", np + "27_f.wav", np + "28_f.wav", np + "29_f.wav", np + "30_f.wav", np + "31_f.wav", np + "32_f.wav", np + "33_f.wav", np + "34_f.wav", np + "35_f.wav", np + "36_f.wav", np + "37_f.wav", np + "38_f.wav", np + "39_f.wav", np + "40_f.wav", np + "41_f.wav", np + "42_f.wav", np + "43_f.wav", np + "44_f.wav", np + "45_f.wav", np + "46_f.wav", np + "47_f.wav", np + "48_f.wav", np + "49_f.wav", np + "50_f.wav", np + "51_f.wav", np + "52_f.wav", np + "53_f.wav", np + "54_f.wav", np + "55_f.wav", np + "56_f.wav", np + "57_f.wav", np + "58_f.wav", np + "59_f.wav" ] self.sounds = [menulist, daylist, hourlist, minutelist] self.specialsounds = [ "tmp_file_p782s8u.wav", mp + "you_selected_f.wav", mp + "AM_f.wav", mp + "PM_f.wav" ] sound.Play(self.sounds[0][0])
def report_event(self, event): ### (5) if self.arrowYPosition == 20: #menu list sounds if self.arrowXPosition == 0: sound.Play("wav_files_provided/miscellaneous_f/Set_day_f.wav") elif self.arrowXPosition == 100: sound.Play("wav_files_provided/miscellaneous_f/Set_hour_f.wav") elif self.arrowXPosition == 200: sound.Play("wav_files_provided/miscellaneous_f/Set_minute_f.wav") else: sound.Play("wav_files_provided/miscellaneous_f/Exit_program_f.wav") elif self.arrowYPosition == 80: #day audio sound.Play("wav_files_provided/days_of_week_f/" + self.days[self.day] + "_f.wav") elif self.arrowYPosition == 140: #hour audio sound.Play("wav_files_provided/numbers_f/" + self.hours[self.hour] + "_f.wav") else: #minute audio sound.Play("wav_files_provided/numbers_f/" + self.minutes[self.minute] + "_f.wav")
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
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
def j_edit(self, event): select = 0 k = 0 j = 0 if (self.state_index == 0): select = self.current_day - 1 k = select + 1 j = select - 1 if (select == -1): select = 6 if (k == self.day_limit): k = 0 if (j == -1): j = 6 self.selection["text"] = self.days_list[select] self.k_index["text"] = self.days_list[k] self.j_index["text"] = self.days_list[j] sound.Play(days_path + self.days_list[select] + "_f.wav") self.current_day = select elif (self.state_index == 1): select = self.current_hour - 1 k = select + 1 j = select - 1 self.setHour(select, k, j) elif (self.state_index == 2): select = self.current_min - 1 k = select + 1 j = select - 1 self.setMin(select, k, j) # Update display of gui to changes made in labels self.selection.update_idletasks() self.k_index.update_idletasks() self.j_index.update_idletasks()
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()
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()
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" ) # print(self.day) # print(self.hour) # print(self.minute) # print(self.ampm) # if(self.day != self.target_dates[trial_count-1][0] # and self.hour != self.target_dates[trial_count-1][1] # and self.minute != self.target_dates[trial_count-1][2] # and self.ampm != self.target_dates[trial_count-1][3] # ): # f.write(["Wrong date entered!" + str(trial_count)]) # print("Wrong date entered!") 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) self.button3.config(relief=tk.SUNKEN, background=self.cursor_Col) self.button3.after(150, lambda: self.button3.config(relief=tk.SOLID, background="#ffffff"))
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"))