Skip to content

Instantly share code, notes, and snippets.

@codewithpom
Created March 21, 2021 07:44
Show Gist options
  • Save codewithpom/31654706a68b909bc7d7b0368fc9d660 to your computer and use it in GitHub Desktop.
Save codewithpom/31654706a68b909bc7d7b0368fc9d660 to your computer and use it in GitHub Desktop.
Sets alarm at time for you plays the statement that you had given it according to your computer's time.
import datetime
import gtts
import playsound
import keyboard
time_to_wake_up = input("Enter time in HH:MM:SS")
time_to_wake_up = time_to_wake_up.replace(" ", "")
statement = input("What should I say when the time has reached")
audio = gtts.gTTS(text=statement, lang="en", slow=True)
print(audio)
audio.save("Sound.mp3")
print("Alarm set for "+time_to_wake_up)
while True:
now = datetime.datetime.now().strftime("%H:%M:%S")
if time_to_wake_up == now:
print("Wake up")
while True:
if keyboard.is_pressed("s"):
break
playsound.playsound("Sound.mp3")
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment