diff --git a/.options.txt b/.options.txt index acb2937ab327e6bbc810a911f61a3f8bd5dd3ae1..9977e71a69edff0e4f0cd104fee039d073f6bd1c 100644 --- a/.options.txt +++ b/.options.txt @@ -1,5 +1,5 @@ slu: 0 -xml_filename: data/homeostasis_25nov.xml +xml_filename: /home/favre/work/kaldi/interface-rocio/data/simple-example.xml osc_host: 127.0.0.1 osc_port: 1234 asr_model: asr/custom.cfg diff --git a/actions.py b/actions.py index ed7849b5b63ffbb32d4c9cb86cf6a15286725531..f1f64649b03646cfe3a347b6463fc703185824f4 100644 --- a/actions.py +++ b/actions.py @@ -37,12 +37,13 @@ def perform_action(action, confirm=True, timeout=3): #action(1,1,"#ENDSECTION(1)","") def parse_slu_action(text): - found = re.search(r'^action\((\d+),(\d+),"(([^"\\]|\\")*)","(([^"\\]|\\")*)"\)$', text) + found = re.search(r'^action\((\d+),(\d+),(\d+),"(([^"\\]|\\")*)","(([^"\\]|\\")*)"\)$', text) if found: section_id = int(found.group(1)) sequence_id = int(found.group(2)) - action_name = found.group(3) - action_text = found.group(5) + action_id = int(found.group(3)) + action_name = found.group(4) + action_text = found.group(6) return Action(action_name, section=section_id, sequence=sequence_id, words=action_text) print "Warning: could not parse slu action '%s'" % text return Action(text) diff --git a/data/simple-example.xml b/data/simple-example.xml new file mode 100644 index 0000000000000000000000000000000000000000..9e7364ad50d4973c10b6587e0fe8e72eb4ff1956 --- /dev/null +++ b/data/simple-example.xml @@ -0,0 +1,11 @@ +<homeostasis version="25-11-2014"> + <liste_section sequences="1" ordre="variable" repetition="oui" action="exclusive"> + <section id="1" action="example1"> + <sequence ordre="strict" repetition="non" action="" lang="eng"> + <keyword action="example1" lang="eng"> this is the one </keyword> + <keyword action="example2" lang="eng"> two is where we go </keyword> + <keyword action="example3" lang="eng"> I am three to do whatever I want </keyword> + </sequence> + </section> + </liste_section> +</homeostasis> diff --git a/main.py b/main.py index 1a5aa524e087c9d9a8f4467b4408014080d21dbb..3b9e217f65582402626490ce76ffd1cfae56ab80 100644 --- a/main.py +++ b/main.py @@ -53,8 +53,8 @@ class ScriptedASR(Gtk.Window): # slu #prefix = 'slu/automate/homeostasis_25nov_%s' #library = 'slu/src.new/librocio_slu.so' - prefix = 'slu/automate/homeostasis_25nov_%s' - library = 'slu/src/librocio_slu.so' + prefix = 'tools/model/automate/simple-example_%s' + library = 'tools/slu/src/librocio_slu.so' self.slu = {} for section_fst in glob.glob(prefix % 'section*.fst'): found = re.search('section(\d+)\.fst$', section_fst) diff --git a/osc.py b/osc.py index f9abf100615f86e52139cd9d3ac47f8c1bf56d5c..d3b425a26d4611c29e253e1d434f16987188e3ec 100644 --- a/osc.py +++ b/osc.py @@ -19,7 +19,7 @@ class Client: def send_words(self, start, words): #self.send('/words/%d/%s' % (start, words)) - self.send('WORDS(%d): %s' % (action.text)) + self.send('WORDS(%d): %s' % (start, words)) class Server: def __init__(self, host = '127.0.0.1', port = 1234): diff --git a/slu.py b/slu.py index b020accb5276ed1194c5932e1e734725475f70be..95d93ddf76e4ad7b35ec704ade53249253da3be6 100644 --- a/slu.py +++ b/slu.py @@ -7,7 +7,7 @@ _semaphore = None class SLU: #/src.new/rocio_slu -word "$prefix"_dico_word.txt -action "$prefix"_dico_action.txt -fstmodel "$prefix".fst -fstclean "$prefix"_clean_tail.fst - def __init__(self, word_lexicon, action_lexicon, model_fst, cleaner_fst, action_history, library='slu/src/librocio_slu.so'): + def __init__(self, word_lexicon, action_lexicon, model_fst, cleaner_fst, action_history, library='tools/slu/src/librocio_slu.so'): global _backend, _semaphore if _backend == None: _backend = cdll.LoadLibrary(library) @@ -113,9 +113,9 @@ class SLU: _backend.free_slu(self.slu) if __name__ == '__main__': - prefix = 'slu/automate/homeostasis_25nov_%s' + prefix = 'tools/slu/automate/homeostasis_25nov_%s' slu = SLU(prefix % 'dico_word.txt', prefix % 'dico_action.txt', prefix % 'section6.fst', prefix % 'clean_tail.fst') #print 'before' - slu.process(open('slu/homeostasis_25nov.asr/sect6.ref').read().strip().split(), lambda x: sys.stdout.write('%s\n' % x)) + slu.process(open('tools/slu/homeostasis_25nov.asr/sect6.ref').read().strip().split(), lambda x: sys.stdout.write('%s\n' % x)) #print 'after' slu.shutdown() diff --git a/xmledit.py b/xmledit.py index 3d6b73cd4947760b412c6a028ad1c9b7de257c51..8b7bf20bf50b83d8d1c95b3997df9b575d601a28 100644 --- a/xmledit.py +++ b/xmledit.py @@ -166,7 +166,7 @@ class SourceView(Gtk.Window): if self.save(): if self.validate(): self.command.add_text('COMPILE...') - self.command.run('./tools/compile.ben.sh "%s" tools/model' % self.filename) + self.command.run('./tools/compile.sh "%s" "tools/model"' % self.filename) def quit(self, window): Gtk.main_quit() diff --git a/xmlview.py b/xmlview.py index a67d4b4faeaf0615cb7f712a588e668e818fa3f1..99642e0f487d683b1e7a29a24aab833c04b9483a 100644 --- a/xmlview.py +++ b/xmlview.py @@ -193,6 +193,8 @@ class XmlView(Gtk.ScrolledWindow): def highlight(self, action): if hasattr(action, 'keyword'): action.keyword.highlight(True, self) + elif hasattr(action, 'action_id'): + self.keywords[action.action_id].highlight(True, self) else: i = self.last_highlighted + 1 while i < len(self.keywords):