Last active
March 20, 2022 06:29
-
-
Save vishnudas-raveendran/c2602df83b0e8979913916ac7ff6442e to your computer and use it in GitHub Desktop.
For long running processes in Google colab, I will find it useful if there is some audio alert indicating end of processing. This processing often runs into hours. So I move-on to other errands, while doing those I don't want to be distracted checking in once in a while if the processing is completed. You can also use some chime like alerts here…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#For long running processes in Google colab, I will find it useful if there is some audio alert indicating end of processing. | |
#This processing often runs into hours. So I move-on to other errands. | |
#while doing those I don't want to be distracted checking in once in a while if the processing is completed.Hence the alert. | |
#You can also use some chime like alerts here, but with all the devices in the house including my laptop | |
#chiming all the time because of notifications. I would prefer this to be very specific, hence the voice prompt. | |
from gtts import gTTS | |
from IPython.display import Audio | |
import time | |
sound_file = 'processing_completed.wav' | |
TIME_INTERVAL_BETWEEN_VOICE_ALERTS_IN_SECONDS = 30 | |
tts = gTTS('Processing Completed') | |
tts.save(sound_file) | |
try: | |
while True: | |
audio = Audio(sound_file, autoplay=True) | |
display(audio) | |
time.sleep(TIME_INTERVAL_BETWEEN_VOICE_ALERTS_IN_SECONDS) #re-alert after 30 seconds | |
except KeyboardInterrupt: | |
print('End') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment