Skip to content

Commit

Permalink
sound on keypress
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Dec 21, 2023
1 parent 5675b5e commit 2e12cc3
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 16 deletions.
48 changes: 41 additions & 7 deletions core/overrides.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
from talon import Module, actions, Context
from talon import actions, Context, settings, Module, app

soundContext = Context()

class ActionClass:
ctx = Context()

disable_keypresses = False
sound_on_keypress = False

# Set psuedo tags for the user's settings that can be switched on and off
def set_tags():
global disable_keypresses, sound_on_keypress
disable_keypresses = True if settings.get("user.disable_keypresses", False) else False
sound_on_keypress = True if settings.get("user.sound_on_keypress", False) else False

app.register("ready", set_tags)

@ctx.action_class("main")
class MainOverrides():
def key(key: str):
"""Presses a key"""
actions.beep()
actions.next(key)
global disable_keypresses, sound_on_keypress

if settings.get("user.disable_keypresses", False) or disable_keypresses:
print("A key was pressed but sight-free-talon has disabled keypresses")
return

elif settings.get("user.sound_on_keypress", False) or sound_on_keypress:
actions.user.beep()

actions.next(key)


mod = Module()

@mod.action_class
class ActionsToCall():
def toggle_keypress_sound():
"""Toggles whether or not to play a sound on keypress"""
global sound_on_keypress
sound_on_keypress = not sound_on_keypress

def toggle_keypresses():
"""Toggles whether or not to pass keypresses through to the OS"""
global sound_on_keypress
sound_on_keypress = not sound_on_keypress
10 changes: 4 additions & 6 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@
desc="The volume of the text to speech",
)

mod.setting(
"tone_on_keypress",
type=bool,
default=False,
desc="If True, plays a tone on keypress to reduce the impact of accidental keypresses",
)

mod.setting("disable_keypresses", type=bool, default=False)
mod.setting("sound_on_keypress", type=bool, default=False)


mod.mode("strict_dictation", desc="Dictation mode with only a subset of dictation commands")
mod.mode('strict_command', desc='Command mode with only a subset of command commands')
2 changes: 1 addition & 1 deletion docs/src/philosophy.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Once content is made accessible to a screen reader, the main problem becomes syn

Large language models are the future of accessibility not just because they can dynamically create new content, but precisely because they are so good at eliminating that which is unnecessary.

This reason is why I write so much in Markdown. It is not necessarily the most efficient, but it is undoubtedly the most flexible. It is easy to export to HTML, PDFs, and is essentially the thinnest wrapper possible over plaintext while still maintaining a syntactic structure on the document as a whole. And as stated previously, what we need isn't just the ability to read everything aloud, but the aBig accessbility to tightly scope what _not_ to read. The more abstractions we place over the file that is being edited, the harder it becomes to process programmatically. That is why I do not like PowerPoint or Word. They have inaccessibility by obscurity.
This reason is why I write so much in Markdown. It is not necessarily the most efficient, but it is undoubtedly the most flexible. It is easy to export to HTML, PDFs, and is essentially the thinnest wrapper possible over plaintext while still maintaining a syntactic structure on the document as a whole. And as stated previously, what we need isn't just the ability to read everything aloud, but the ability to tightly scope what _not_ to read. The more abstractions we place over the file that is being edited, the harder it becomes to process programmatically. That is why I do not like PowerPoint or Word. They have inaccessibility by obscurity.

The Unix philosophy on the other hand is true universal design since in it, every program knows its place. Universality is not accomplished by each program individually, but rather by their composition.

Expand Down
5 changes: 3 additions & 2 deletions lib/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import base64, enum
from talon import Module, actions, ui, Context, ctrl, clip, registry
import os, requests
from .HTMLbuilder import HTMLBuilder
import threading

mod = Module()

Expand Down Expand Up @@ -85,4 +85,5 @@ class ActionsWin:

def beep(freq: int = 440, duration: int = 1000):
"""Beep"""
winsound.Beep(freq, duration)
t = threading.Thread(target=winsound.Beep, args=(freq, duration))
t.start()
6 changes: 6 additions & 0 deletions sight-free-settings.talon
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ settings():
# Output dictated text to braille display through your screen reader
user.braille_output = false

# To prevent errors from accidental key presses, play a sound each time a key is pressed
user.sound_on_keypress = false

# Disable keypresses from Talon in high risk contexts that cannot afford typos
user.disable_keypresses = false

### Relevant Community Settings Below ###
# Change key_wait if you want the screen reader to speak words
# at the same pace as if you were typing them manually.
Expand Down
3 changes: 3 additions & 0 deletions tts.talon
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ echo tab level:

toggle [screen] reader:
user.toggle_reader()

toggle keypress sound:
user.toggle_keypress_sound()

0 comments on commit 2e12cc3

Please sign in to comment.