Skip to content
Snippets Groups Projects
Commit add1e4fa authored by Benoit Favre's avatar Benoit Favre
Browse files

towards integration of newly created model

parent e21710e0
No related branches found
No related tags found
No related merge requests found
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
......@@ -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)
......
<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>
......@@ -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)
......
......@@ -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):
......
......@@ -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()
......@@ -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()
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment