1
0

setup_config.sh 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #!/bin/bash
  2. #############################################################################
  3. # Author: www.corvin.cn
  4. #############################################################################
  5. # Description:该脚本只需要在下载代码后执行一次即可,注意该脚本位置需要在代码
  6. # 的根目录下,不要随便移动位置,否则导致无法正常配置和编译。该脚本注意功能
  7. # 就是安装缺少运行语音程序的软件包,编译整个代码空间,配置环境变量,可以说
  8. # 是一键执行脚本,减少大家烦琐的配置编译步骤。
  9. #
  10. #############################################################################
  11. # History:
  12. # 20171205-init bash script
  13. # 20171213-在安装pocketSphinx时需要注意先安装base包再安装其他的,更新
  14. # wakeup的提示音从wav格式到mp3,最后增加source devel/setup.bash,直接
  15. # source ~/.bashrc没有反应。
  16. # 20180102-更新注释信息,先更新系统软件源列表为阿里源后再update,方便安装
  17. # 软件更快;
  18. #
  19. #############################################################################
  20. CURRENT_PATH=$(dirname $(readlink -f "$0"))
  21. WORKSPACE_PATH=${CURRENT_PATH%scripts}
  22. green="\e[32;1m"
  23. normal="\e[0m"
  24. function updateSourceList()
  25. {
  26. SOURCE_FILE=/etc/apt/sources.list
  27. sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
  28. sudo sh -c "echo #deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted > ${SOURCE_FILE}"
  29. sudo sh -c "echo deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties >> ${SOURCE_FILE}"
  30. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted >> ${SOURCE_FILE}"
  31. sudo sh -c "echo deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties >> ${SOURCE_FILE}"
  32. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted >> ${SOURCE_FILE}"
  33. sudo sh -c "echo deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties >> ${SOURCE_FILE}"
  34. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial universe >> ${SOURCE_FILE}"
  35. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe >> ${SOURCE_FILE}"
  36. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse >> ${SOURCE_FILE}"
  37. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse >> ${SOURCE_FILE}"
  38. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse >> ${SOURCE_FILE}"
  39. sudo sh -c "echo deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties >>${SOURCE_FILE}"
  40. sudo sh -c "echo deb http://archive.canonical.com/ubuntu xenial partner >> ${SOURCE_FILE}"
  41. sudo sh -c "echo deb-src http://archive.canonical.com/ubuntu xenial partner >> ${SOURCE_FILE}"
  42. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted >> ${SOURCE_FILE}"
  43. sudo sh -c "echo deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties >> ${SOURCE_FILE}"
  44. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe >>${SOURCE_FILE}"
  45. sudo sh -c "echo deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse >> ${SOURCE_FILE}"
  46. }
  47. echo -e "${green}>>> WORKSPACE_PATH=${WORKSPACE_PATH} <<< ${normal}"
  48. echo -e "\n${green} 0x00: Update packages source list ${normal}"
  49. updateSourceList
  50. sudo apt-get update
  51. echo -e "\n${green} 0x01: Install sox pkg and lib for iflytek_tts ${normal}"
  52. sudo apt-get install -y sox libsox-fmt-all
  53. cd ${WORKSPACE_PATH}
  54. sudo cp src/iflytek_tts/lib/libmsc_tts.so /usr/lib/
  55. echo -e "\n${green} 0x02: Install pkg for iflytek_asr ${normal}"
  56. cd ${WORKSPACE_PATH}
  57. sudo cp src/iflytek_asr/lib/libmsc.so /usr/lib/
  58. sudo apt-get install -y libasound2 libasound2-dev
  59. echo -e "\n${green} 0x03: Install pkgs for tuling_nlu ${normal}"
  60. sudo apt-get install -y libcurl3 libcurl4-openssl-dev libjsoncpp1 libjsoncpp-dev
  61. echo -e "\n${green} 0x04: Instal requests and vlc pkg for baidu_speech ${normal}"
  62. #first,config pip install source
  63. cd ~
  64. sudo rm -rf .pip
  65. mkdir .pip
  66. touch ~/.pip/pip.conf
  67. echo "[global]">~/.pip/pip.conf
  68. echo "timeout = 600">>~/.pip/pip.conf
  69. echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple">>~/.pip/pip.conf
  70. echo "[list]">>~/.pip/pip.conf
  71. echo "format = columns">>~/.pip/pip.conf
  72. #seconde,install pkg
  73. sudo apt-get install -y python-pip python-dev python-pyaudio build-essential
  74. sudo -H pip install --upgrade pip
  75. cd ${WORKSPACE_PATH}src/baidu_speech/requests/
  76. sudo -H pip install .
  77. cd ${WORKSPACE_PATH}src/baidu_speech/vlc-python/
  78. sudo cp generated/vlc.py /usr/lib/python2.7/
  79. #third,for baidu asr
  80. sudo apt-get install -y gstreamer0.10-*
  81. sudo apt-get install -y multimedia-jack
  82. jack_control start
  83. echo -e "\n${green} 0x05: Config respeaker mic array pkg ${normal}"
  84. #first,install swig by source code
  85. sudo apt-get install -y byacc
  86. cd ${WORKSPACE_PATH}src/respeaker/swig-3.0.12/
  87. ./configure
  88. make
  89. sudo make install
  90. make clean
  91. #seconde,install necessary python pkg
  92. sudo apt-get install -y libpulse-dev
  93. sudo -H pip install pocketsphinx webrtcvad
  94. sudo -H pip install respeaker --upgrade
  95. sudo -H pip install pyusb
  96. echo -e "\n${green} 0x06: Setup pocketsphinx for offline wakeup${normal}"
  97. sudo apt-get install -y ros-kinetic-audio-common
  98. #copy wakeup notice wav to Music folder
  99. cd ${WORKSPACE_PATH}
  100. cp ${WORKSPACE_PATH}src/sphinx_wakeup/wakeup_alert_sound/wakeup_alert.mp3 ~/Music/
  101. #copy language model to system env path
  102. LM_PATH=/usr/share/pocketsphinx/model/lm/zh_CN/
  103. sudo mkdir -p ${LM_PATH}
  104. sudo cp ${WORKSPACE_PATH}src/pocketsphinx/model/*.DMP ${LM_PATH}
  105. sudo cp ${WORKSPACE_PATH}src/pocketsphinx/model/*.dic ${LM_PATH}
  106. HMM_PATH=/usr/share/pocketsphinx/model/hmm/zh/
  107. sudo mkdir -p ${HMM_PATH}
  108. sudo cp -rf ${WORKSPACE_PATH}src/pocketsphinx/model/zh_broadcastnews_ptm256_8000 ${HMM_PATH}
  109. #install neceesary apt-get pkg and debian pkg
  110. cd ${WORKSPACE_PATH}src/pocketsphinx/debian/
  111. sudo apt-get install -y libgstreamer-plugins-base0.10-0
  112. sudo dpkg -i gstreamer0.10-pocketsphinx_0.8-5_amd64.deb
  113. sudo dpkg -i libsphinxbase1_0.8-6_amd64.deb
  114. sudo dpkg -i libpocketsphinx1_0.8-5_amd64.deb
  115. sudo apt-get install -y python-gst0.10
  116. echo -e "\n${green} 0x07: Autoremove useless pkgs for cleaning disk ${normal}"
  117. sudo apt-get autoremove -y
  118. echo -e "\n${green} 0x08: Compile ros_voice_system workspace ${normal}"
  119. cd ${WORKSPACE_PATH}
  120. catkin_make
  121. echo -e "\n${green} 0x09: Setup ros_voice_system env to .bashrc ${normal}"
  122. cd ${WORKSPACE_PATH}
  123. source devel/setup.bash
  124. echo "#config ros_voice_system env">>~/.bashrc
  125. echo "source ${WORKSPACE_PATH}devel/setup.bash">>~/.bashrc
  126. echo -e "${green}-------------------------------------------------${normal}"
  127. echo -e "${green} Congratulation! All be completed successfully! ${normal}"
  128. echo -e "${green} Now will auto startup ros_voice_system ${normal}"
  129. echo -e "\n"
  130. echo -e "${green} roslaunch voice_bringup voice_bringup.launch ${normal}"
  131. echo -e "${green}-------------------------------------------------${normal}"
  132. roslaunch voice_bringup voice_bringup.launch