Skip to content

Commit a6a9b66

Browse files
authored
Merge pull request qxresearch#32 from dhananjaypai08/Alarm
Alarm improvement
2 parents 4db5c7d + 39614f3 commit a6a9b66

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

Applications/Alarm/alarmtiming.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
from datetime import datetime
22
from playsound import playsound
3+
import winsound
4+
5+
36
#input the time in HH:MM where HH is hour and MM is minutes in 12 hour format
4-
alarm_date=input('Enter the date on which you want to set the alarm ').strip()
5-
alarm_time=''.join(input("Enter the time of alarm to be set: HH:MM AM/PM ").split())
7+
8+
9+
10+
alarm_date=input('Enter the date on which you want to set the alarm: ').strip()
11+
alarm_time=''.join(input("Enter the time of alarm to be set in HH:MM,AM/PM format: ").split())
12+
music_or_beep = input("Enter m for a music or b for beep sound: ")
13+
if music_or_beep=='b':
14+
dur=int(input("duration in seconds: "))*1000 #winsound takes in milliseconds
15+
freq = int(input("frequency of the noise: ")) #optimal- 500
616
alarm_hour=alarm_time[0:2]
717
alarm_minute=alarm_time[3:5]
8-
alarm_period=alarm_time[5:7].upper()
18+
alarm_period=alarm_time[6:8].upper()
19+
20+
21+
922
print('setting alarm.....')
23+
24+
25+
1026
while True:
1127
current_time=datetime.now()
1228
current_hour=current_time.strftime('%I')
@@ -17,5 +33,8 @@
1733
print('*'*10)
1834
print('| '+'Wake up!'+' |')
1935
print('*'*10)
20-
playsound('audio.wav')
36+
if music_or_beep=='m':
37+
playsound('audio.wav')
38+
else:
39+
winsound.Beep(freq,dur)
2140
break

0 commit comments

Comments
 (0)