setup.sh 2.3 KB
Newer Older
Y
Yibing Liu 已提交
1
#! /usr/bin/env  bash
Y
yangyaming 已提交
2

3 4 5
source utils/log.sh


H
Hui Zhang 已提交
6 7 8 9 10
SUDO='sudo'
if [ $(id -u) -eq 0 ]; then
  SUDO=''
fi

11
if [ -e /etc/lsb-release ];then
H
Hui Zhang 已提交
12
    ${SUDO} apt-get update -y
H
Hui Zhang 已提交
13
    ${SUDO} apt-get install -y jq vim tig tree sox pkg-config libflac-dev libogg-dev libvorbis-dev libboost-dev swig python3-dev
14 15 16 17
    if [ $? != 0 ]; then
        error_msg "Please using Ubuntu or install pkg-config libflac-dev libogg-dev libvorbis-dev libboost-dev swig python3-dev by user."
        exit -1
    fi
H
Hui Zhang 已提交
18 19
fi

H
Hui Zhang 已提交
20 21 22 23 24

# tools/make
rm tools/*.done
pushd tools && make && popd

H
Hui Zhang 已提交
25 26
source tools/venv/bin/activate

Y
yangyaming 已提交
27
# install python dependencies
28
if [ -f "requirements.txt" ]; then
H
Hui Zhang 已提交
29
    pip3 install -r requirements.txt
Y
yangyaming 已提交
30 31
fi
if [ $? != 0 ]; then
32
    error_msg "Install python dependencies failed !!!"
Y
yangyaming 已提交
33 34 35
    exit 1
fi

36
# install package libsndfile
H
Hui Zhang 已提交
37
python3 -c "import soundfile"
Y
yangyaming 已提交
38
if [ $? != 0 ]; then
39
    info_msg "Install package libsndfile into default system path."
L
Luo Tao 已提交
40
    wget "http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.28.tar.gz"
L
Luo Tao 已提交
41
    if [ $? != 0 ]; then
42
        error_msg "Download libsndfile-1.0.28.tar.gz failed !!!"
L
Luo Tao 已提交
43 44 45 46
        exit 1
    fi
    tar -zxvf libsndfile-1.0.28.tar.gz
    cd libsndfile-1.0.28
47
    ./configure > /dev/null && make > /dev/null && make install > /dev/null
L
Luo Tao 已提交
48 49 50
    cd ..
    rm -rf libsndfile-1.0.28
    rm libsndfile-1.0.28.tar.gz
Y
yangyaming 已提交
51
fi
Y
yangyaming 已提交
52

53
#install auto-log
54
python -c "import auto_log"
55 56
if [ $? != 0 ]; then
    info_msg "Install auto_log into default system path"
57
    test -d AutoLog || git clone https://github.com/LDOUBLEV/AutoLog
58 59 60 61 62
    if [ $? != 0 ]; then
        error_msg "Download auto_log failed !!!"
        exit 1
    fi
    cd AutoLog
63
    pip install -r requirements.txt
H
Hui Zhang 已提交
64
    python setup.py install
65 66
    cd ..
    rm -rf AutoLog
H
Hui Zhang 已提交
67
fi
68

Y
Yibing Liu 已提交
69
# install decoders
H
Hui Zhang 已提交
70
python3 -c "import pkg_resources; pkg_resources.require(\"swig_decoders==1.1\")"
Y
Yibing Liu 已提交
71
if [ $? != 0 ]; then
72 73
    cd deepspeech/decoders/ctcdecoder/swig > /dev/null
    bash setup.sh
Y
Yibing Liu 已提交
74
    cd - > /dev/null
Y
Yibing Liu 已提交
75
fi
76 77 78 79 80
python3 -c "import pkg_resources; pkg_resources.require(\"swig_decoders==1.1\")"
if [ $? != 0 ]; then
   error_msg "Please check why decoder install error!"
   exit -1
fi
Y
Yibing Liu 已提交
81

82

H
Hui Zhang 已提交
83 84 85
# install third_party
pushd third_party
bash install.sh
86
if [ $? != 0 ]; then
H
Hui Zhang 已提交
87
   error_msg "Please check why third_party install error!"
88 89 90 91
   exit -1
fi
popd

92

93
info_msg "Install all dependencies successfully."