Open Holzhaus opened 9 years ago
Haha, love the drawing.
Good overall first impression. Charlie and I'll think about this for a few days and provide some more specific feedback! Thanks for putting a lot of thought into this.
Thanks for waiting-- we just finished up with exams on this end!
I'm excited about all of these ideas. Here's my quick reactions for discussion:
populate.py
altogether. ~/.jasper/plugins
would also be fantastic to have.So generally: I think these are good features! Eager to see the implementation you mentioned
Concerning 2: Instead of using Sockets directly, I used the XMLRPC server built into Python. The usage example would be either to use it for testing or to create an Android App that uses the Google API to transcribe speech directly on the phone, then sends the command to Jasper and then outputs the answer on the phone again.
Concering 3: The good thing: You can still use a phrase consisting only of a single word (like "WEATHER"). So the simple modules will need to change the API calls, but the usage remains the same. More complex modules like MusicMode could stop running in their own "mode" entirely, but register a phrase like "Load playlist {playlist}" globally instead, which would simplify and speed up usage a lot.
I'll upload my example implementation soon.
There it is: https://github.com/Holzhaus/jasper-plugin-draft The localization part is still missing.
Please have a look and tell me what you think.
Ah, OK. Yes, the applications for XMLRPC seem to be compelling use cases, so let's go forward with that too then.
Good point about global grammar registration-- I too would prefer that MusicMode not steal its own "mode".
The plugin draft looks fantastic. I like the inheritance from SpeechHandlerPlugin
and .jasperplugin
config files.
(Side note... you might've dealt with this already: I had to cast the slugify arguments in unicode()
to get app.py
to run)
https://github.com/Holzhaus/jasper-plugin-draft/blob/master/core/configmanager.py#L48
https://github.com/Holzhaus/jasper-plugin-draft/blob/master/core/pluginmanager.py#L292
Whoops, I accidently tested with Python3 instead of Python2. In Python3, all strings are unicode. I'll add that as soon as I finished my exams ;-)
What's still missing is a good way to implement the multi-language stuff. I'd like to use a directory structure like this, so that every plugins has the translations stored in it's own folder.
plugins/
plugin1/
plugin1.jasperplugin
plugin1.py
locale/
en_US/
plugin1.mo
de_DE/
plugin1.mo
@shbhrsaha @crm416 After I finally finished both my exam period and the massive chillout period that necessarily followed it, I had some time to work on the plugin system draft. I now got multilanguage (based on gettext) working for speech handler plugins. Thus, most basic plugin stuff is finished. Please have a look at the respective git repo.
For testing purposes, you can change the default language in app.py
to de_DE
: All plugins that do not support that language should be rejected automatically.
The plugin structure has been simplified a bit:
plugins/
plugin1/
plugin1.jasperplugin
plugin1.py
languages/
en_US.mo
de_DE.mo
There still some remaining issues:
*.jasperplugin
file. Any ideas?en_GB.mo
file. Shall we reduce the available set of languages to just the base language (without the region, i.e. en.mo
instead of en_US.mo
)? Or shall we allow the language config key to be a comma-separated list of languages (ordered by preference). A third option: we define that plugins should always have the base language mo file (en.mo
) and can optionally add the regional language file, so that the user can safely set his language to en_GB
- if en_GB.mo
does not exist, en.mo
is used (But what is en
? British English or American?).EventHandler
(a.k.a. Notifier) Plugins? I'm not fond of them, because I do not want Jasper to suddenly start talking without me requesting it. That could be annoying and/or cause heart attacks. IMHO stuff should be just checked on demand, not as a background process. What do you think?enabled
config option. That's not too hard, but's still missing. EDIT: DoneAnother thing just came to my mind. I'd like to put individual plugin initializiation into the plugin's activate()
method, e.g. SpeechHandlerPlugins
should register their phrases there, and also STTPlugins
should compile their vocabularies inside this method, etc.
This raises 2 issues:
SpeechHandlerPlugins
will have to be activated before STTPlugins
(because they need the CommandPhrases
to be registered to be able to compile their vocabularies).compile_vocabulary
to the STTPlugin
specs that will be called after activating the SpeechHandlerPlugins
, but before activating the STTPlugins
- or we add an additional argument to the STTPlugins
activate method. Each option is not that clean, but I dislike the latter more than the first.
Any thoughts?Sorry for the late reply, Jan. Congrats on finishing exams! We're about to start that period on our end.
Your plugin work looks slick. My responses to your plugin issues:
*.jasperplugin
file would be a reasonable place to define a plugin's supported languagesen_US
vs. en_GB
. I think I like your third proposal best-- to require that plugins have a base language .mo
file. For plugin developers, that solution helps new devs get "up and running" quickly, while still offering flexibility for those who want it. Do we necessarily need to decide whether en
is en_US
or en_GB
by default? In other words, would associating a default change how Jasper loads the module for anyone?In response to your ideas about SpeechHandlerPlugins
/STTPlugins
:
SpeechHandlerPlugins
should be processed before STTPlugins
.STTPlugin
's activate()
method?
While thinking about the design of the next Jasper release I hit some stumble blocks that require architectural changes in Jasper.
Here a some ideas open for discussion. I already created a working sample implementation that covers these points:
populate.py
's functionality, we can simply implement a function that iters through all registered options and prints description and default_value.AbstractSTTEngine
). Plugins need a metadata file (ini-file format), that states name, slug, version, description, license, etc. Plugins can also be places into~/.jasper/plugins
so that every user can install his/her own plugins.SWITCH {location} LIGHTS {state}
or something like that)Also have a look at this amateurish diagram:
What is still missing in my sample implementation:
locale
folder withmo
files for different languages and can be filtered based on their language. If the user set the language to French, but a plugin supports only english and spanish, it will be filtered out. If we're using command phrases instead of single words, it'll be easy to translate.@crm416 @shbhrsaha Any thoughts/criticism/feedback?