Skip to content

Instantly share code, notes, and snippets.

[unary_method]
"reper"= "repr"
"stir"= "str"
"len"= "len"
"name"= "name"
"Unicode"= "unicode"
"size of"= "sizeof"
"dir"= "dir"
"int"= "int"
import toml
import io
from dragonfly import (Grammar, Context, AppContext, Dictation, Key, Text, Repeat,
Function, Choice, Mouse, MappingRule)
from castervoice.lib import navigation, alphanumeric, textformat, text_utils
from castervoice.lib import control
from castervoice.lib.dfplus.additions import IntegerRefST
from castervoice.lib.dfplus.merge.ccrmerger import CCRMerger
from castervoice.lib.dfplus.merge.mergerule import MergeRule
from castervoice.lib.dfplus.state.short import R
from castervoice.lib.imports import *
_NEXUS = control.nexus()
def fix_dragon_double(nexus):
try:
lr = nexus.history[len(nexus.history) - 1]
lu = " ".join(lr)
Key("left/5:" + str(len(lu)) + ", del").execute()
#
# This file is a command-module for Dragonfly.
# (c) Copyright 2008 by Christo Butcher
# Licensed under the LGPL, see <http://www.gnu.org/licenses/>
#
"""
Command-module for Chrome
"""
------------------
Grammar(chrome): 3 rules (1 exported, 0 imported):
- ChromeRule(chrome) 1571
- Alternative(...) 1570
- Compound('[<click_by_voice_options>] <numbers>') 376
- Sequence(...) 375
- Optional(...) 18
- Choice(..., name='click_by_voice_options') 17
- Compound('click') 2 (+ 1 trivial direct child)
- Compound('copy') 2 (+ 1 trivial direct child)
<?xml version="1.0" encoding="utf-16"?>
<!DOCTYPE WordExport SYSTEM "http://dragoncontent.nuance.com/dtds/Words10.dtd">
<WordExport NatspeakVersion="15.00.000.076" NatspeakEdition="ProfessionalIndividual" User="alex_profile_10-2018 - Copy_july-2019" Topic="math" Language="ENX" MRECVersion="1.35.100.17944">
<Word name="math alpha">
<ITN-RuleInfo rewriteActive="true" paramHandle="-1" paramValue="" userData="">
<RewriteText>
<![CDATA[$\alpha$]]>
__version__ = "$Revision: 105 $, $Date: 2008-12-04 12:47:13 +0100 (do, 04 dec 2008) $, $Author: quintijn $"
# Python Macro Language for Dragon NaturallySpeaking
# (c) Copyright 1999 by Joel Gould
# Portions (c) Copyright 1999 by Dragon Systems, Inc.
#
# This code simulates the basic text formatting from NatSpeak.
#
# code written by Joel Gould, posted on the natpython discussion list on Wed, 28 Aug 2002
#
# inserted in the unimacro package june 2006
from dragonfly import *
import nsformat
formatting_state = None #
def format_dictation(dictation, input_state):
formatted_output, output_state = nsformat.formatWords(str(dictation), state=input_state)
formatted_output = str(formatted_output)
Text(formatted_output).execute()
global formatting_state # I'm not sure if I'm managing the state properly here,I don't know how to properly do that in Python
formatting_state = output_state
def make_averager():
count = 0
total = 0
def averager(new_value):
# nonlocal count, total # doesn't work
# global count, total
count = count + 1
total = total + new_value
print(total/count)
return total/count
from dragonfly import *
import nsformat
dictation_length = [] # for "scratch that" purposes
input_state = None
""" Note: if you pass in the input state into the function using the function action rather than just accessing it
from within the function using the fact that it is in global scope, the input state will not be updated
when you run the dictation command multiple times
To see what I mean note that in contrast to the approach here, the approach taken
at the following link does not update the state after each dictation utterance