#!/usr/bin/env bash # bash install.sh --stage 1 --stop_stage 2 --system_version centos python_version=3.12.8 system_version="centos"; verbose=true; stage=-1 stop_stage=0 # parse options while true; do [ -z "${1:-}" ] && break; # break if there are no arguments case "$1" in --*) name=$(echo "$1" | sed s/^--// | sed s/-/_/g); eval '[ -z "${'"$name"'+xxx}" ]' && echo "$0: invalid option $1" 1>&2 && exit 1; old_value="(eval echo \\$$name)"; if [ "${old_value}" == "true" ] || [ "${old_value}" == "false" ]; then was_bool=true; else was_bool=false; fi # Set the variable to the right value-- the escaped quotes make it work if # the option had spaces, like --cmd "queue.pl -sync y" eval "${name}=\"$2\""; # Check that Boolean-valued arguments are really Boolean. if $was_bool && [[ "$2" != "true" && "$2" != "false" ]]; then echo "$0: expected \"true\" or \"false\": $1 $2" 1>&2 exit 1; fi shift 2; ;; *) break; esac done work_dir="$(pwd)" trained_models_dir="$(pwd)/trained_models" mkdir -p "${trained_models_dir}" if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then $verbose && echo "stage 1: download sound models" cd "${work_dir}" || exit 1; python download_sound_models.py fi if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then $verbose && echo "stage 2: download silero vad model" cd "${trained_models_dir}" || exit 1; wget https://github.com/snakers4/silero-vad/blob/master/src/silero_vad/data/silero_vad.jit fi if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then $verbose && echo "stage 3: install python" cd "${work_dir}" || exit 1; sh ./script/install_python.sh --python_version "${python_version}" --system_version "${system_version}" fi if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then $verbose && echo "stage 4: create virtualenv" # /usr/local/python-3.9.9/bin/pip3 install virtualenv # /usr/local/python-3.9.9/bin/virtualenv cc_vad # source /data/local/bin/cc_vad/bin/activate /usr/local/python-${python_version}/bin/pip3 install virtualenv mkdir -p /data/local/bin cd /data/local/bin || exit 1; /usr/local/python-${python_version}/bin/virtualenv cc_vad fi