Skip to content

Commit a8123c2

Browse files
karpnvzhehuaichen
authored andcommitted
install_bs (NVIDIA-NeMo#7019)
Signed-off-by: Nikolay Karpov <[email protected]>
1 parent c830c33 commit a8123c2

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

scripts/asr_language_modeling/ngram_lm/install_beamsearch_decoders.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# limitations under the License.
1515

1616
# Use this script to install KenLM, OpenSeq2Seq decoder, Flashlight decoder
17+
shopt -s expand_aliases
18+
1719
NEMO_PATH=/workspace/nemo # Path to NeMo folder: /workspace/nemo if you use NeMo/Dockerfile
1820
if [ "$#" -eq 1 ]
1921
then
@@ -24,10 +26,14 @@ KENLM_MAX_ORDER=10 # Maximum order of KenLM model, also specified in the setup_o
2426
cd $NEMO_PATH
2527

2628
if [ $(id -u) -eq 0 ]; then
27-
alias sudo=eval
29+
alias aptupdate='apt-get update'
30+
alias b2install='./b2'
31+
else
32+
alias aptupdate='sudo apt-get update'
33+
alias b2install='sudo ./b2'
2834
fi
2935

30-
sudo apt-get update && apt-get upgrade -y && apt-get install -y liblzma-dev && rm -rf /var/lib/apt/lists/* # liblzma needed for flashlight decoder
36+
aptupdate && apt-get upgrade -y && apt-get install -y liblzma-dev && rm -rf /var/lib/apt/lists/* # liblzma needed for flashlight decoder
3137

3238

3339
git clone https://github.com/NVIDIA/OpenSeq2Seq
@@ -42,7 +48,7 @@ cp $NEMO_PATH/scripts/installers/setup_os2s_decoders.py ./setup.py
4248
./setup.sh
4349

4450
# install Boost package for KenLM
45-
wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 --no-check-certificate && tar --bzip2 -xf $NEMO_PATH/decoders/boost_1_80_0.tar.bz2 && cd boost_1_80_0 && ./bootstrap.sh && sudo ./b2 --layout=tagged link=static,shared threading=multi,single install -j4 || echo FAILURE
51+
wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2 --no-check-certificate && tar --bzip2 -xf $NEMO_PATH/decoders/boost_1_80_0.tar.bz2 && cd boost_1_80_0 && ./bootstrap.sh && b2install --layout=tagged link=static,shared threading=multi,single install -j4 || echo FAILURE
4652
export BOOST_ROOT=$NEMO_PATH/decoders/boost_1_80_0
4753

4854
# install KenLM

tutorials/asr/Offline_ASR.ipynb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"nbformat_minor": 0,
44
"metadata": {
55
"colab": {
6-
"name": "Offline_ASR.ipynb",
76
"provenance": [],
8-
"collapsed_sections": [],
97
"toc_visible": true
108
},
119
"kernelspec": {
@@ -31,7 +29,9 @@
3129
"\n",
3230
"You may find more info on how to train and use language models for ASR models here:\n",
3331
"https://docs.nvidia.com/deeplearning/nemo/user-guide/docs/en/main/asr/asr_language_modeling.html\n",
34-
"\n\nNOTE: User is responsible for checking the content of datasets and the applicable licenses and determining if suitable for the intended use.\n"
32+
"\n",
33+
"\n",
34+
"NOTE: User is responsible for checking the content of datasets and the applicable licenses and determining if suitable for the intended use.\n"
3535
]
3636
},
3737
{
@@ -41,7 +41,7 @@
4141
},
4242
"source": [
4343
"## Installation\n",
44-
"NeMo can be installed via simple pip command. \n",
44+
"NeMo can be installed via simple pip command.\n",
4545
"\n",
4646
"Optional CTC beam search decoder might require restart of Colab runtime after installation."
4747
]
@@ -52,7 +52,7 @@
5252
"id": "I9eIxAyKHREB"
5353
},
5454
"source": [
55-
"BRANCH = 'r1.20.0'\n",
55+
"BRANCH = 'main'\n",
5656
"try:\n",
5757
" # Import NeMo Speech Recognition collection\n",
5858
" import nemo.collections.asr as nemo_asr\n",
@@ -77,12 +77,14 @@
7777
" import ctc_decoders\n",
7878
"except ModuleNotFoundError:\n",
7979
" # install beam search decoder\n",
80+
" import os\n",
8081
" !apt-get update && apt-get install -y swig\n",
8182
" !git clone https://github.com/NVIDIA/NeMo -b \"$BRANCH\"\n",
82-
" !cd NeMo && bash scripts/asr_language_modeling/ngram_lm/install_beamsearch_decoders.sh\n",
83+
" pwd = !pwd\n",
84+
" NEMO_PATH = os.path.join(pwd[0], \"NeMo\")\n",
85+
" !cd NeMo && bash scripts/asr_language_modeling/ngram_lm/install_beamsearch_decoders.sh $NEMO_PATH\n",
8386
" print('Restarting Colab runtime to successfully import built module.')\n",
8487
" print('Please re-run the notebook.')\n",
85-
" import os\n",
8688
" os.kill(os.getpid(), 9)"
8789
],
8890
"execution_count": null,
@@ -110,7 +112,7 @@
110112
},
111113
"source": [
112114
"## Instantiate pre-trained NeMo model\n",
113-
"``from_pretrained(...)`` API downloads and initializes model directly from the cloud. \n",
115+
"``from_pretrained(...)`` API downloads and initializes model directly from the cloud.\n",
114116
"\n",
115117
"Alternatively, ``restore_from(...)`` allows loading a model from a disk.\n",
116118
"\n",
@@ -403,7 +405,7 @@
403405
"source": [
404406
"## Offline inference with beam search decoder and N-gram language model re-scoring\n",
405407
"\n",
406-
"It is possible to use an external [KenLM](https://kheafield.com/code/kenlm/)-based N-gram language model to rescore multiple transcription candidates. \n",
408+
"It is possible to use an external [KenLM](https://kheafield.com/code/kenlm/)-based N-gram language model to rescore multiple transcription candidates.\n",
407409
"\n",
408410
"Let's download and preprocess LibriSpeech 3-gram language model."
409411
]
@@ -653,4 +655,4 @@
653655
"outputs": []
654656
}
655657
]
656-
}
658+
}

0 commit comments

Comments
 (0)