From dc9081b49b1ba2b7a2f88e1ecc18809b4f9f1e33 Mon Sep 17 00:00:00 2001 From: avyay jain <63355322+avyayjain@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:34:43 +0530 Subject: [PATCH 1/7] set alarm using speech recogntion --- alaram using speech recognition/alarm.py | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 alaram using speech recognition/alarm.py diff --git a/alaram using speech recognition/alarm.py b/alaram using speech recognition/alarm.py new file mode 100644 index 000000000..11d29cb7c --- /dev/null +++ b/alaram using speech recognition/alarm.py @@ -0,0 +1,70 @@ +import speech_recognition as sr +import winsound +import datetime +import pyttsx3 + + +engine = pyttsx3.init() + + +def speech(audio): + engine.setProperty('rate', 200) + voices = engine.getProperty('voices') + engine.setProperty('voice', voices[0].id) + engine.say(audio) + engine.runAndWait() + + +def takeCommand(): + + r = sr.Recognizer() + with sr.Microphone() as source: + r.adjust_for_ambient_noise(source, duration=1) + print() + print("Listening...") + print() + audio = r.listen(source) + + try: + print("Recognizing...") + print() + query = r.recognize_google(audio, language='en-in') + print(f"you said: {query}\n") + + except Exception as e: + print("Say that again please...") + print() + print(e) + return "None" + return query + + +def alarm(Timing): + + altime = str(datetime.datetime.now().strptime(Timing, "%I:%M %p")) + altime = altime[11:-3] + print(altime) + Horeal = altime[:2] + Horeal = int(Horeal) + Mireal = altime[3:5] + Mireal = int(Mireal) + + print(f"Done, alarm is set for {Timing}") + + while True: + if Horeal == datetime.datetime.now().hour and Mireal == datetime.datetime.now().minute: + print("alarm is running") + winsound.PlaySound('abc', winsound.SND_LOOP) + + elif Mireal < datetime.datetime.now().minute: + break + + +speech("say set alarm for 5:30 am ") + +print("say set alarm for 5:30 am") +tt = takeCommand() +tt = tt.replace("set alarm to ", "") +tt = tt.replace(".", "") +tt = tt.upper() +alarm(tt) From dc7f8d46f6bae7ccd6664b23513c85f98231ce09 Mon Sep 17 00:00:00 2001 From: avyay jain <63355322+avyayjain@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:43:14 +0530 Subject: [PATCH 2/7] Create Readme.md --- alaram using speech recognition/Readme.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 alaram using speech recognition/Readme.md diff --git a/alaram using speech recognition/Readme.md b/alaram using speech recognition/Readme.md new file mode 100644 index 000000000..fddda27da --- /dev/null +++ b/alaram using speech recognition/Readme.md @@ -0,0 +1,9 @@ +this is a speech recognition alarm in this you just simply have to say "set alarm for 5:30 am" and it will simpily set an alarm for you + +for this to work you just have to install the following libraries + +1.datetime +2.winsound +3.sepeech_Recognition +4.pyttx3 + From 40a4c553fba5c1ac916ae74a54cbc46d496de766 Mon Sep 17 00:00:00 2001 From: avyay jain <63355322+avyayjain@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:56:28 +0530 Subject: [PATCH 3/7] Update Readme.md --- alaram using speech recognition/Readme.md | 33 ++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/alaram using speech recognition/Readme.md b/alaram using speech recognition/Readme.md index fddda27da..eff7a4899 100644 --- a/alaram using speech recognition/Readme.md +++ b/alaram using speech recognition/Readme.md @@ -1,9 +1,30 @@ -this is a speech recognition alarm in this you just simply have to say "set alarm for 5:30 am" and it will simpily set an alarm for you +# Alarm using speech recognition -for this to work you just have to install the following libraries -1.datetime -2.winsound -3.sepeech_Recognition -4.pyttx3 + +## Steps to set an alarm : +1. run the script `AlarmClock.py` using python3. + On Unix based systems the command looks like : + ```bash + python3 Alarm.py + ``` + or + ```bash + python Alarm.py + ``` + +2. After execution of the script you will be prompted to say the time to set an alarm in HH:MM format. Which looks something as shown below : + ``` + say "set alarm for (for eg)5:30am" + `` + +3. Then you will get a looping output of the current time and set time on the CLI as shown below : + ``` + set alarm for 5:30am + +4. When the alarm goes off you will __hear a sound__ and get the following lines on the prompt : + ``` + Time to Wake up + + ``` From 7cbf3fd515e28acf210da06399017aba3d698df1 Mon Sep 17 00:00:00 2001 From: avyay jain <63355322+avyayjain@users.noreply.github.com> Date: Thu, 7 Oct 2021 11:08:04 +0530 Subject: [PATCH 4/7] Update alarm.py --- alaram using speech recognition/alarm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alaram using speech recognition/alarm.py b/alaram using speech recognition/alarm.py index 11d29cb7c..dc7d4c4d1 100644 --- a/alaram using speech recognition/alarm.py +++ b/alaram using speech recognition/alarm.py @@ -53,7 +53,7 @@ def alarm(Timing): while True: if Horeal == datetime.datetime.now().hour and Mireal == datetime.datetime.now().minute: - print("alarm is running") + print("alarm is running please exit the program") winsound.PlaySound('abc', winsound.SND_LOOP) elif Mireal < datetime.datetime.now().minute: From e1c841aa9d04763394f955aa3b03c2ea5b2c8d07 Mon Sep 17 00:00:00 2001 From: Pawan Jain <42181691+pawangeek@users.noreply.github.com> Date: Thu, 7 Oct 2021 11:35:14 +0530 Subject: [PATCH 5/7] Rename alaram using speech recognition/Readme.md to speech_alarm/README.md --- .../Readme.md => speech_alarm/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename alaram using speech recognition/Readme.md => speech_alarm/README.md (100%) diff --git a/alaram using speech recognition/Readme.md b/speech_alarm/README.md similarity index 100% rename from alaram using speech recognition/Readme.md rename to speech_alarm/README.md From b404f7ff1497a700692dca43a59c4f02a75e26b1 Mon Sep 17 00:00:00 2001 From: Pawan Jain <42181691+pawangeek@users.noreply.github.com> Date: Thu, 7 Oct 2021 11:35:47 +0530 Subject: [PATCH 6/7] Rename alaram using speech recognition/alarm.py to speech_alarm/script.py --- .../alarm.py => speech_alarm/script.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename alaram using speech recognition/alarm.py => speech_alarm/script.py (100%) diff --git a/alaram using speech recognition/alarm.py b/speech_alarm/script.py similarity index 100% rename from alaram using speech recognition/alarm.py rename to speech_alarm/script.py From e793f7cb65d5af822b999c92aa87b9acf3b96ea4 Mon Sep 17 00:00:00 2001 From: Pawan Jain <42181691+pawangeek@users.noreply.github.com> Date: Thu, 7 Oct 2021 11:39:32 +0530 Subject: [PATCH 7/7] Update README.md --- speech_alarm/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/speech_alarm/README.md b/speech_alarm/README.md index eff7a4899..5eb0000eb 100644 --- a/speech_alarm/README.md +++ b/speech_alarm/README.md @@ -1,7 +1,5 @@ # Alarm using speech recognition - - ## Steps to set an alarm : 1. run the script `AlarmClock.py` using python3. On Unix based systems the command looks like : @@ -27,4 +25,3 @@ Time to Wake up ``` -