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

include slu and xml in config

parent 21e2463b
No related branches found
No related tags found
No related merge requests found
slu: 0
xml_filename: /home/favre/work/kaldi/interface-rocio/data/simple-example.xml
asr_model: asr/custom.cfg
osc_host: 127.0.0.1
xml_filename: /home/favre/work/kaldi/interface-rocio/data/homeostasis_25nov.xml
osc_port: 1234
asr_model: asr/custom.cfg
slu: 0
......@@ -65,7 +65,7 @@ class ASR(Gtk.HBox):
if self.asr:
import config
for name, value in config.read(asr_config_file).items():
if name != 'dir' and name != 'name':
if name != 'dir' and name != 'name' and not name.startswith('slu') and not name.startswith('xml'):
self.asr.set_property(name, value)
else:
print >> sys.stderr, "Couldn't create the kaldinnet2onlinedecoder element. "
......
dir = tools/model
name = Custom (compiled from simple-example.xml)
xml_filename = data/simple-example.xml
slu_prefix = $dir/automate/simple-example_%s
slu_actions = $dir/simple-example.action
fst = $dir/HCLG.fst
model = $dir/final.mdl
word-syms = $dir/words.txt
feature-type = mfcc
mfcc-config = $dir/conf/mfcc.conf
ivector-extraction-config = $dir/conf/ivector_extractor.fixed.conf
max-active = 7000
beam = 11.0
lattice-beam = 6.0
do-endpointing = True
endpoint-silence-phones = 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35
......@@ -28,9 +28,13 @@ import confirm, asr, actions, xmlview
import levenstein, slu, osc
class ScriptedASR(Gtk.Window):
def __init__(self, xml_filename, asr_config_file, osc_host, osc_port, slu_type):
def __init__(self, asr_config_file, osc_host, osc_port, slu_type):
super(ScriptedASR, self).__init__()
import config
config_dict = config.read(asr_config_file)
xml_filename = config_dict['xml_filename']
self.connect("destroy", self.quit)
self.set_default_size(1024, 768)
self.set_border_width(10)
......@@ -53,14 +57,19 @@ class ScriptedASR(Gtk.Window):
# slu
#prefix = 'slu/automate/homeostasis_25nov_%s'
#library = 'slu/src.new/librocio_slu.so'
prefix = 'tools/model/automate/simple-example_%s'
library = 'tools/slu/src/librocio_slu.so'
#prefix = 'tools/model/automate/simple-example_%s'
#library = 'tools/slu/src/librocio_slu.so'
slu_prefix = config_dict['slu_prefix']
slu_actions = config_dict['slu_actions']
slu_library = '%s/tools/slu/src/librocio_slu.so' % directory
self.slu = {}
for section_fst in glob.glob(prefix % 'section*.fst'):
for section_fst in glob.glob(slu_prefix % 'section*.fst'):
found = re.search('section(\d+)\.fst$', section_fst)
if found:
section_id = int(found.group(1))
self.slu[section_id - 1] = slu.SLU(prefix % 'dico_word.txt', prefix % 'dico_action.txt', section_fst, prefix % 'clean_tail.fst', 'slu/homeostasis_25nov.action', library=library)
self.slu[section_id - 1] = slu.SLU(slu_prefix % 'dico_word.txt', slu_prefix % 'dico_action.txt', section_fst, slu_prefix % 'clean_tail.fst', slu_actions, library=slu_library)
if slu_type == 0:
for keyword in self.xmlview.keywords:
keyword.add_listener(self.set_slu_history)
......@@ -216,16 +225,9 @@ class ScriptedASR(Gtk.Window):
if __name__ == '__main__':
import selector
xml_filename = 'data/homeostasis_25nov.xml'
asr_config_file = 'asr/mika-fred-1.cfg'
asr_config_file = 'asr/mika-fred-2.cfg'
asr_config_file = 'asr/fisher-benoit-1.cfg'
if len(sys.argv) > 1:
xml_filename = sys.argv[1]
if len(sys.argv) > 2:
asr_config_file = sys.argv[2]
xml_filename, asr_config_file, osc_host, osc_port, slu_type = selector.ModelSelector(xml_filename, asr_config_file).run()
if xml_filename == None or asr_config_file == None or osc_host == None or osc_port == None or slu_type == None:
asr_config_file = 'asr/custom.cfg'
asr_config_file, osc_host, osc_port, slu_type = selector.ModelSelector(asr_config_file).run()
if asr_config_file == None or osc_host == None or osc_port == None or slu_type == None:
sys.exit(0)
app = ScriptedASR(xml_filename, asr_config_file, osc_host, osc_port, slu_type)
app = ScriptedASR(asr_config_file, osc_host, osc_port, slu_type)
Gtk.main()
......@@ -3,9 +3,9 @@ import os, sys, glob, re
import config
class ModelSelector(Gtk.Dialog):
def __init__(self, xml_filename = '', asr_model = ''):
def __init__(self, asr_model = ''):
super(ModelSelector, self).__init__()
self.options = {'xml_filename': xml_filename, 'asr_model': asr_model, 'osc_host': '127.0.0.1', 'osc_port': '1234', 'slu': 'Regular'}
self.options = {'asr_model': asr_model, 'osc_host': '127.0.0.1', 'osc_port': '1234', 'slu': 'Regular'}
self.load_options()
self.set_title('Configuration')
......@@ -14,18 +14,18 @@ class ModelSelector(Gtk.Dialog):
self.add_button("OK", Gtk.ResponseType.OK)
box = self.get_content_area()
xml_box = Gtk.HBox()
xml_box.pack_start(Gtk.Label('XML file:'), False, False, 5)
xml_entry = Gtk.Entry()
xml_entry.set_text(self.options['xml_filename'])
xml_entry.set_width_chars(len(self.options['xml_filename']))
self.xml_entry = xml_entry
xml_box.pack_start(xml_entry, True, True, 5)
xml_button = Gtk.Button("Choose...")
xml_button.connect('clicked', self.show_filechooser)
xml_box.pack_start(xml_button, False, False, 5)
#xml_box = Gtk.HBox()
#xml_box.pack_start(Gtk.Label('XML file:'), False, False, 5)
#xml_entry = Gtk.Entry()
#xml_entry.set_text(self.options['xml_filename'])
#xml_entry.set_width_chars(len(self.options['xml_filename']))
#self.xml_entry = xml_entry
#xml_box.pack_start(xml_entry, True, True, 5)
#xml_button = Gtk.Button("Choose...")
#xml_button.connect('clicked', self.show_filechooser)
#xml_box.pack_start(xml_button, False, False, 5)
box.pack_start(xml_box, False, False, 5)
#box.pack_start(xml_box, False, False, 5)
model_box = Gtk.HBox()
model_box.pack_start(Gtk.Label('ASR model:'), False, False, 5)
......@@ -70,7 +70,7 @@ class ModelSelector(Gtk.Dialog):
box.pack_start(osc_box, False, False, 5)
self.xml_entry.set_activates_default(True)
#self.xml_entry.set_activates_default(True)
okButton = self.get_widget_for_response(response_id=Gtk.ResponseType.OK)
okButton.set_can_default(True)
okButton.grab_default()
......@@ -132,11 +132,11 @@ class ModelSelector(Gtk.Dialog):
if response != Gtk.ResponseType.OK:
return None, None, None, None
self.options['asr_model'] = self.models[self.model_chooser.get_active()]
self.options['xml_filename'] = self.xml_entry.get_text()
#self.options['xml_filename'] = self.xml_entry.get_text()
self.options['osc_host'] = self.osc_host.get_text()
self.options['osc_port'] = self.osc_port.get_text()
self.options['slu'] = self.slu_chooser.get_active()
self.save_options()
self.destroy()
return self.options['xml_filename'], self.options['asr_model'], self.options['osc_host'], self.options['osc_port'], self.options['slu']
return self.options['asr_model'], self.options['osc_host'], self.options['osc_port'], self.options['slu']
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