Create 93-multiocr.sh

This commit is contained in:
Alexandre
2021-12-22 04:05:29 +01:00
committed by GitHub
parent 30e77907d8
commit 077058e4b9

View File

@@ -0,0 +1,21 @@
!/usr/bin/with-contenv bash
OCRLANG=$(bashio::config 'OCRLANG')
if [ -n "$OCRLANG" ]; then
apt-get update &>/dev/null
echo "OCRLANG variable is set, processing the language packages"
for i in $(echo "$OCRLANG" | tr "," " "); do
if apt-cache show tesseract-ocr-"${i}" > /dev/null 2>&1; then
echo "installing tesseract-ocr-${i}"
apt-get install -y tesseract-ocr-"${i}"
# Downloading trainer data
# Downloading trainer data
cd /usr/share/tessdata
sudo rm -r $LANG.traineddata &>/dev/null || true
wget https://github.com/tesseract-ocr/tessdata/raw/main/$LANG.traineddata &>/dev/null
else
echo "package tesseract-ocr-${i} not found in the repository, skipping"
fi
bashio::log.info "OCR Language installed : $i" || bashio::log.fatal "Couldn't install OCR lang $i. Please check its format is conform"
done
fi