Skip to content

Commit

Permalink
var
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Jan 11, 2024
1 parent 34cdc04 commit 3396bf9
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 21 deletions.
44 changes: 39 additions & 5 deletions core/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,46 @@ def on_title_switch(win):
def on_update_contexts():
global last_mode
modes = scope.get("mode") or []
if last_mode == "sleep" and "sleep" not in modes:
actions.user.tts(f"Talon has woken up")
elif last_mode != "sleep" and "sleep" in modes:
actions.user.tts(f"Talon has gone to sleep")
last_mode = "sleep" if "sleep" in modes else "other"

MIXED = ("command" in modes and "dictation" in modes)
COMMAND = ("command" in modes and "dictation" not in modes)
DICTATION = ("dictation" in modes and "command" not in modes)
SLEEP = ("sleep" in modes)
ANNOUNCE = settings.get("user.announce_mode_updates")

if last_mode == "sleep" and not SLEEP:
# ALways announce wake up
actions.user.tts(f"Talon now listening")

elif last_mode != "sleep" and SLEEP:
# Always announce sleep
actions.user.tts(f"Talon asleep")

elif last_mode != "sleep" and MIXED and last_mode != "mixed":
if ANNOUNCE:
actions.user.tts(f"Talon mixed mode")

elif last_mode != "sleep" and COMMAND \
and not DICTATION and not SLEEP and last_mode != "command":
if ANNOUNCE:
actions.user.tts(f"Talon command mode")

elif last_mode != "sleep" and \
DICTATION and not COMMAND \
and not SLEEP and \
last_mode != "dictation" \
and last_mode != "mixed":
if ANNOUNCE:
actions.user.tts(f"Talon dictation mode")

if SLEEP:
last_mode = "sleep"
elif MIXED:
last_mode = "mixed"
elif COMMAND:
last_mode = "command"
elif DICTATION:
last_mode = "dictation"

def on_ready():
# Only register these callbacks once all user settings and Talon
Expand Down
1 change: 0 additions & 1 deletion core/sapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
from collections import OrderedDict
import os

Expand Down
33 changes: 27 additions & 6 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,34 @@
)


mod.setting("disable_keypresses", type=bool, default=False)
mod.setting("sound_on_keypress", type=bool, default=False)
mod.setting("disable_keypresses",
type=bool,
default=False,
desc="If True, disables all keypresses to prevent accidental keypresses"
)

mod.setting("sound_on_keypress",
type=bool,
default=False,
desc="If True, plays a sound on every keypress to help prevent accidental keypresses"
)

mod.setting("min_until_break",
type=int,
default=10
)

mod.setting("min_until_break", type=int, default=10)
# mod.setting("break_length", type=int, default=10)
mod.setting("orca_key",
type=str,
default="capslock",
desc="The key that is used as the Orca modifier key"
)

mod.setting("announce_mode_updates",
type=bool,
default=True
)

mod.setting("orca_key", type=str, default="capslock")

# 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')
# mod.mode('strict_command', desc='Command mode with only a subset of command commands')
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [Quickstart](./quickstart.md)
- [Talon Intro](./talon-intro.md)
- [Sight-Free-Talon Commands](./commands.md)
- [Contributing](./CONTRIBUTING.md)
- [Philosophy](./philosophy.md)
- [Acknowledgements](./ATTRIBUTIONS.md)
24 changes: 24 additions & 0 deletions docs/src/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Commands Specific to Sight-Free Talon

Sight-Free-Talon has a series of voice commands and settings to make Talon easier to user alongside screen readers. Any general commands for dictating text or controlling your computer can be found in the central community repo, which you should also have installed.

## Commands

TODO

## Settings

All settings can be set within `.talon` files and contextually scoped to specific applications.

| Setting | Description | Default Value |
| ---------------------------------- | -------------------------------------------------------------------------------------- | ------------- |
| user.echo_dictation | Echo the subtitles from talon back via tts | true |
| user.tts_speed | How fast to play back text-to-speech -10 to 10 | 8 |
| user.tts_volume | How loud to play back text-to-speech from 0 to 100 | 80 |
| user.echo_context | Automatically echo the context of the focused window when switching applications/tabs | false |
| user.tts_via_screenreader | If a screen reader is enabled, use it for tts instead of the TTS engine in Talon | true |
| user.nvda_key | Key used for nvda modifier, change to 'insert' if that is your nvda modifier | 'capslock' |
| user.start_screenreader_on_startup | Start your screen reader automatically when Talon starts | false |
| user.braille_output | Output dictated text to braille display through your screen reader | false |
| user.sound_on_keypress | To prevent errors from accidental key presses, play a sound each time a key is pressed | false |
| user.disable_keypresses | Disable keypresses from Talon in high risk contexts that cannot afford typos | false |
2 changes: 1 addition & 1 deletion docs/src/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ git clone https://github.com/C-Loftus/sight-free-talon

and then updating it frequently with `git pull`. On Windows your user directory is located at `%APPDATA%\Talon\user`. On MacOS and Linux your user directory is located at `~/.talon/user`.

For GPT functionality, install the `talon-ai-tools` repo dependency in your Talon user directory by running
For AI/GPT functionality, install the `talon-ai-tools` repo dependency in your Talon user directory by running

