diff --git a/align/align.py b/align/align.py index 42b1aa0..b5a1085 100644 --- a/align/align.py +++ b/align/align.py @@ -537,7 +537,8 @@ def main(): logging.debug('Start') - model_dir = os.path.expanduser(args.stt_model_dir if args.stt_model_dir else 'models/en') + app_root = os.environ['APP_ROOT'] if 'APP_ROOT' in os.environ else os.curdir + model_dir = os.path.expanduser(args.stt_model_dir if args.stt_model_dir else os.path.join(app_root, 'models', 'en')) if args.alphabet is not None: alphabet_path = args.alphabet @@ -555,13 +556,13 @@ def main(): if output_graph_path is None: logging.debug('Looking for model files in "{}"...'.format(model_dir)) output_graph_path, lang_lm_path, lang_trie_path = wavTranscriber.resolve_models(model_dir) - kenlm_path = 'dependencies/kenlm/build/bin' + kenlm_path = os.path.join(app_root, 'dependencies', 'kenlm', 'build', 'bin') if not path.exists(kenlm_path): kenlm_path = None - deepspeech_path = 'dependencies/deepspeech' + deepspeech_path = os.path.join(app_root, 'dependencies', 'deepspeech') if not path.exists(deepspeech_path): deepspeech_path = None - if kenlm_path and deepspeech_path and not args.stt_no_own_lm: + if kenlm_path is not None and deepspeech_path is not None and not args.stt_no_own_lm: tc = read_script(script) clean_text_path = script + '.clean' with open(clean_text_path, 'w') as clean_text_file: @@ -570,7 +571,7 @@ def main(): arpa_path = script + '.arpa' if not path.exists(arpa_path): subprocess.check_call([ - kenlm_path + '/lmplz', + os.path.join(kenlm_path, 'lmplz'), '--text', clean_text_path, '--arpa', @@ -582,7 +583,7 @@ def main(): lm_path = script + '.lm' if not path.exists(lm_path): subprocess.check_call([ - kenlm_path + '/build_binary', + os.path.join(kenlm_path, 'build_binary'), '-s', arpa_path, lm_path @@ -591,7 +592,7 @@ def main(): trie_path = script + '.trie' if not path.exists(trie_path): subprocess.check_call([ - deepspeech_path + '/generate_trie', + os.path.join(deepspeech_path, 'generate_trie'), alphabet_path, lm_path, trie_path diff --git a/bin/align.sh b/bin/align.sh index 7eeba71..4a3366a 100755 --- a/bin/align.sh +++ b/bin/align.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -approot="$(dirname "$(dirname "$(readlink -fm "$0")")")" -source "$approot/venv/bin/activate" -python "$approot/align/align.py" "$@" +export APP_ROOT=`python -c "import os, sys; print os.path.dirname(os.path.dirname(os.path.realpath(\"$0\")))"` +source "$APP_ROOT/venv/bin/activate" +python "$APP_ROOT/align/align.py" "$@" stty sane diff --git a/bin/export.sh b/bin/export.sh index e182516..ca036b8 100755 --- a/bin/export.sh +++ b/bin/export.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -approot="$(dirname "$(dirname "$(readlink -fm "$0")")")" -source "$approot/venv/bin/activate" -python "$approot/align/export.py" "$@" +export APP_ROOT=`python -c "import os, sys; print os.path.dirname(os.path.dirname(os.path.realpath(\"$0\")))"` +source "$APP_ROOT/venv/bin/activate" +python "$APP_ROOT/align/export.py" "$@" stty sane diff --git a/bin/meta.sh b/bin/meta.sh index 3a038bf..9568479 100755 --- a/bin/meta.sh +++ b/bin/meta.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -approot="$(dirname "$(dirname "$(readlink -fm "$0")")")" -source "$approot/venv/bin/activate" -python "$approot/align/meta.py" "$@" +export APP_ROOT=`python -c "import os, sys; print os.path.dirname(os.path.dirname(os.path.realpath(\"$0\")))"` +source "$APP_ROOT/venv/bin/activate" +python "$APP_ROOT/align/meta.py" "$@" stty sane diff --git a/bin/statistics.sh b/bin/statistics.sh index e367ea2..75745eb 100755 --- a/bin/statistics.sh +++ b/bin/statistics.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash -approot="$(dirname "$(dirname "$(readlink -fm "$0")")")" -source "$approot/venv/bin/activate" -python "$approot/align/stats.py" "$@" +export APP_ROOT=`python -c "import os, sys; print os.path.dirname(os.path.dirname(os.path.realpath(\"$0\")))"` +source "$APP_ROOT/venv/bin/activate" +python "$APP_ROOT/align/stats.py" "$@" +stty sane