Insert text directly in document

This commit is contained in:
El Mau 2022-04-20 22:00:05 -05:00
parent a29a7d0b81
commit fb124c35d0
4 changed files with 13 additions and 5 deletions

View File

@ -10,12 +10,10 @@ Dependencias:
Ubuntu
```
sudo apt install xdotool
pip install --user vosk
```
Arch
```
sudo pacman -S xdotool
pip install --user vosk
```

Binary file not shown.

View File

@ -20,12 +20,12 @@ class ZazTalk2Me(unohelper.Base, XJobExecutor):
path_ext = app.paths.from_id(ID_EXTENSION)
path_model = app.paths.join(path_ext, 'model')
nd.main_begin(vosk_model_dir=path_model, config_override=None)
app.info('Start')
return
def trigger(self, args):
if args=='start':
self._start()
app.info('Start')
elif args=='end':
nd.main_end()
app.info('End')

View File

@ -22,7 +22,7 @@
This is a utility that activates text to speech in Linux.
While it could use any system currently it uses the VOSK-API.
"""
import easymacro as app
# See: `hacking.rst` for developer notes.
# All built in modules.
@ -68,7 +68,15 @@ def run_xdotool(subcommand: str, payload: List[str]) -> None:
"--clearmodifiers",
] + payload
try:
subprocess.check_output(cmd)
# ~ print(cmd)
# ~ type or key
rango = app.selection.goto_end()
if subcommand == 'type':
word = payload[-1]
rango.string = word
else:
rango.go_left(count=len(payload), expand=True).string = ''
# ~ subprocess.check_output(cmd)
except FileNotFoundError as ex:
print("Command {!r} not found: {!s}".format(cmd_base, ex))
sys.exit(1)
@ -762,6 +770,8 @@ def text_from_vosk_pipe(
sys.stderr.write("--input %r not supported.\n" % input_method)
sys.exit(1)
# ~ print(cmd)
# ~ ('parec', '--record', '--rate=44100', '--channels=1', '--format=s16ne', '--latency=10')
ps = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout = ps.stdout