Last active
May 23, 2023 08:56
-
-
Save glowinthedark/c4a9acd99a9f225c52f834c92fc7926a to your computer and use it in GitHub Desktop.
Read aloud MacOS notifications using TTS voice synthesis
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
set previousList to {} | |
repeat | |
set currentList to {} | |
tell application "System Events" | |
tell process "Notification Center" | |
set allWindows to every window | |
set numWindows to count of allWindows | |
repeat with currentWindow in allWindows | |
try | |
set _groups to groups of UI element 1 of scroll area 1 of group 1 of currentWindow | |
repeat with _group in _groups | |
set AppleScript's text item delimiters to ", " -- Set the separator | |
set notifList to value of static text of _group | |
set notif to notifList as string -- Convert the list to a string | |
set end of currentList to notif | |
-- ignoring case -- make comparisons case-insensitive | |
-- -- filter by contains... | |
-- if (notif contains "Slack" or notif contains "SENSITIVE") then | |
-- set end of currentList to notif | |
-- end if | |
-- -- filter by not contains | |
-- if not (notif contains "junk1" or notif contains "junk2") then | |
-- set end of currentList to notif | |
-- end if | |
-- end ignoring | |
end repeat | |
on error errorMsg | |
log "An error occurred: " & errorMsg | |
end try | |
end repeat | |
end tell | |
end tell | |
if currentList is not equal to previousList then | |
repeat with notificationText in currentList | |
say notificationText | |
--say notificationText using "Daniel (Enhanced)" | |
end repeat | |
set previousList to currentList | |
end if | |
delay 1 | |
end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment