| 1 |
#!/usr/bin/env python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Fenrir TTY screen reader |
| 5 |
# By Chrys, Storm Dragon, and contributors. |
| 6 |
|
| 7 |
import time |
| 8 |
|
| 9 |
|
| 10 |
class command: |
| 11 |
def __init__(self): |
| 12 |
pass |
| 13 |
|
| 14 |
def initialize(self, environment): |
| 15 |
self.env = environment |
| 16 |
|
| 17 |
def shutdown(self): |
| 18 |
pass |
| 19 |
|
| 20 |
def get_description(self): |
| 21 |
return "" |
| 22 |
|
| 23 |
def run(self): |
| 24 |
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool( |
| 25 |
"speech", "auto_read_incoming" |
| 26 |
): |
| 27 |
return |
| 28 |
|
| 29 |
if "pendingPromptText" not in self.env["commandBuffer"]: |
| 30 |
return |
| 31 |
|
| 32 |
pending_text = self.env["commandBuffer"]["pendingPromptText"] |
| 33 |
if not pending_text: |
| 34 |
return |
| 35 |
|
| 36 |
pending_time = self.env["commandBuffer"].get("pendingPromptTime", 0) |
| 37 |
delay = self.env["runtime"]["SettingsManager"].get_setting_as_float( |
| 38 |
"speech", "batch_flush_interval" |
| 39 |
) |
| 40 |
if time.time() - pending_time < delay: |
| 41 |
return |
| 42 |
|
| 43 |
self.env["runtime"]["OutputManager"].present_text( |
| 44 |
pending_text, interrupt=False, flush=False |
| 45 |
) |
| 46 |
self.env["commandBuffer"]["pendingPromptText"] = "" |
| 47 |
|
| 48 |
def set_callback(self, callback): |
| 49 |
pass |