Skip to content

Commit 50c2f24

Browse files
committed
simplify mkgraph api
1 parent 835fa69 commit 50c2f24

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

gentle/language_model.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ def make_bigram_language_model(kaldi_seq, proto_langdir='PROTO_LANGDIR'):
6868
hclg_filename = tempfile.mktemp(suffix='_HCLG.fst')
6969
try:
7070
subprocess.check_output([MKGRAPH_PATH,
71-
os.path.join(proto_langdir, 'langdir'),
72-
os.path.join(proto_langdir, 'modeldir'),
73-
txt_fst_file.name,
74-
os.path.join(proto_langdir, "graphdir/words.txt"),
75-
hclg_filename])
71+
proto_langdir,
72+
txt_fst_file.name,
73+
hclg_filename])
7674
except Exception, e:
7775
os.unlink(hclg_filename)
7876
raise e

mkgraph.cc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ int main(int argc, char *argv[]) {
1313
using namespace fst;
1414
using fst::script::ArcSort;
1515
try {
16-
const char *usage = "Usage: ./mkgraph [options] <lang-dir> <model-dir> <grammar-fst> <words-txt> <out-fst>\n";
16+
const char *usage = "Usage: ./mkgraph [options] <proto-dir> <grammar-fst> <out-fst>\n";
1717

1818
ParseOptions po(usage);
1919
po.Read(argc, argv);
20-
if (po.NumArgs() != 5) {
20+
if (po.NumArgs() != 3) {
2121
po.PrintUsage();
2222
return 1;
2323
}
@@ -27,17 +27,16 @@ int main(int argc, char *argv[]) {
2727
float self_loop_scale = 0.1;
2828
bool reverse = false;
2929

30-
std::string lang_dir = po.GetArg(1),
31-
model_dir = po.GetArg(2),
32-
grammar_fst_filename = po.GetArg(3),
33-
words_filename = po.GetArg(4),
34-
out_filename = po.GetArg(5);
35-
36-
std::string lang_fst_filename = lang_dir + "/L.fst",
37-
lang_disambig_fst_filename = lang_dir + "/L_disambig.fst",
38-
disambig_phones_filename = lang_dir + "/phones/disambig.int",
39-
model_filename = model_dir + "/final.mdl",
40-
tree_filename = model_dir + "/tree";
30+
std::string proto_dir = po.GetArg(1),
31+
grammar_fst_filename = po.GetArg(2),
32+
out_filename = po.GetArg(3);
33+
34+
std::string lang_fst_filename = proto_dir + "/langdir/L.fst",
35+
lang_disambig_fst_filename = proto_dir + "/langdir/L_disambig.fst",
36+
disambig_phones_filename = proto_dir + "/langdir/phones/disambig.int",
37+
model_filename = proto_dir + "/modeldir/final.mdl",
38+
tree_filename = proto_dir + "/modeldir/tree",
39+
words_filename = proto_dir + "/graphdir/words.txt";
4140

4241
if (!std::ifstream(lang_fst_filename.c_str())) {
4342
std::cerr << "expected " << lang_fst_filename << " to exist" << std::endl;

0 commit comments

Comments
 (0)