Beispiel #1
0
from dragonfly import Dictation, Choice, ShortIntegerRef

from castervoice.lib import utilities
from castervoice.lib.actions import Text, Key
from castervoice.lib.util import recognition_history

_DBL_FIX_HISTORY = recognition_history.get_and_register_history(1)


def fix_dragon_double():
    try:
        lr = _DBL_FIX_HISTORY[len(_DBL_FIX_HISTORY) - 1]
        lu = " ".join(lr)
        Key("left/5:" + str(len(lu)) + ", del").execute()
    except Exception:
        utilities.simple_log(False)


# extras are common to both classes in this file
def extras_for_whole_file():
    return [
        Dictation("text"),
        ShortIntegerRef("n10", 1, 10),
        Choice(
            "first_second_third", {
                "first": 0,
                "second": 1,
                "third": 2,
                "fourth": 3,
                "fifth": 4,
                "six": 5,
Beispiel #2
0
from dragonfly import Function, Playback, RecognitionHistory, MappingRule

from castervoice.lib import settings
from castervoice.lib.ctrl.mgr.rule_details import RuleDetails
from castervoice.lib.merge.additions import IntegerRefST
from castervoice.lib.merge.state.actions import AsynchronousAction
from castervoice.lib.merge.state.short import R, L, S
from castervoice.lib.util import recognition_history

_history = recognition_history.get_and_register_history(10)


class Again(MappingRule):

    mapping = {
        "again (<n> [(times|time)] | do)":
        R(Function(lambda n: Again._create_asynchronous(n)), show=False),  # pylint: disable=E0602
    }
    extras = [IntegerRefST("n", 1, 50)]
    defaults = {"n": 1}

    @staticmethod
    def _repeat(utterance):
        Playback([(utterance, 0.0)]).execute()
        return False

    @staticmethod
    def _create_asynchronous(n):
        if len(_history) == 0:
            return
Beispiel #3
0
 def __init__(self):
     super(HistoryRule,
           self).__init__(settings.settings(["paths", "SM_HISTORY_PATH"]))
     self._history = recognition_history.get_and_register_history(20)
     self._preserved = None