# Speak To Me # # *********** # TESTED ON: Python 3.9 on Raspbian Bullseye 64 bit (May 5 2023 release) # # Version 1.39 (May 20, 2023) # Fix AM/PM reading for times between 4 and 6 PM # # Version 1.38 (May 14, 2023) # Change bouncetime to 100ms # Add 0.1 seconds sleep before checking input # # Version 1.37 (May 14, 2023) # CHange bouncetime=100 # Debug statements for initial log file open # pause slightly after reading log file close # add sys.stdout.flush() after closing log file for read # add TIME_PRESSED to check for elapsed time and ignore quick press # set default start time to 0 # add delay after say_phrase before calling subprocess # # ??? use DEVNULL for stdin does it defaukt to subprocess.PIPE??? # ??? or use universal_newlines=True if it's a problem with ^M is lines # change log file open to log = open(name, "w", 1) # line-buffered # log.flush() in the main processes has no effect on the file buffers in the child processes # # Version 1.36 (May 13, 2023) # Check for internet connected inside say_phrase(sayAloud... # Play a prerecorded phrase when internet is down and don't exit program # Pull everything out of function and put into GPIO callback button and it works # add in folderName and description variables to GPIO if clause # # Version 1.35 (May 12, 2023) # Test code using Red button to call playAudioFromFolder("news", "CBC WORLD NEWS") # # Version 1.34 (May 12, 2023) # Set home_dir to script path # Change name of Client Secret File constant to CALENDAR_OAUTH_FILE # Test Green button to see if it will play from last spot stopped # Attempted to use SIGKILL to stop sox process when program killed but was not saving Aborted message in log file # Use SIGTERM when button pressed to retain ABORTED message in SOX Play log file # # Version 1.33 (May 10, 2023) # Check test GREEN button using trim parameter with stop/start and different times # Set SOX_CMD to full play path # Remove PLAYING_AUDIO constant - use SOX_ID instead # # Version 1.32 (May 9, 2023) # Add process ID to Audio Folder play function # Merge today and tomorrow's events into one button # Use another button for Audio Folder chapters # Add global SOX_ID to Audio Folder function # # Version 1.31 (May 9, 2023) # Test kill of subprocess when 4th button clicked # Stop playback if button press causes Sox process to be killed # # Version 1.30 (May 9, 2023) - edited from v 1.27 # Add cbc news to 4th button # # Version 1.27 (April 20, 2023) # Get start end dates collection before any announce events call # Version 1.26 (April 6, 2023) # Use shlex.split for popen args # add delay after popen # use creationflags=subprocess.DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP (windows) # start_new_session=True # # Version 1.25 (April 5, 2023) # Use sox -d instead of play # Change play command to use -d for sox device and - ta alsa to hide encode error # hard code home directory instaed of os.getcwd to work with rc.local # Tested use with rc.local and shell script # Change say_phrase back to using play command # # Version 1.24 (April 3, 2023) # Test version with cancelling GPIO inputs while button pressed # # Version 1.23 (March 29, 2023) # Change kill process back to SIGTERM # Split play command into array for all items separated by white space # Change subprocess.Popen call to specify executable parameter # # Version 1.22 (March 26, 2023) # Try to find out why process can't be killed # Split command into arguments and try running Popen with shell = False # Make sure to install latest RPi.GPIO (pip install RPi.GPIO==0.7.1) # Find way to add to rc.local to start program and exit (using nohup?) # # Version 1.20 (March 23, 2023) # Use terminate command for SOX_PROCESS instead of SIGTERM signal # Remove EXEC command in order to kill subprocess later # Add communicate after kill process # # Version 1.19 (March 23, 2023) # Add back in SUBPROCESS for call/Popen to use for termination # # Version 1.18 (March 23, 2023) # Use -t alsa to get rid of ALSA warning message # Fix subprocess to play mp3 chapters and save to log file with -t alsa # Replace Popen with Call and split of arguments for subprocess # # Version 1.17 (March 18, 2023) # Convert to latest Raspbian Bullseye 64 edition Feb 2023 # Use os.getcwd to set home_dir foldername for paths # Eliminate trying to say phrase when Internet connection not found # Change Button1_GPIO to GPIO 4 # # Version 1.16 (December 17, 2022) # Set environment variables to remove fork errors from grpcio # # Version 1.15 (December 11, 2022) # Assign meal times to blue button # Fix syntax error # Assign COLOR constants using GPIO constants # # Version 1.14 (December 7, 2022) # Remove leading zero from time of day hours # Remove deleted events (showing up as CANCELLED) # Fix detail of time of day for morning, afternoon and evening # Add split character to handle spaces in audio play filename # Notify aloud if no internet connection to Google # Fix button to say today and tomorrow # # Version 1.11 (September 4, 2022) # Modify buttons 3 and 4 to say TODAY and TOMORROW # # Version 1.10 (August 8, 2022) # Insert Audio Folder error message before playing # Check for no sox log file to restart playing at first file # # Version 1.09 (June 26, 2022) # Add NOSTART argument for testing # Adjust meal start times # Modify AM/PM to morning, afternoon, evening # Trim code to use one call back function with code dependent GPIO channel # # Version 1.06 (April 16, 2022) # Use full path to sox play command # Add audio folder description to playing audio phrase # # Version 1.05 (April 7, 2022) # Add second audio folder to play audio from # Replace AUDIO with AUDIO1 and AUDIO2 parameters on startup # Modify buttons to group meal and today/tomorrow # Modify buttons to play second audio folder # Modify Play_audio_from_folder to pass folder name # Modify sox log file to use audio folder # Remove welcome message from future events # # Version 1.04 (March 21, 2022) # Swap today/tomorrow with play audio folder buttons # Fix am to say A.M. # # Version 1.03 (March 17, 2022) # Add extra message for playing audio to use button to stop # Attach new button GPIOs # Add events for buttons # # Version 1.02 (March 6, 2022) # Add GPIO interrupts to test for button pushes # Add Internet connection testing # # Version 1.01 (March 1, 2022) # Add Audio option to play files in order from folder # # Version 1.00 (Feb 28, 2022) # Google TextToSpeech (TTS), # Google Calendar API, # sox audio player to play files from folder of mp3s # ********************************************************