forked from gooofy/kaldi-adapt-lm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1-download-requirements.sh
83 lines (80 loc) · 2.73 KB
/
1-download-requirements.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Download Kaldi and KenLM
set -e
echo "---------------------------DOWNLOAD_REQUIREMENTS-------------------------------"
G2P_TOOL=
if [ -n "$1" ]; then
G2P_TOOL="$1"
fi
# basic requirements
sudo apt update
sudo apt install -y --no-install-recommends zip unzip libatlas-base-dev sphinxbase-utils swig
# make sure python tools are there
sudo apt install -y --no-install-recommends python3-pip python3-dev python3-setuptools python3-wheel python3-venv
# NOTE: what about openBLAS (libopenblas-dev) instead of ATLAS (libatlas-base-dev)?
platform_kaldi=""
platform_wheels=""
if [ -n "$(uname -m | grep aarch64)" ]; then
platform_kaldi="arm64"
platform_wheels="aarch64"
elif [ -n "$(uname -m | grep armv7l)" ]; then
platform_kaldi="armv7"
platform_wheels="armv7l"
else
# NOTE: x86 32bit build not supported atm
platform_kaldi="amd64"
platform_wheels="x86_64"
fi
# Kaldi and KenLM
mkdir -p kaldi
mkdir -p kenlm
kalid_file="kaldi-2021_${platform_kaldi}.tar.gz"
kenlm_file="kenlm-20210107_${platform_kaldi}.tar.gz"
if [ ! -f "$kalid_file" ]; then
wget "https://github.com/fquirin/kaldi-adapt-lm/releases/download/v1.0.0/${kalid_file}"
fi
if [ $(ls -A kaldi | wc -l) -eq 0 ]; then
tar --strip-components=1 -xzvf "${kalid_file}" -C kaldi
fi
if [ ! -f "$kenlm_file" ]; then
wget "https://github.com/fquirin/kaldi-adapt-lm/releases/download/v1.0.0/${kenlm_file}"
fi
if [ $(ls -A kenlm | wc -l) -eq 0 ]; then
tar -xzvf "${kenlm_file}" -C kenlm
fi
# Sequitur or Phonetisaurus for G2P ?
if [ "$G2P_TOOL" = "sequitur" ]; then
# Sequitur G2P
PYTHON_39=$(python3 --version | grep "3.9" | wc -l)
pip3 install numpy
if [ $PYTHON_39 -eq 1 ]; then
G2P_URL="https://github.com/fquirin/kaldi-adapt-lm/releases/download/v1.0.0"
pip3 install "${G2P_URL}/sequitur_g2p-1.0.1668.23-cp39-cp39-linux_${platform_wheels}.whl"
else
pip3 install git+https://github.com/sequitur-g2p/sequitur-g2p@master
fi
mkdir -p sequitur
echo ""
echo "Installed Sequitur G2P. Please note that this tool is GPLv2 licensed:"
echo "https://github.com/sequitur-g2p/sequitur-g2p/blob/master/LICENSE"
echo ""
elif [ "$G2P_TOOL" = "phonetisaurus" ]; then
# Phonetisaurus G2P
G2P_URL="https://github.com/fquirin/kaldi-adapt-lm/releases/download/v1.0.0"
#G2P_URL="https://github.com/rhasspy/phonetisaurus-pypi/releases/download/v0.3.0" # fallback
if [ "$platform_wheels" = "x86_64" ]; then
pip3 install "${G2P_URL}/phonetisaurus-0.3.0-py3-none-manylinux1_${platform_wheels}.whl"
else
pip3 install "${G2P_URL}/phonetisaurus-0.3.0-py3-none-linux_${platform_wheels}.whl"
fi
mkdir -p phonetisaurus
echo ""
echo "Installed Phonetisaurus G2P."
echo ""
else
echo ""
echo "NOTE: To install a G2P tool run this script with argument 'sequitur' or 'phonetisaurus'."
echo ""
fi
#pip3 cache purge
echo "DONE"