DragonComputer/Dragonfire

View on GitHub
debian/postinst

Summary

Maintainability
Test Coverage
#!/bin/bash

OPTS=`getopt \
-o n --long no-model \
-o d --long dev \
-o p --long pip \
-- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
eval set -- "$OPTS"

NO_MODEL=false
DEV=false
DEBIAN=true
while true; do
  case "$1" in
    -n | --no-model )
      NO_MODEL=true;
      shift
    ;;
    -d | --dev )
      DEV=true;
      shift
    ;;
    -p | --pip )
      DEBIAN=false;
      shift
    ;;
    -- )
      shift;
      break
    ;;
    * )
      break
    ;;
  esac
done

apt-get update

if [ "$DEV" = true ] ; then
  apt-get -y install debhelper dpkg
fi
apt-get -y install python3 python3-all-dev libglib2.0-dev libcairo2-dev libgtk2.0-dev
apt-get -y install python3-minimal ${misc:Pre-Depends}
apt-get -y install ${python3:Depends} ${misc:Depends} flite python3-xlib portaudio19-dev python3-all-dev flac libnotify-bin python3-lxml python3-nltk python3-pyaudio python3-httplib2 python3-pip python3-setuptools python3-wheel libgstreamer1.0-dev gstreamer1.0-plugins-good gstreamer1.0-tools subversion libatlas-base-dev automake autoconf libtool libgtk2.0-0 gir1.2-gtk-3.0

python3 -m pip install --upgrade pip

#DEBHELPER#
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
CHECKSUM="32a93c35215a4a7498a7940d2d32fa9b"
CHECKSUM2="7823532dce2ca25596905e93515588b1"
TAR=downloaded.tar.gz

DRAGONFIRE_DIR=/usr/share/dragonfire
if [ ! -d "$DRAGONFIRE_DIR" ]; then
  mkdir $DRAGONFIRE_DIR
fi

DEEPSPEECH_DIR=/usr/share/dragonfire/deepspeech
if [ "$NO_MODEL" = false ] ; then
    if [ ! -d "$DEEPSPEECH_DIR" ]; then
      mkdir $DEEPSPEECH_DIR
    fi
    verified=$(md5sum ${DEEPSPEECH_DIR}/models/* | md5sum)
    if [ ! ${verified::-3} = "$CHECKSUM" ]; then
      wget -c https://github.com/mozilla/DeepSpeech/releases/download/v0.4.1/deepspeech-0.4.1-models.tar.gz -O $TAR && tar xvfz $TAR -C $DEEPSPEECH_DIR && rm $TAR
    fi
fi

DEEPCONV_DIR=/usr/share/dragonfire/deepconv
if [ ! -d "$DEEPCONV_DIR" ]; then
  mkdir $DEEPCONV_DIR
fi
verified=$(find $DEEPCONV_DIR -type f -exec md5sum {} \; | md5sum)
if [ ! ${verified::-3} = "$CHECKSUM2" ]; then
  wget -c https://github.com/DragonComputer/Dragonfire/releases/download/v1.0.4/deepconv-v3.tar.gz -O $TAR && tar xvfz $TAR -C $DEEPCONV_DIR && rm $TAR
fi

if [ "$DEBIAN" = false ] ; then
  if [ "$DEV" = true ] ; then
    pip3 install -e .
  else
    pip3 install .
  fi
fi

python3 -m spacy download en
python3 -m deeppavlov install squad_bert

printf "import logging\nlogging.getLogger('tensorflow').setLevel(logging.ERROR)\nimport warnings\nwarnings.simplefilter(action='ignore', category=FutureWarning)\nfrom deeppavlov import build_model, configs\nmodel = build_model(configs.squad.squad, download=True)" | python3

pip3 install https://github.com/huggingface/neuralcoref-models/releases/download/en_coref_sm-3.0.0/en_coref_sm-3.0.0.tar.gz

NLTK_DATA_PATH=/usr/local/share/nltk_data
python3 -m nltk.downloader -d $NLTK_DATA_PATH names
python3 -m nltk.downloader -d $NLTK_DATA_PATH brown
python3 -m nltk.downloader -d $NLTK_DATA_PATH wordnet
python3 -m nltk.downloader -d $NLTK_DATA_PATH punkt

echo -e "\n\n${GREEN}Dragonfire is successfully installed to your computer.${NC}\n"