Skip to content

Instantly share code, notes, and snippets.

@issadarkthing
Created June 4, 2023 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save issadarkthing/30dfc29b49f40d3fad6133bab5b5f1b5 to your computer and use it in GitHub Desktop.
Save issadarkthing/30dfc29b49f40d3fad6133bab5b5f1b5 to your computer and use it in GitHub Desktop.
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