```
git clone https://github.com/C-Loftus/talon-ai-tools
Expand Down
8 changes: 8 additions & 0 deletions docs/src/talon-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ You should have already installed Talon and the [community](https://github.com/t

This document is not a replacement for the wiki but is intended to be used as a quick way to briefly get an overview of the most important commands and most relevant behavior.

## Talon Brief Overview

Talon is a voice control engine. In order to have any behavior, you need to install scripts, the standard of which comes from the [community](https://github.com/talonhub/community/) repository. Each time you say a command within Talon, the voice model will try to match the command to the closest one that is defined and is contextually in scope. So, for instance, if there are specific commands to control Gmail, but you are not within Gmail, the command will likely be misrecognized. For this same reason, it is also very important to be in the proper mode. By default, there are two main modes: dictation mode and command mode. The former is for dictating raw text and the latter is for calling specific commands. If you are not in the proper mode but try to say a command that is defined in a different mode, Talon will likely still try to interpret the phrase, but it will be matched to something in the wrong mode.

### Debugging Talon Issues

If you are not getting the proper behavior within Talon, most of the time it is likely due to a poor microphone or an error in your scripts. You do not need a fancy microphone to have good performance with Talon; however, too much background noise, static, or fans are likely to cause issues. You should check the "save recordings" option within the Talon tray icon menu if you are getting poor recognition. This will allow you to hear what Talon hears for a given phrase.

## Helpful Standard Talon Commands

| Command | Description |
Expand Down
Empty file removed docs/src/tasks.md
Empty file.
49 changes: 48 additions & 1 deletion core/additional_voices/jaws.py → jaws/jaws.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# from __future__ import absolute_import
# import pywintypes

from talon import actions, Module, settings, cron, Context, clip, registry, app , speech_system
import os, ctypes, time

# class Jaws():
# """Supports the Jaws for Windows screen reader."""
Expand Down Expand Up @@ -33,4 +35,49 @@
# or win32gui.FindWindow("JFWUI2", "JAWS") != 0
# )
# except:
# return False
# return False


mod = Module()
ctx = Context()

mod.tag("jaws_running", desc="If set, JAWS is running")

@mod.scope
def set_jaws_running_tag():
'''Update tags based on if JAWS is running'''
# TODO edge case on startup this might not be set yet
try:
ctx.tags = ["user.jaws_running"] \
if actions.user.is_jaws_running() \
else []
except:
ctx.tags = []

if os.name == 'nt':
cron.interval("3s", set_jaws_running_tag.update)


@mod.action_class
class Actions:

def toggle_jaws():
'''Toggles JAWS on and off'''

def restart_jaws():
"""Restarts JAWS"""

def is_jaws_running() -> bool:
'''Returns true if JAWS is running'''

def jaws_tts(text: str, use_clipboard: bool= False):
'''text to speech with JAWS'''


ctxWindowsJAWSRunning = Context()
ctxWindowsJAWSRunning.matches = r"""
os: windows
tag: user.jaws_running
"""


1 change: 0 additions & 1 deletion lib/describe-images/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def extract_text():

active_win = ui.active_window().rect
actions.mouse_move(active_win.x, active_win.y)
actions.user.notify(str(active_win.x) + " " + str(active_win.y) + " " + str(active_win.width) + " " + str(active_win.height))
actions.key('super-shift-t')
actions.sleep("2s")
actions.mouse_drag(0)
Expand Down
1 change: 1 addition & 0 deletions orca/orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ def with_orca_mod_press(key: str):
class orcaActions:
def orca_tts(text: str, use_clipboard: bool= False):
"""text to speech with orca"""
# blocked until orca supports tts via a socket
7 changes: 7 additions & 0 deletions orca/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Orca Support

TODO. Blocked until tts via a socket is implemented.

## Notes

Orca is often out of date within Linux package managers (apt on Debian/Ubuntu for instance). Therefore, it is recommended to install from source or use a distribution like Arch or Fedora with packages that are updated more frequently. Once Orca implements support for a socket connection through which text-to-speech (TTS) can be sent, it is likely that older versions will stay in system package managers for a significant amount of time.
13 changes: 7 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ This repository integrates with:

# Usage

* Watch [my demo video](https://www.youtube.com/watch?v=i-XcpnVwvR0) for a quick overview
* The `.talon` files in each subdirectory contain scoped commands corresponding to each application or specific context
* The settings file at the root of the repository contains all user-configurable settings for this repo
- Watch [my demo video](https://www.youtube.com/watch?v=i-XcpnVwvR0) for a quick overview
- The `.talon` files in each subdirectory contain scoped commands corresponding to each application or specific context
- The settings file at the root of the repository contains all user-configurable settings for this repo

# Installing

* Clone the repo into your Talon user directory.
* Clone the [Talon community script repository](https://github.com/talonhub/community). That is the sole OS-agnostic dependency of this project.

- Clone the repo into your Talon user directory.
- Clone the [Talon community repository](https://github.com/talonhub/community).
- This is the sole OS-agnostic dependency of this project.

## OS Specific Setup

- Linux
Expand Down
3 changes: 3 additions & 0 deletions sight-free-settings.talon
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ settings():
# Disable keypresses from Talon in high risk contexts that cannot afford typos
user.disable_keypresses = false

# Speak Talon's mode (command, dictation, mixed) whenever it is changed
user.announce_mode_updates = true

# Every given number of minutes, send a notification, prompting you to rest your eyes
# user.enable_break_timer = true
# user.user.min_until_break = 10
Expand Down
6 changes: 6 additions & 0 deletions utils/log/log_parser.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Go program to parse the Talon log file and extract the last lines for each category.
We used a Go program instead of a Python program because we have to run
a subprocess and we can't be sure that another Python interpreter is available.
*/

package main

import (
Expand Down

0 comments on commit 3396bf9

Please sign in to comment.