Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: etc/sphinx_train.cfg
- ===================================================================
- --- etc/sphinx_train.cfg (revision 11411)
- +++ etc/sphinx_train.cfg (working copy)
- @@ -8,7 +8,7 @@
- $CFG_SPHINXTRAIN_DIR = "___SPHINXTRAIN_DIR___";
- # Directory containing SphinxTrain binaries
- -$CFG_BIN_DIR = "___SPHINXTRAIN_DIR___/../../libexec/sphinxtrain";
- +$CFG_BIN_DIR = "___SPHINXTRAIN_DIR___/__RELATIVE_BIN_DIR__";
- $CFG_GIF_DIR = "$CFG_BASE_DIR/gifs";
- $CFG_SCRIPT_DIR = "___SPHINXTRAIN_DIR___/scripts";
- Index: scripts/sphinxtrain.in
- ===================================================================
- --- scripts/sphinxtrain.in (revision 11411)
- +++ scripts/sphinxtrain.in (working copy)
- @@ -1,9 +1,14 @@
- #!/usr/bin/python
- -sphinxpath="@prefix@"
- -
- import getopt, sys, os
- +if os.name == 'nt':
- + scriptdir = os.path.dirname(sys.argv[0])
- + sphinxtrainpath = os.path.join(scriptdir, os.path.pardir)
- +else:
- + sphinxpath = "@prefix@"
- + sphinxtrainpath = sphinxpath + "/lib/sphinxtrain"
- +
- def setup(task):
- if not os.path.exists("etc"):
- os.mkdir("etc")
- @@ -11,13 +16,25 @@
- print "Setting up the database " + task
- out_cfg = open("etc/sphinx_train.cfg", "w")
- - for line in open(sphinxpath + "/lib/sphinxtrain/etc/sphinx_train.cfg", "r"):
- - line = line.replace("___DB_NAME___", task).replace("___BASE_DIR___", os.getcwd()).replace("___SPHINXTRAIN_DIR___", sphinxpath + "/lib/sphinxtrain")
- + for line in open(sphinxtrainpath + "/etc/sphinx_train.cfg", "r"):
- + line = line.replace("___DB_NAME___", task).replace("___BASE_DIR___", os.getcwd()).replace("___SPHINXTRAIN_DIR___", sphinxtrainpath)
- + if os.name == 'nt':
- + dirlist = [ 'bin/Release', 'bin/Debug' ]
- + for dirname in dirlist:
- + if os.path.isdir(os.path.join(sphinxtrainpath, dirname)):
- + bin_dir = dirname
- + break
- + else:
- + raise IOError("Could not find the binaries. " +
- + " Please compile the project using Visual Studio.")
- + else:
- + bin_dir = '../../libexec/sphinxtrain'
- + line = line.replace('__RELATIVE_BIN_DIR__', bin_dir).replace('\\', '/')
- out_cfg.write(line)
- out_cfg.close()
- out_cfg = open("etc/feat.params", "w")
- - for line in open(sphinxpath + "/lib/sphinxtrain/etc/feat.params", "r"):
- + for line in open(sphinxtrainpath + "/etc/feat.params", "r"):
- out_cfg.write(line)
- out_cfg.close()
- @@ -43,17 +60,24 @@
- "decode/slave.pl"
- ]
- +def run_stage(step):
- + script_path = os.path.join(sphinxtrainpath, "scripts", step)
- + if os.name == 'nt':
- + return os.system("perl " + script_path)
- + else:
- + return os.system(script_path)
- +
- def run_stages(stages):
- for stage in stages.split(","):
- for step in steps:
- name = step.split("/")[0].split(".")[-1]
- if name == stage:
- - os.system(sphinxpath + "/lib/sphinxtrain/scripts/" + step)
- + run_stage(step)
- def run():
- print "Running the training"
- for step in steps:
- - os.system(sphinxpath + "/lib/sphinxtrain/scripts/" + step)
- + run_stage(step)
- def usage():
- print ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement