Advertisement
Guest User

Untitled

a guest
Oct 24th, 2012
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. Index: etc/sphinx_train.cfg
  2. ===================================================================
  3. --- etc/sphinx_train.cfg (revision 11411)
  4. +++ etc/sphinx_train.cfg (working copy)
  5. @@ -8,7 +8,7 @@
  6. $CFG_SPHINXTRAIN_DIR = "___SPHINXTRAIN_DIR___";
  7.  
  8. # Directory containing SphinxTrain binaries
  9. -$CFG_BIN_DIR = "___SPHINXTRAIN_DIR___/../../libexec/sphinxtrain";
  10. +$CFG_BIN_DIR = "___SPHINXTRAIN_DIR___/__RELATIVE_BIN_DIR__";
  11. $CFG_GIF_DIR = "$CFG_BASE_DIR/gifs";
  12. $CFG_SCRIPT_DIR = "___SPHINXTRAIN_DIR___/scripts";
  13.  
  14. Index: scripts/sphinxtrain.in
  15. ===================================================================
  16. --- scripts/sphinxtrain.in (revision 11411)
  17. +++ scripts/sphinxtrain.in (working copy)
  18. @@ -1,9 +1,14 @@
  19. #!/usr/bin/python
  20.  
  21. -sphinxpath="@prefix@"
  22. -
  23. import getopt, sys, os
  24.  
  25. +if os.name == 'nt':
  26. + scriptdir = os.path.dirname(sys.argv[0])
  27. + sphinxtrainpath = os.path.join(scriptdir, os.path.pardir)
  28. +else:
  29. + sphinxpath = "@prefix@"
  30. + sphinxtrainpath = sphinxpath + "/lib/sphinxtrain"
  31. +
  32. def setup(task):
  33. if not os.path.exists("etc"):
  34. os.mkdir("etc")
  35. @@ -11,13 +16,25 @@
  36. print "Setting up the database " + task
  37.  
  38. out_cfg = open("etc/sphinx_train.cfg", "w")
  39. - for line in open(sphinxpath + "/lib/sphinxtrain/etc/sphinx_train.cfg", "r"):
  40. - line = line.replace("___DB_NAME___", task).replace("___BASE_DIR___", os.getcwd()).replace("___SPHINXTRAIN_DIR___", sphinxpath + "/lib/sphinxtrain")
  41. + for line in open(sphinxtrainpath + "/etc/sphinx_train.cfg", "r"):
  42. + line = line.replace("___DB_NAME___", task).replace("___BASE_DIR___", os.getcwd()).replace("___SPHINXTRAIN_DIR___", sphinxtrainpath)
  43. + if os.name == 'nt':
  44. + dirlist = [ 'bin/Release', 'bin/Debug' ]
  45. + for dirname in dirlist:
  46. + if os.path.isdir(os.path.join(sphinxtrainpath, dirname)):
  47. + bin_dir = dirname
  48. + break
  49. + else:
  50. + raise IOError("Could not find the binaries. " +
  51. + " Please compile the project using Visual Studio.")
  52. + else:
  53. + bin_dir = '../../libexec/sphinxtrain'
  54. + line = line.replace('__RELATIVE_BIN_DIR__', bin_dir).replace('\\', '/')
  55. out_cfg.write(line)
  56. out_cfg.close()
  57.  
  58. out_cfg = open("etc/feat.params", "w")
  59. - for line in open(sphinxpath + "/lib/sphinxtrain/etc/feat.params", "r"):
  60. + for line in open(sphinxtrainpath + "/etc/feat.params", "r"):
  61. out_cfg.write(line)
  62. out_cfg.close()
  63.  
  64. @@ -43,17 +60,24 @@
  65. "decode/slave.pl"
  66. ]
  67.  
  68. +def run_stage(step):
  69. + script_path = os.path.join(sphinxtrainpath, "scripts", step)
  70. + if os.name == 'nt':
  71. + return os.system("perl " + script_path)
  72. + else:
  73. + return os.system(script_path)
  74. +
  75. def run_stages(stages):
  76. for stage in stages.split(","):
  77. for step in steps:
  78. name = step.split("/")[0].split(".")[-1]
  79. if name == stage:
  80. - os.system(sphinxpath + "/lib/sphinxtrain/scripts/" + step)
  81. + run_stage(step)
  82.  
  83. def run():
  84. print "Running the training"
  85. for step in steps:
  86. - os.system(sphinxpath + "/lib/sphinxtrain/scripts/" + step)
  87. + run_stage(step)
  88.  
  89. def usage():
  90. print ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement