Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 4, 2024
1 parent e2b6414 commit ae88390
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions nvda/nvda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import time
from typing import ClassVar

from talon import Context, Module, actions, clip, cron, scope, settings, speech_system

mod = Module()
Expand Down
2 changes: 1 addition & 1 deletion voiceover/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VoiceOver

This integration is a work in progress. VoiceOver is difficult to customize or script since it is all closed source and most of the best APIs are only able to be queried via objc or swift, not Python unless ffi is brought into play.
This integration is a work in progress. VoiceOver is difficult to customize or script since it is all closed source and most of the best APIs are only able to be queried via objc or swift, not Python unless ffi is brought into play.

## Setup

Expand Down
9 changes: 5 additions & 4 deletions voiceover/voiceover.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from talon.mac import applescript


@ctx.action_class("user")
class MacActions:
def toggle_reader():
Expand All @@ -28,6 +29,7 @@ def with_voiceover_mod_press(key: str):

mod.tag("voiceover_running", desc="If set, voiceover is running")


@mod.scope
def set_voiceover_running_tag():
"""Update tags based on if voiceover is running"""
Expand All @@ -51,7 +53,7 @@ def is_voiceover_running() -> bool:
"""Returns true if voiceover is running"""
if os.name != "darwin":
return False

# TODO : figure out how a way to check this without spamming subprocesses
return False

Expand All @@ -78,17 +80,16 @@ def with_voiceover_mod_press(key: str):
class VoiceoverActions:
def tts(text: str, interrupt: bool = True):
"""text to speech with voiceover"""


def wrapper(text):
res = applescript.run(
f"""
f"""
tell application "VoiceOver"
output "{text}"
end tell
"""
)

# spawn it on a different thread so if it stalls we don't hang
cron.after("0s", lambda: wrapper(text))

12 changes: 4 additions & 8 deletions voiceover/voiceover.talon
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
os: mac

os: mac
-

read below: key(ctrl-alt-a)
next heading: key(cmd-ctrl-alt-h)
next heading: key(cmd-ctrl-alt-h)
previous heading: key(cmd-ctrl-alt-shift-h)
next landmark: key(ctrl-alt-cmd-n)

# TODO voiceover mod not working
reader help:
user.with_voiceover_mod_press("h")

screen curtain:
user.with_voiceover_mod_press("shift-fn-_")
reader help: user.with_voiceover_mod_press("h")

screen curtain: user.with_voiceover_mod_press("shift-fn-_")

0 comments on commit ae88390

Please sign in to comment.