From add1e4fa88058349a72f58eceb7e7629ae1ba010 Mon Sep 17 00:00:00 2001 From: Benoit Favre <benoit.favre@lif.univ-mrs.fr> Date: Mon, 2 Mar 2015 22:16:29 +0100 Subject: [PATCH] towards integration of newly created model --- .options.txt | 2 +- actions.py | 7 ++++--- data/simple-example.xml | 11 +++++++++++ main.py | 4 ++-- osc.py | 2 +- slu.py | 6 +++--- xmledit.py | 2 +- xmlview.py | 2 ++ 8 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 data/simple-example.xml diff --git a/.options.txt b/.options.txt index acb2937..9977e71 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 ed7849b..f1f6464 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 0000000..9e7364a --- /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 1a5aa52..3b9e217 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 f9abf10..d3b425a 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 b020acc..95d93dd 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 3d6b73c..8b7bf20 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 a67d4b4..99642e0 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): -- GitLab