本文整理汇总了Python中alex.utils.config.Config.load_configs方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load_configs方法的具体用法?Python Config.load_configs怎么用?Python Config.load_configs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alex.utils.config.Config
的用法示例。
在下文中一共展示了Config.load_configs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tecto_template_nlg
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def test_tecto_template_nlg(self):
# initialize
cfg = Config.load_configs(config=CONFIG_DICT, use_default=False,
log=False)
nlg = TectoTemplateNLG(cfg)
# test all cases
for da, correct_text in zip(DAS, TEXTS):
# try generation
da = DialogueAct(da)
generated_text = nlg.generate(da)
# print output
s = []
s.append("")
s.append("Input DA:")
s.append(unicode(da))
s.append("")
s.append("Correct text:")
s.append(correct_text)
s.append("")
s.append("Generated text:")
s.append(generated_text)
s.append("")
# test the result
self.assertEqual(correct_text, generated_text)
示例2: main
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""
AudioHub runs the spoken dialog system, using your microphone and speakers.
The default configuration is loaded from '<app root>/resources/default.cfg'.
Additional configuration parameters can be passed as an argument '-c'.
Any additional config parameters overwrite their previous values.
""")
parser.add_argument('-c', "--configs", nargs="+",
help='additional configuration file')
args = parser.parse_args()
cfg = Config.load_configs(args.configs)
cfg['Logging']['system_logger'].info("Voip Hub\n" + "=" * 120)
vhub = AudioHub(cfg)
vhub.run()
示例3: main
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def main():
cfg = Config.load_configs(['resources/default-lz.cfg'],
use_default=False, project_root=True)
#cfg = {'DM': {'UfalRuleDM':
# {'ontology':"/xdisk/devel/vystadial/alex/applications/" + \
# "CamInfoRest/ontology.cfg",
# 'db_cfg': "/xdisk/devel/vystadial/alex/applications/" + \
# "CamInfoRest/cued_data/CIRdbase_V7_noloc.txt"}}}
u = UfalRuleDM(cfg)
# ufal_ds = u.create_ds()
while 1:
curr_acts = DialogueActNBList()
for ln in sys.stdin:
if len(ln.strip()) == 0:
break
ln = ln.strip()
print ln
score, act = ln.split(" ", 1)
score = float(score)
curr_acts.add(score, DialogueActItem(dai=act))
u.da_in(curr_acts)
print " >", u.da_out()
示例4: get_config
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def get_config():
global config
config = Config.load_configs(['config_gp_sarsa.py'], log=False)
示例5: get_config
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def get_config():
global cfg
cfg = Config.load_configs(['scheduler_simulator.cfg'], log=False)
示例6: get_config
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def get_config():
global cfg
cfg = Config.load_configs(['../demos/ptien/simulator.cfg', '../demos/ptien/ptien_metadata.py'], log=False)
示例7: Exception
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
parser_a.add_argument('indomain_data_dir',
help='Directory which should contain symlinks or directories with transcribed ASR')
parser_b = subparsers.add_parser(
'load', help='Load wav transcriptions and reference with full paths to wavs')
parser_b.add_argument(
'reference', help='Key value file: Keys contain paths to wav files. Values are reference transcriptions.')
args = parser.parse_args()
if os.path.exists(args.out_dir):
if not args.f:
print "\nThe directory '%s' already exists!\n" % args.out_dir
parser.print_usage()
parser.exit()
else:
# create the dir
try:
os.makedirs(args.out_dir)
except OSError as exc:
if exc.errno != errno.EEXIST or os.path.isdir(args.out_dir):
raise exc
cfg = Config.load_configs(args.configs, use_default=True)
if args.command == 'extract':
extract_from_xml(args.indomain_data_dir, args.out_dir, cfg)
elif args.command == 'load':
decode_with_reference(args.reference, args.out_dir, cfg)
else:
raise Exception('Argparse mechanism failed: Should never happen')
示例8: main
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def main():
from alex.utils.config import Config
from alex.utils.caminfodb import CamInfoDb
# This implicitly loads also the default config.
cfg = Config.load_configs(['resources/lz.cfg'], project_root=True)
db_cfg = cfg['DM']["PUfalRuleDM"]['db_cfg'] # database provider
db = CamInfoDb(db_cfg)
pdm = PRuleDM(cfg, db)
pdm.new_dialogue()
pdm.da_out()
# user's input
cn = DialogueActConfusionNetwork()
cn.add(0.7, DialogueActItem(dai="inform(food=chinese)"))
cn.add(0.2, DialogueActItem(dai="inform(food=indian)"))
cn.add(0.5, DialogueActItem(dai="inform(food=chinese)"))
cn.add(0.1, DialogueActItem(dai="inform(food=czech)"))
cn.add(0.1, DialogueActItem(dai="confirm(food=czech)"))
cn.add(0.6, DialogueActItem(dai="request(phone)"))
cn.add(0.3, DialogueActItem(dai="reset()"))
cn.add(0.3, DialogueActItem(dai="asdf()"))
cn.add(0.3, DialogueActItem(dai="reset()"))
print cn
pdm.da_in(cn)
pdm.da_out()
cn = DialogueActConfusionNetwork()
cn.add(0.99, DialogueActItem(dai="confirm(food=indian)"))
print cn
pdm.da_in(cn)
pdm.da_out()
cn = DialogueActConfusionNetwork()
cn.add(0.77, DialogueActItem(dai="reqalts()"))
print cn
pdm.da_in(cn)
pdm.da_out()
cn = DialogueActConfusionNetwork()
cn.add(0.77, DialogueActItem(dai="reqalts()"))
print cn
pdm.da_in(cn)
pdm.da_out()
cn = DialogueActConfusionNetwork()
cn.add(0.99, DialogueActItem(dai="confirm(food=indian)"))
print cn
pdm.da_in(cn)
pdm.da_out()
cn = DialogueActConfusionNetwork()
cn.add(0.99, DialogueActItem(dai="request(name)"))
cn.add(0.99, DialogueActItem(dai="request(food)"))
print cn
pdm.da_in(cn)
pdm.da_out()
cn = DialogueActConfusionNetwork()
cn.add(0.99, DialogueActItem(dai="bye()"))
print cn
pdm.da_in(cn)
pdm.da_out()
示例9: main
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
'as confnets.'))
arger.add_argument('dirname',
help='directory name where to search for WAVs; in '
'fact, it can be path towards a file listing '
'paths to the files in question or path globs or '
'paths to their immediate parent directories')
arger.add_argument('outfname', help='path towards the output file')
arger.add_argument('-c', '--configs', nargs='+',
help='configuration files',
required=True)
arger.add_argument('-s', '--skip', type=int,
help="how many wavs to skip")
arger.add_argument('-g', '--ignore',
type=argparse.FileType('r'),
metavar='FILE',
help='Path towards a file listing globs of CUED '
'call log files that should be ignored.\n'
'The globs are interpreted wrt. the current '
'working directory. For an example, see the '
'source code.')
args = arger.parse_args()
cfg = Config.load_configs(args.configs, log=False)
try:
DEBUG = cfg['General']['debug']
except KeyError:
pass
main(args.dirname, args.outfname, cfg, args.skip, args.ignore)
示例10: test_session_logger
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def test_session_logger(self):
cfg = Config.load_configs(config=CONFIG_DICT, use_default=False)
sl = SessionLogger()
# test 3 calls at once
for i in range(3):
sess_dir = "./%d" % i
if not os.path.isdir(sess_dir):
os.mkdir(sess_dir)
sl.session_start(sess_dir)
sl.config('config = ' + unicode(cfg))
sl.header(cfg['Logging']["system_name"], cfg['Logging']["version"])
sl.input_source("voip")
sl.dialogue_rec_start(None, "both_complete_dialogue.wav")
sl.dialogue_rec_start("system", "system_complete_dialogue.wav")
sl.dialogue_rec_start("user", "user_complete_dialogue.wav")
sl.dialogue_rec_end("both_complete_dialogue.wav")
sl.dialogue_rec_end("system_complete_dialogue.wav")
sl.dialogue_rec_end("user_complete_dialogue.wav")
sl.turn("system")
sl.dialogue_act("system", "hello()")
sl.text("system", "Hello.")
sl.rec_start("system", "system1.wav")
sl.rec_end("system1.wav")
sl.turn("user")
sl.rec_start("user", "user1.wav")
sl.rec_end("user1.wav")
A1, A2, A3 = 0.90, 0.05, 0.05
B1, B2, B3 = 0.70, 0.20, 0.10
C1, C2, C3 = 0.80, 0.10, 0.10
asr_confnet = UtteranceConfusionNetwork()
asr_confnet.add([[A1, "want"], [A2, "has"], [A3, 'ehm']])
asr_confnet.add([[B1, "Chinese"], [B2, "English"], [B3, 'cheap']])
asr_confnet.add([[C1, "restaurant"], [C2, "pub"], [C3, 'hotel']])
asr_confnet.merge()
asr_confnet.normalise()
asr_confnet.sort()
asr_nblist = asr_confnet.get_utterance_nblist()
sl.asr("user", "user1.wav", asr_nblist, asr_confnet)
slu_confnet = DialogueActConfusionNetwork()
slu_confnet.add(0.7, DialogueActItem('hello'))
slu_confnet.add(0.6, DialogueActItem('thankyou'))
slu_confnet.add(0.4, DialogueActItem('restart'))
slu_confnet.add(0.1, DialogueActItem('bye'))
slu_confnet.merge()
slu_confnet.normalise()
slu_confnet.sort()
slu_nblist = slu_confnet.get_da_nblist()
sl.slu("user", "user1.wav", slu_nblist, slu_confnet)
sl.turn("system")
sl.dialogue_act("system", "thankyou()")
sl.text("system", "Thank you.", cost = 1.0)
sl.rec_start("system", "system2.wav")
sl.rec_end("system2.wav")
sl.barge_in("system", tts_time = True)
sl.turn("user")
sl.rec_start("user", "user2.wav")
sl.rec_end("user2.wav")
sl.hangup("user")
示例11: directory
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
if __name__ == '__main__':
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""
Switchboard system records conversation between two users.
When the first user calls the system, the systems rejects the call. Then in a few seconds,
it calls back to the first user, informs about how to use the system and the recording data.
Then, it asks the first user to enter a phone number of a second user. If the number is entered successfully,
it calls the second user.
The systems calls back to the user to prevent any call charges on the users' side.
The program reads the default config in the resources directory ('../resources/default.cfg').
In addition, it reads all config file passed as an argument of a '-c'.
The additional config files overwrites any default or previous values.
""")
parser.add_argument('-o', action="store", dest="caller", nargs='+', help='additional configure file')
parser.add_argument('-d', action="store", dest="callee", nargs='+', help='additional configure file')
args = parser.parse_args()
cfg1 = Config.load_configs(args.caller)
cfg2 = Config.load_configs(args.callee)
run(cfg1, cfg2)
示例12: main
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def main():
cldb = CategoryLabelDatabase('../data/database.py')
preprocessing = PTIENSLUPreprocessing(cldb)
slu = PTIENHDCSLU(preprocessing, cfg={'SLU': {PTIENHDCSLU: {'utt2da': as_project_path("applications/PublicTransportInfoEN/data/utt2da_dict.txt")}}})
cfg = Config.load_configs(['../kaldi.cfg',], use_default=True)
asr_rec = asr_factory(cfg)
fn_uniq_trn = 'uniq.trn'
fn_uniq_trn_hdc_sem = 'uniq.trn.hdc.sem'
fn_uniq_trn_sem = 'uniq.trn.sem'
fn_all_sem = 'all.sem'
fn_all_trn = 'all.trn'
fn_all_trn_hdc_sem = 'all.trn.hdc.sem'
fn_all_asr = 'all.asr'
fn_all_asr_hdc_sem = 'all.asr.hdc.sem'
fn_all_nbl = 'all.nbl'
fn_all_nbl_hdc_sem = 'all.nbl.hdc.sem'
fn_train_sem = 'train.sem'
fn_train_trn = 'train.trn'
fn_train_trn_hdc_sem = 'train.trn.hdc.sem'
fn_train_asr = 'train.asr'
fn_train_asr_hdc_sem = 'train.asr.hdc.sem'
fn_train_nbl = 'train.nbl'
fn_train_nbl_hdc_sem = 'train.nbl.hdc.sem'
fn_dev_sem = 'dev.sem'
fn_dev_trn = 'dev.trn'
fn_dev_trn_hdc_sem = 'dev.trn.hdc.sem'
fn_dev_asr = 'dev.asr'
fn_dev_asr_hdc_sem = 'dev.asr.hdc.sem'
fn_dev_nbl = 'dev.nbl'
fn_dev_nbl_hdc_sem = 'dev.nbl.hdc.sem'
fn_test_sem = 'test.sem'
fn_test_trn = 'test.trn'
fn_test_trn_hdc_sem = 'test.trn.hdc.sem'
fn_test_asr = 'test.asr'
fn_test_asr_hdc_sem = 'test.asr.hdc.sem'
fn_test_nbl = 'test.nbl'
fn_test_nbl_hdc_sem = 'test.nbl.hdc.sem'
indomain_data_dir = "indomain_data"
print "Generating the SLU train and test data"
print "-"*120
###############################################################################################
files = []
files.append(glob.glob(os.path.join(indomain_data_dir, 'asr_transcribed.xml')))
files.append(glob.glob(os.path.join(indomain_data_dir, '*', 'asr_transcribed.xml')))
files.append(glob.glob(os.path.join(indomain_data_dir, '*', '*', 'asr_transcribed.xml')))
files.append(glob.glob(os.path.join(indomain_data_dir, '*', '*', '*', 'asr_transcribed.xml')))
files.append(glob.glob(os.path.join(indomain_data_dir, '*', '*', '*', '*', 'asr_transcribed.xml')))
files.append(glob.glob(os.path.join(indomain_data_dir, '*', '*', '*', '*', '*', 'asr_transcribed.xml')))
files = various.flatten(files)
sem = []
trn = []
trn_hdc_sem = []
asr = []
asr_hdc_sem = []
nbl = []
nbl_hdc_sem = []
for fn in files[:100000]:
f_dir = os.path.dirname(fn)
print "Processing:", fn
doc = xml.dom.minidom.parse(fn)
turns = doc.getElementsByTagName("turn")
for i, turn in enumerate(turns):
if turn.getAttribute('speaker') != 'user':
continue
recs = turn.getElementsByTagName("rec")
trans = turn.getElementsByTagName("asr_transcription")
asrs = turn.getElementsByTagName("asr")
if len(recs) != 1:
print "Skipping a turn {turn} in file: {fn} - recs: {recs}".format(turn=i,fn=fn, recs=len(recs))
continue
if len(asrs) == 0 and (i + 1) < len(turns):
next_asrs = turns[i+1].getElementsByTagName("asr")
if len(next_asrs) != 2:
print "Skipping a turn {turn} in file: {fn} - asrs: {asrs} - next_asrs: {next_asrs}".format(turn=i, fn=fn, asrs=len(asrs), next_asrs=len(next_asrs))
continue
print "Recovered from missing ASR output by using a delayed ASR output from the following turn of turn {turn}. File: {fn} - next_asrs: {asrs}".format(turn=i, fn=fn, asrs=len(next_asrs))
hyps = next_asrs[0].getElementsByTagName("hypothesis")
elif len(asrs) == 1:
hyps = asrs[0].getElementsByTagName("hypothesis")
elif len(asrs) == 2:
print "Recovered from EXTRA ASR outputs by using a the last ASR output from the turn. File: {fn} - asrs: {asrs}".format(fn=fn, asrs=len(asrs))
hyps = asrs[-1].getElementsByTagName("hypothesis")
else:
print "Skipping a turn {turn} in file {fn} - asrs: {asrs}".format(turn=i,fn=fn, asrs=len(asrs))
continue
#.........这里部分代码省略.........
示例13: setUp
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def setUp(self):
cfg = Config.load_configs()
cfg.config['ASR']['Julius']['msg_timeout'] = 5.
cfg.config['ASR']['Julius']['timeout'] = 5.
cfg.config['corpustools']['get_jasr_confnets']['rt_ratio'] = 0.
self.cfg = cfg
示例14: get_config
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
def get_config():
global cfg
cfg = Config.load_configs(['../applications/PublicTransportInfoEN/ptien.cfg'])#, '../applications/PublicTransportInfoEN/ptien_hdc_slu.cfg'])
cfg['Logging']['system_logger'].info("Voip Hub\n" + "=" * 120)
示例15: FliteTTS
# 需要导入模块: from alex.utils.config import Config [as 别名]
# 或者: from alex.utils.config.Config import load_configs [as 别名]
print
text = 'Hello. Thank you for calling. '
voice = 'kal'
print "Synthesize text:", text
print "Voice: ", voice
print
c = {
'TTS': {
'Flite': {
'debug': False,
'voice': 'kal'
}
}
}
cfg = Config.load_configs(log=False)
cfg.update(c)
tts = FliteTTS(cfg)
print 'calling TTS'
wav = tts.synthesize(text)
print 'saving the TTS audio in ./tmp/flite_tts.wav'
audio.save_wav(cfg, './tmp/flite_tts.wav', wav)
print 'playing audio'
audio.play(cfg, wav)