Last active
July 25, 2021 22:57
Revisions
-
tararoys revised this gist
Jul 25, 2021 . 1 changed file with 80 additions and 21 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,27 @@ from talon import Module, actions, noise, imgui, skia, canvas, cron from talon.types import Point2d import time noise_module = Module() #C:\\Users\\TalonBeginner\\AppData\\Roaming\\talon\\ morse_tree_guide = skia.Image.from_file("user\\TarasMasterTalonRepo\\morse code keyboard\\1599px-Morse-code-tree.png") morse_canvas = None global last_activity_at global history hiss_start_time = 0 hiss_end_time = 0 max_dot_time = 0.3 history = [] morse = { "dot": "e", "dot dot": "i", @@ -46,48 +62,75 @@ } def maybe_insert(): global history letter = history print( "last activity" + str(time.monotonic() - last_activity_at)) if(time.monotonic() - last_activity_at) >= 2: try: letter=morse[" ".join(letter)] print(letter) actions.insert(letter) history = [] except: print("no letter") history = [] #return "no letter" else: print("no letter") history= [] #return "no letter" def morse_canvas_draw(canvas): canvas.draw_image(morse_tree_guide, 500, 0) canvas.draw_points(canvas.PointMode.POLYGON, [Point2d(0, 0), Point2d(10, 10), Point2d(-10, -10), Point2d(10, -10), Point2d(-10, 10)]) @imgui.open(y=0) def gui(gui: imgui.GUI): global history gui.text("Morse History") gui.line() try: gui.text(morse[" ".join(history)]) except: gui.text("not a letter") gui.text(" ".join(history)) @noise_module.action_class class NoiseActions: def noise_pop(): """Invoked when the user does the pop noise.""" print("I'm a pop star.") def noise_hiss_start(): """Invoked when the user starts hissing (potentially while speaking)""" global hiss_start_time hiss_start_time = time.monotonic() pass def noise_hiss_stop(): """Invoked when the user finishes hissing (potentially while speaking)""" global hiss_start_time global hiss_end_time hiss_end_time = time.monotonic() global last_activity_at last_activity_at= time.monotonic() hiss_length_in_seconds = hiss_end_time - hiss_start_time print (hiss_length_in_seconds.__class__) @@ -98,8 +141,24 @@ def noise_hiss_stop(): else: history.append("dash") print(history) cron.after("2000ms", maybe_insert) pass def morse_history_toggle(): """Toggles viewing the morse_history""" global morse_canvas if morse_canvas is None: morse_canvas = canvas.Canvas(500, 0, 1599, 1000) if gui.showing: morse_canvas.unregister("draw", morse_canvas_draw) morse_canvas.hide() gui.hide() else: morse_canvas.register("draw", morse_canvas_draw) morse_canvas.show() gui.show() def pop_handler(blah): actions.user.noise_pop() -
tararoys revised this gist
Jul 25, 2021 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # short hiss to make a dot, long hiss to make a dash, pop to interpret the latest sequence of dots and dashes and type it as a letter. morse history: user.morse_history_toggle() -
tararoys renamed this gist
Jul 25, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes -
tararoys renamed this gist
Jul 25, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes -
tararoys revised this gist
Jul 25, 2021 . 1 changed file with 5682 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
tararoys created this gist
Mar 28, 2021 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,114 @@ from talon import Module, actions, noise import time noise_module = Module() global history morse = { "dot": "e", "dot dot": "i", "dot dot dot": "s", "dot dot dot dot": "h", "dot dot dot dot dot": "5", "dot dot dot dot dash": "4", "dot dot dot dash":"v", "dot dot dot dash dash":"3", "dot dot dash:":"u", "dot dot dash dot": "f", "dot dot dash dash dash": "2", "dot dash": "a", "dot dash dot":"r", "dot dash dot dot": "l", "dot dash dash": "w", "dot dash dash dot": "p", "dot dash dash dash": "j", "dot dash dash dash dash": "1", "dash": "t", "dash dot": "n", "dash dot dot": "d", "dash dot dot dot": "b", "dash dot dot dot dot": ".", "dash dot dot dot dash": "=", "dash dot dot dash": "x", "dash dot dash": "k", "dash dot dash dot": "c", "dash dot dash dash": "y", "dash dash": "m", "dash dash dot": "g", "dash dash dot dot": "z", "dash dash dot dash": "q", "dash dash dash": "o", "dash dash dash dot dot": "8", "dash dash das dash dot": "9", "dash dash dash dash dash": "0" } hiss_start_time = 0 hiss_end_time = 0 max_dot_time = 0.3 history = [] @noise_module.action_class class NoiseActions: def noise_pop(): """Invoked when the user does the pop noise.""" global history letter = history history = [] print(history) try: letter=morse[" ".join(letter)] print(letter) actions.insert(letter) except: print("no letter") return "no letter" else: print("no letter") return "no letter" def noise_hiss_start(): """Invoked when the user starts hissing (potentially while speaking)""" global hiss_start_time hiss_start_time = time.time() pass def noise_hiss_stop(): """Invoked when the user finishes hissing (potentially while speaking)""" global hiss_start_time global hiss_end_time hiss_end_time = time.time() hiss_length_in_seconds = hiss_end_time - hiss_start_time print (hiss_length_in_seconds.__class__) print("- sssss length of hiss:" + str(hiss_length_in_seconds)) if hiss_length_in_seconds < max_dot_time: history.append("dot") else: history.append("dash") print(history) pass def pop_handler(blah): actions.user.noise_pop() def hiss_handler(active): if active: actions.user.noise_hiss_start() else: actions.user.noise_hiss_stop() noise.register("pop", pop_handler) noise.register("hiss", hiss_handler)