Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New system plugin #82

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ce7cb52
Limit a bug in KDE (if the update is too frequent the notification be…
tobiasBora Jul 18, 2013
c06e2a5
Add some to be able to implement languages in plugins.
tobiasBora Jul 19, 2013
5e470d4
New plugin mode available, it works for files in ~/.palader.d/Plugins…
tobiasBora Jul 19, 2013
61614cc
Add pre-treatment function (put speech in lower case in main mode for…
tobiasBora Jul 19, 2013
39bc6db
Add a new SDK version which can create, package, and UPDATE a plugin …
tobiasBora Jul 20, 2013
439da46
A new way to install/list/remove plugins... With the new plugin struc…
tobiasBora Jul 21, 2013
1c04538
Add modifications to the install process
tobiasBora Jul 21, 2013
453968b
Made this system usable with old plugins (actions.dic = main.dic).
tobiasBora Jul 21, 2013
20db3fb
Minor bug correction.
tobiasBora Jul 21, 2013
1d3f814
Minor bug + Complete the default plugin in English, French, Spanish (…
tobiasBora Jul 24, 2013
942ea1f
Just rename a file.
tobiasBora Jul 24, 2013
21a0580
Rename file.
tobiasBora Jul 24, 2013
79cb9cc
Minor bug + Documentation for the new plugin system.
tobiasBora Jul 24, 2013
c9ddb8a
Doc modification.
tobiasBora Jul 24, 2013
adeb796
Minor doc modification.
tobiasBora Jul 24, 2013
7061681
Add documentation "why changing the plugin system".
tobiasBora Jul 24, 2013
59a5fb0
Little bugs fixed and some alterations in hotkey continuous mode.
MarcoRabelo Jul 26, 2013
b33518b
Preparing paquaging : allow symbolic links.
tobiasBora Jul 26, 2013
024eeb6
Adding Portuguese translations and synchronizing the changes that hav…
MarcoRabelo Jul 28, 2013
d6aad69
Merge branch 'master' of git://github.com/MarcoRabelo/Palaver into Ma…
tobiasBora Jul 28, 2013
679c7c8
Don't cut the end of the sentence in countinuous mode.
tobiasBora Jul 28, 2013
8581596
Add a mode in continuous recording to be able to call the computer to…
tobiasBora Jul 28, 2013
95171fe
Minor bug about main-en.pre.
tobiasBora Jul 28, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions Doc/Plugins/New_Plugin_Version.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
* Create a plugin

The plugins are installed now in ~/.palaver.d/Plugins or in <install directory>/Plugins.

** Generate the structure
To create a plugin you can still use the old structure (see How to create a plugin to know how to use it), or use the new one. With the new one, you can automatiquely update your plugin.info file, use several languages plugins, create your own modes... You can put all files in the root of the plugin directory but to update the plugin you must use the following structure, and it's really more readable to use it, so it's recommanded to use it :

- Plugin_name/
--- plugin.info <=== contain all informations about the file
--- bin/ <=== contain all new scripts
--- config/ <=== contain configuration files, I don't know what's the use so I didn't add this function yet
--- modes/ <=== contain all modes. For classic mode, please use main.dic instead of actions.dic which is depreciated. You can specify a language plugin with main-fr.dic (Cf. Languages)
--- <mode>.pre <=== Facultatif file Cf. apply script to the speech

To create automatiquely this structure you can do :
./plugins_sdk -c Plugin_name

The plugin will be created in ~/.palader.d/Plugins by default. (see ./plugins_sdk for all options)


** Dictionnaries, modes, and languages
All dictionaries files are in Plugin_name/modes directory. The filename of a dictionnary is <mode>-<language>.dic, with <mode> the name of the mode (by default main) and <language> the name of the language (en, es, fr...). If you want to add your functions in all languages, you can put it in <mode>.dic

The structure of the dictionnary is always the same :
#+begin_src
what to say
what to do
#+end_src

Now when you create a new mode you can too make a modification to the speech (like put in in lower case) with a script <mode>.pre with must be in the root of the plugin *before* the package, and in the same level as the plugin directory *after* the packaging. You can have only one <mode>.pre file in the whole installation. For exemple this is the content of main.pre (put in lower case the message) :
#+begin_src
#!/bin/bash
tr '[:upper:]' '[:lower:]'
#+end_src

Moreover you can now document your plugin :


** Document your plugin
To be able to auto-generate the field "actions" in plugin.info, you can put in your dictionary files comments on actions with '#@:' in the beginning of a line :
#+begin_src
#@:what to say : execute an action
what <to,you can> say
what to do
#+end_src

The sentence "what to say" will be the one displayed to the user in the plugin documentation.

You can put too in you bin files (in bin/) the following comment to specify the dependancies of your script :

#@depends: <name depend 1> <name depend 2>



** Update your plugin
If you use the new structure you can use auto-generate the plugin.info file with
./plugins_sdk -u <Plugin name>

It will automatiquely generate the bin dependencies (local, and system if you use comments), the documentation in action (Cf. Document your plugin)

The new plugin.info is displayed at the end.


** Package your plugin
To share your plugin you must package it. You can do it with
./plugins_sdk -p <Plugin name>
(with no options the plugin must be in ~/.palader.d/Plugins)

The package is generated in ~/.palader.d/Plugins.


* Manage your plugins
You can use plugins_manager to manage your plugin (Cf. documentation with ./plugins_manager).

** List plugins
You can list plugins installed with
./plugins_manager -l
and plugins available in repository with
./plugins_manager -L

** Install plugins
To install a new plugin from a file :
./plugins_manager -i <filename>
And from the repository
./plugins_manager -p <Plugin name>

** Remove plugins
Just run
./plugins_manager -r <Plugin name>

** More options
For more options (changing directory...) just run ./plugins_manager with no options.


* Why changing the plugin system

I think that the old system is really hard to expand. It's not possible to use differents languages in plugins, the old system uses database which are not practive (now it's useless).

Now it's possible to auto-generate documentation and dependencies, apply a script to the speech (by default the speech in main mode is now in lower case)... And we make a real distinction between plugins in install folder and personal plugins, and that's a good thing for packaging Palaver for Linux.
4 changes: 4 additions & 0 deletions Microphone/Translations/es
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Listening=Escucha
Please wait=Por favor, espere
Performing recognition=Realización de Reconocimiento
Done=Hecho
Please call me=por favor me llame
Yes I m listening to you=Si lo estoy escuchando
I was proud to help you=Me senti orgulloso de ayudar a
I do it now=Lo hago ahora
4 changes: 4 additions & 0 deletions Microphone/Translations/fr
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Please wait=Merci de patienter
Performing recognition=Reconnaissance en cours
Done=Fini
Speech unable to be transcribed=Le discours n'a pu être transcrit
Please call me=S'il te plait appelle moi
Yes I m listening to you=Oui je vous ecoute
I was proud to help you=J'etais fier de vous aider
I do it now=Je le fais tout de suite
4 changes: 4 additions & 0 deletions Microphone/Translations/pt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Listening=Escutando
Please wait=Por favor, aguarde
Performing recognition=Reconhecendo
Done=Pronto
Please call me=por favor me ligue
Yes I m listening to you=sim eu estou te ouvindo
I was proud to help you=Eu estava orgulhoso de ajuda-lo
I do it now=Eu faco isso agora
4 changes: 2 additions & 2 deletions Microphone/osd_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def transText(text):
PWD+"/Recording/thumbs/rec"+ str(64-i)+".gif")
n.show()
i += 8
time.sleep(.1)
time.sleep(.5)
i = 0
while os.path.exists("pycmd_wait"):
n.update(transText("Performing recognition"),
"",
PWD+"/Waiting/wait-"+str(i)+".png")
n.show()
time.sleep(.1)
time.sleep(.5)
i += 1;
if i > 17:
i = 0
Expand Down
File renamed without changes.
23 changes: 23 additions & 0 deletions Plugins/Default/bin/ask
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash



if [ -z "$1" ];then
echo "You haven't asked anything!"
exit 1
fi


# This is kinda stealing resources, it's okay for testing, but lets
# call MIT START and wolfram on our own.
ANS_START="$(wget -qO- "http://qxip.net/bot/getstart.php?q=$1")"

ANS_WOLF="$(wget -qO- "http://qxip.net/bot/getwolf.php?q=$1")"

if [ ! -z "$ANS_START" ];then
echo "$ANS_START"
fi

if [ ! -z "$ANS_WOLF" ];then
echo "$ANS_WOLF"
fi
14 changes: 14 additions & 0 deletions Plugins/Default/bin/edit_details
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if which "gedit"
then
gedit "$HOME/.palaver.d/UserInfo"
elif which "kate"
then
kate "$HOME/.palaver.d/UserInfo"
elif which "emacs"
then
emacs "$HOME/.palaver.d/UserInfo"
else
nano "$HOME/.palaver.d/UserInfo"
fi
12 changes: 12 additions & 0 deletions Plugins/Default/bin/goto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# This should use the default browser


# Allows it to accept any url
if echo "$1" |egrep "^http" >/dev/null 2>&1;then
xdg-open "$1" &
else
xdg-open http://"$1" &
fi

17 changes: 17 additions & 0 deletions Plugins/Default/bin/mode
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Change modes.


if [ -z "$1" ];then
1="main" # Default mode is main
fi

read mode < MODE

echo "$1" > MODE

if [ "$1" != "$mode" ];then # we changed modes
./Recognition/bin/result "Mode Changed" "You are now in '$1' mode." ""
fi

9 changes: 9 additions & 0 deletions Plugins/Default/bin/open
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

eval "$@ "&

if which "${1%% *}" ;then
:
else
exit 1 # It's not a command
fi
9 changes: 9 additions & 0 deletions Plugins/Default/bin/result
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

> Microphone/result

for i in "$@";do
echo $i >> Microphone/result
done

./pycmd result
26 changes: 26 additions & 0 deletions Plugins/Default/bin/result_from_call
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/python3

# This module can accept many arguments. If the "" syntax is used, then the argument will be recognised as one,
# else if no "" syntax is used, then the arguments will be recognised as different.
# I did this to keep a steady syntax across all dictionaries

import sys
from subprocess import Popen

args = sys.argv

if args.__len__() < 2:
print("ERROR: Not enough arguments provided to result_from_call")
exit(1)

args.pop(0) # Remove script name

try:
with open('Microphone/result', 'w') as result:
if args.__len__() == 1: # If an item with "" was passed. I know this as it will be recognised as one argument
args = args[0].split()
response = Popen(args, stdout=result) # Store all output in to result file
except IOError as ioerr:
print("File could not be found: " + str(ioerr))


12 changes: 12 additions & 0 deletions Plugins/Default/bin/say
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Use : say [language] <text>

if [ ! -z "$2" ]
then
play -q "|espeak -v $1 -s 150 -p 30 \"$2\" --stdout"
else
play -q "|espeak -s 150 -p 30 \"$1\" --stdout"
fi


3 changes: 3 additions & 0 deletions Plugins/Default/bin/type
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

xvkbd -text "$1"
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#@:exit dication mode
<exit,end,stop,leave> dictation mode
mode main
(LINE catch_all)
type "$catch_all$\\r"
3 changes: 3 additions & 0 deletions Plugins/Default/modes/dictation-es.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#@:Modo dictado sale
[M,m]odo dictado sale
mode main
3 changes: 3 additions & 0 deletions Plugins/Default/modes/dictation-fr.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#@:Quitte le mode dictée
<<A,a>rr<è,ê,é,e>te[s],<Q,q>uitte[s]> [le ,la ][mode ][de ]dictée[s'il<-, >te plaît]
mode main
3 changes: 3 additions & 0 deletions Plugins/Default/modes/dictation-pt.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#@:sair do modo ditado
<sair,finalizar,parar,deixar> <do,o> modo ditado
mode main
2 changes: 2 additions & 0 deletions Plugins/Default/modes/dictation.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(LINE catch_all)
type "$catch_all$\\r"
37 changes: 37 additions & 0 deletions Plugins/Default/modes/main-en.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#@:say <text> : Pronounce the text
<say,speak> (LINE words)
say "$words$"
#@:write <text> the text
<type,write> (LINE words)
type "$words$\\r"
#@:copy
copy[ this]
type '\\Cc'
#@:paste
paste[ this]
type '\\Cv'

#@:dictation mode : go in dictation mode
dictation mode
mode dictation

#@:Open repository : open the palaver website
<o,O>pen <r,R>epository
goto "http://palaver.bmandesigns.com"

#@:status : gives the git status
<s,S>tatus
result_from_call "git status"

#@:go to <website> : open your browser with website.
<g,G>o[ ]to (LINE site)
goto "$site$"

#@:open Google Chrome
open <g,G>oogle <c,C>hrome
open 'google-chrome'
open does not exit
open 'bob'
#@:Change my info
<<e,E>dit,<c,C>hange> <m,M>y <i,I>nfo
edit_details
42 changes: 42 additions & 0 deletions Plugins/Default/modes/main-es.dic
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#@:Decir <texto>
decir (LINE words)
say "$words$"
#@:escrito <texto>
escrito (LINE words)
type "$words$\\r"
#@:copiar
copiar
type '\\Cc'
#@:pegar
pegar
type '\\Cv'

#@:modo dictato
modo dictato
mode dictation

#@:repositorio abierto
repositorio abierto
goto "http://palaver.bmandesigns.com"

#@:da el git status
status
result_from_call "git status"

#@:abre la página <website>
abre la p<a,á>gina (LINE site)
goto "$site$"

#@:abre Google Chrome
abrir <g,G>oogle <c,C>hrome
open 'google-chrome'
#@:abre Firefox
abrir <f,F>irefox
open 'firefox'
#@:abre el programa <programa>
abre el programa (WORD prog)
open $prog$

#@:Cambiar perfil
cambiar perfil
edit_details
Loading