├── LICENSE ├── README.md └── tamil-tts.sh /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GPL 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tamil-TTS-install-script 2 | 3 | Author : T Shrinivasan 4 | 5 | This is a script to install the Tamil text to Speech System provided by IIT Madras and SSN College of Engineering at 6 | https://www.iitm.ac.in/donlab/tts/voices.php 7 | 8 | ## System requirements: 9 | 1. Ubuntu 16.04 10 | 2. Ubuntu 18.04 11 | 12 | ## Will it work on Windows? 13 | No. 14 | 15 | ## How to Install 16 | ``` 17 | git clone https://github.com/tshrinivasan/tamil-tts-install.git 18 | cd tamil-tts-install 19 | ./tamil-tts.sh --clean --setup 20 | 21 | ``` 22 | 23 | ## How to convert tamil text to .wav 24 | ``` 25 | cd tamil-tts-install 26 | ./tamil-tts.sh --run --source tamil-text.txt 27 | ``` 28 | This will generate 'tamil-text.wav' file 29 | 30 | ## How to convert tamil text to .mp3 31 | ``` 32 | cd tamil-tts-install 33 | ./tamil-tts.sh --run --gen-mp3 --source tamil-text.txt 34 | ``` 35 | This will generate 'tamil-text.mp3' file 36 | 37 | ## howto set your own HTKUSER and HTKPASSWORD in tamil-tts.sh 38 | Register here http://htk.eng.cam.ac.uk/download.shtml and get a username and password, replace your 39 | own username and passward in HTKUSER and HTKPASSWORD 40 | -------------------------------------------------------------------------------- /tamil-tts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ROOT=$(git rev-parse --show-toplevel) 3 | ROOT="${ROOT:-$(pwd)}" 4 | BUILD="${ROOT}/build" 5 | DOWNLOAD_PATH="${BUILD}"/packages 6 | COMPILE_PATH="${BUILD}"/compiled 7 | RUNDIR="${DOWNLOAD_PATH}"/ssn_hts_demo 8 | 9 | tamil_tts_setup() { 10 | CURRENTDIR=$(pwd) 11 | #Register here http://htk.eng.cam.ac.uk/download.shtml and get a username and password 12 | HTKUSER=htkuserchennai 13 | HTKPASSWORD=sgqY=t=M 14 | 15 | sudo apt-get install -y wget festival libx11-dev perl build-essential g++ csh gawk bc sox tcsh default-jre lame 16 | 17 | mkdir -p "${DOWNLOAD_PATH}" 18 | mkdir -p "${COMPILE_PATH}" 19 | 20 | cd "${DOWNLOAD_PATH}" 21 | if [[ ! -d ssn_hts_demo ]]; then 22 | wget --no-check-certificate https://www.iitm.ac.in/donlab/tts/downloads/voices/hts23/ssn_hts_demo_Tamil_male.tgz 23 | tar xvzf ssn_hts_demo_Tamil_male.tgz 24 | fi 25 | 26 | cd "${DOWNLOAD_PATH}" 27 | if [[ ! -d SPTK-3.10 ]]; then 28 | wget --no-check-certificate https://nchc.dl.sourceforge.net/project/sp-tk/SPTK/SPTK-3.10/SPTK-3.10.tar.gz 29 | tar xvzf SPTK-3.10.tar.gz 30 | fi 31 | cd SPTK-3.10 32 | ./configure --prefix="${COMPILE_PATH}"/sptk 33 | make 34 | make install 35 | 36 | cd "${DOWNLOAD_PATH}" 37 | if [[ ! -d hts-htk ]]; then 38 | mkdir hts-htk 39 | fi 40 | cd hts-htk 41 | if [[ ! -f HTS-2.3_for_HTK-3.4.1.patch ]]; then 42 | wget --no-check-certificate http://hts.sp.nitech.ac.jp/archives/2.3/HTS-2.3_for_HTK-3.4.1.tar.bz2 43 | tar xvjf HTS-2.3_for_HTK-3.4.1.tar.bz2 44 | fi 45 | 46 | cd "${DOWNLOAD_PATH}" 47 | if [[ ! -d htk ]]; then 48 | wget --no-check-certificate http://htk.eng.cam.ac.uk/ftp/software/HTK-3.4.1.tar.gz --user="${HTKUSER}" --password="${HTKPASSWORD}" 49 | tar -zxvf HTK-3.4.1.tar.gz 50 | fi 51 | 52 | if [[ ! -f htk/HTKLVRec/HLVRec.c ]]; then 53 | wget --no-check-certificate http://htk.eng.cam.ac.uk/ftp/software/hdecode/HDecode-3.4.1.tar.gz --user="${HTKUSER}" --password="${HTKPASSWORD}" 54 | tar -zxvf HDecode-3.4.1.tar.gz 55 | fi 56 | cd htk 57 | patch --dry-run -s -N -p1 -d . < ../hts-htk/HTS-2.3_for_HTK-3.4.1.patch 58 | if [[ "${?}" -eq 0 ]]; then 59 | patch -s -N -p1 -d . < ../hts-htk/HTS-2.3_for_HTK-3.4.1.patch 60 | fi 61 | ./configure CFLAGS="-DARCH=linux" --prefix="${COMPILE_PATH}"/htk 62 | make 63 | make install 64 | 65 | cd "${DOWNLOAD_PATH}" 66 | if [[ ! -d hts_engine_API-1.10 ]]; then 67 | wget --no-check-certificate https://nchc.dl.sourceforge.net/project/hts-engine/hts_engine%20API/hts_engine_API-1.10/hts_engine_API-1.10.tar.gz 68 | tar xvzf hts_engine_API-1.10.tar.gz 69 | fi 70 | cd hts_engine_API-1.10 71 | ./configure --prefix="${COMPILE_PATH}"/hts_engine_api 72 | make 73 | make install 74 | 75 | cd /usr/share/doc/festival/examples/ 76 | if [[ ! -f dumpfeats ]]; then 77 | sudo gunzip dumpfeats.gz 78 | fi 79 | if [[ ! -f dumpfeats.sh ]]; then 80 | sudo gunzip dumpfeats.sh.gz 81 | fi 82 | sudo chmod a+rx /usr/share/doc/festival/examples/dumpfeats 83 | 84 | cd "${DOWNLOAD_PATH}" 85 | cd ssn_hts_demo 86 | if [[ ! -f /usr/share/festival/radio_phones.scm-old ]]; then 87 | sudo mv /usr/share/festival/radio_phones.scm /usr/share/festival/radio_phones.scm-old 88 | sudo cp "${DOWNLOAD_PATH}"/ssn_hts_demo/radio_phones.scm /usr/share/festival/ 89 | fi 90 | 91 | if [[ ! -f /usr/share/perl5/File/Slurp.pm ]]; then 92 | mkdir -p /usr/share/perl5/File 93 | sudo cp "${DOWNLOAD_PATH}"/ssn_hts_demo/Slurp.pm /usr/share/perl5/File/ 94 | fi 95 | gcc scripts/tamil_trans.c -o scripts/tamil_trans 96 | 97 | #comment the play audio file line on the complete script 98 | sed -i -e '/play/ s/^/#/' "${DOWNLOAD_PATH}"/ssn_hts_demo/scripts/complete 99 | 100 | #replace $FESTDIR to /usr as festival's path in ubuntu is /usr/bin/festival 101 | sed -i -e 's:\$FESTDIR:/usr:g' "${DOWNLOAD_PATH}"/ssn_hts_demo/scripts/complete 102 | 103 | #make temp2 to point to input file 104 | sed -i -e 's:^echo.*temp2$:cp $1 temp2:g' "${DOWNLOAD_PATH}"/ssn_hts_demo/scripts/complete 105 | 106 | cd "${CURRENTDIR}" 107 | echo "installation completed" 108 | } 109 | 110 | tamil_tts_run() { 111 | if [[ -z "${SOURCE}" ]]; then 112 | echo "${USAGE}" 113 | exit 1 114 | fi 115 | 116 | if [[ -z "${OUTPUT}" ]]; then 117 | OUTPUT="${SOURCE%.*}.wav" 118 | fi 119 | 120 | SOURCE=$(readlink -f "${SOURCE}") 121 | OUTPUT=$(readlink -f "${OUTPUT}") 122 | MP3OUTPUT="${OUTPUT%.*}.mp3" 123 | CURRENTDIR=$(pwd) 124 | 125 | rm -f "${OUTPUT}" "${MP3OUTPUT}" 126 | cp -fra "${RUNDIR}" "${RUNDIR}_${RUNID}" 127 | RUNDIR="${RUNDIR}_${RUNID}" 128 | cd "${RUNDIR}" 129 | ./configure --with-fest-search-path=/usr/share/doc/festival/examples --with-sptk-search-path="${COMPILE_PATH}"/sptk/bin/ --with-hts-search-path="${COMPILE_PATH}"/htk/bin/ --with-hts-engine-search-path="${COMPILE_PATH}"/hts_engine_api/bin/ 130 | ./scripts/complete "${SOURCE}" linux 131 | cd "${CURRENTDIR}" 132 | if [[ $(stat -c '%s' "${RUNDIR}"/wav/1.wav) -eq 0 ]]; then 133 | echo "output file genertion failed" 1>&2 134 | rm -fr "${RUNDIR}" 135 | exit 1 136 | fi 137 | 138 | cp "${RUNDIR}"/wav/1.wav "${OUTPUT}" 139 | rm -fr "${RUNDIR}" 140 | 141 | if [[ "${MP3}" -eq 1 ]]; then 142 | lame "${OUTPUT}" "${MP3OUTPUT}" 143 | rm -f "${OUTPUT}" 144 | fi 145 | } 146 | 147 | tamil_tts_clean() { 148 | rm -fr "${BUILD}" 149 | } 150 | 151 | USAGE="[usage] 152 | ${0} --clean 153 | ${0} --setup 154 | ${0} --run [--runid id] [--gen-mp3] [--output outputfile ] --source sourcefile 155 | ${0} -h|--help 156 | " 157 | 158 | ARGS=$(getopt -o h -l clean,setup,run,gen-mp3,runid:,source:,output:,help -n "${0}" -- "${@}") 159 | if [[ ! "${?}" -eq 0 ]]; then 160 | echo "failed parse options" 1>&2 161 | exit 1 162 | fi 163 | 164 | eval set -- "${ARGS}" 165 | CLEAN=0 166 | SETUP=0 167 | RUN=0 168 | MP3=0 169 | RUNID="${$}" 170 | SOURCE="" 171 | OUTPUT="" 172 | 173 | while true; do 174 | case "${1}" in 175 | --clean) CLEAN=1; shift;; 176 | --setup) SETUP=1; shift;; 177 | --run) RUN=1; shift;; 178 | --gen-mp3) MP3=1; shift;; 179 | --runid) RUNID="${2}"; shift 2;; 180 | --source) SOURCE="${2}"; shift 2;; 181 | --output) OUTPUT="${2}"; shift 2;; 182 | --) shift; break;; 183 | *) echo "${USAGE}"; exit 1;; 184 | esac 185 | done 186 | 187 | if [[ "${CLEAN}" -eq 1 ]]; then 188 | tamil_tts_clean 189 | fi 190 | 191 | if [[ "${SETUP}" -eq 1 ]]; then 192 | tamil_tts_setup 193 | fi 194 | 195 | if [[ "${RUN}" -eq 1 ]]; then 196 | tamil_tts_run 197 | fi 198 | --------------------------------------------------------------------------------