zaz-talk2me/source/ZazTalk2Me.py

33 lines
823 B
Python

import uno
import unohelper
from com.sun.star.task import XJobExecutor
import easymacro as app
import nerd_dictation as nd
ID_EXTENSION = 'net.elmau.zaz.talk'
SERVICE = ('com.sun.star.task.Job',)
class ZazTalk2Me(unohelper.Base, XJobExecutor):
def __init__(self, ctx):
self.ctx = ctx
@app.run_in_thread
def trigger(self, args):
path_ext = app.paths.from_id(ID_EXTENSION)
path_model = app.paths.join(path_ext, 'model')
if args=='start':
nd.main_begin(vosk_model_dir=path_model, config_override=None)
app.info('Start')
elif args=='end':
nd.main_end()
app.info('End')
return
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(ZazTalk2Me, ID_EXTENSION, SERVICE)