Created
June 4, 2023 09:56
-
-
Save issadarkthing/30dfc29b49f40d3fad6133bab5b5f1b5 to your computer and use it in GitHub Desktop.
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
import re | |
import os | |
import sys | |
from playsound import playsound | |
def handle_text(text: str): | |
""" | |
Callback that is called upon detected text | |
""" | |
pattern = re.compile(r"^S.{2}\d+.") | |
match = pattern.search(text) | |
if match: | |
handle_alarm() | |
def resource_path(relative_path): | |
""" Get absolute path to resource, works for dev and for PyInstaller """ | |
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__))) | |
return os.path.join(base_path, relative_path) | |
def handle_alarm(): | |
""" | |
Handle processes when alarm is triggered on singaporean no plate | |
""" | |
print("Singaporean detected") | |
sound_file = resource_path("alarm.wav") | |
playsound(sound_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment