diff --git a/.gitignore b/.gitignore index 4278cf9..016ea63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ spchcat -build \ No newline at end of file +build +audio* \ No newline at end of file diff --git a/README.md b/README.md index 4f24317..90491d0 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,17 @@ You should replace `../STT_download` with the path to the Coqui library folder. LD_LIBRARY_PATH=../STT_download ./spchcat ``` +``` +sudo docker run -it -v`pwd`:/spchcat ubuntu:xenial bash +apt-get update && apt-get install -y sox libsox-dev libpulse-dev make gcc g++ wget +cd /spchcat +make clean && make spchcat LINK_PATH_STT=-Lbuild/lib EXTRA_CFLAGS_STT=-Ibuild/lib + +wget --quiet https://github.com/coqui-ai/STT/releases/download/v1.1.0/audio-1.1.0.tar.gz +tar -xzf audio-1.1.0.tar.gz +LD_LIBRARY_PATH=./build/lib ./spchcat --languages_dir=build/models/ ./audio/4507-16021-0012.wav +``` + ### Models The previous step only built the executable binary itself, but for the complete tool you also need data files for each language. If you have the [`gh` GitHub command line tool](https://cli.github.com/) you can run the `download_releases.py` script to fetch [Coqui's releases](https://github.com/coqui-ai/STT-models/releases) into the `build/models` folder in your local repo. You can then run your locally-built tool against these models using the `--languages_dir` option: diff --git a/definitions.mk b/definitions.mk index 77b4ec8..a90f274 100644 --- a/definitions.mk +++ b/definitions.mk @@ -21,6 +21,9 @@ endif SPCHCAT_BIN := spchcat$(PLATFORM_EXE_SUFFIX) CFLAGS_STT := -std=c++11 -o $(SPCHCAT_BIN) -Os +# Allow user-supplied flags (like include paths) from the command line. +EXTRA_CFLAGS_STT := +CFLAGS_STT += ${EXTRA_CFLAGS_STT} LINK_STT := -lstt -lkenlm -ltflitedelegates -ltensorflowlite -lpulse -l pulse-simple LINK_PATH_STT := -L${TFDIR}/bazel-bin/native_client -L${TFDIR}/bazel-bin/tensorflow/lite diff --git a/scripts/create_deb_package.sh b/scripts/create_deb_package.sh index 29c09ae..fa319bb 100755 --- a/scripts/create_deb_package.sh +++ b/scripts/create_deb_package.sh @@ -1,7 +1,7 @@ #!/bin/bash -xe NAME=spchcat -VERSION=0.0-1 +VERSION=0.0-2 ARCH=amd64 MAINTAINER=pete@petewarden.com DESCRIPTION="Speech recognition tool to convert audio to text transcripts." @@ -30,12 +30,8 @@ find ${DEB_MODELS_DIR} -type f -name "*.pb*" -delete # Some scorers are also very large, so for convenience remove them too. find ${DEB_MODELS_DIR} -iname "*.scorer" -size +150M -delete -# Extract and copy the libraries from Coqui's binary release. -rm -rf ${LIB_TMP_DIR} && mkdir -p ${LIB_TMP_DIR} -wget -q ${LIB_URL} -O ${LIB_TMP_DIR}native_client.tflite.Linux.tar.xz -unxz ${LIB_TMP_DIR}native_client.tflite.Linux.tar.xz -rm -rf ${LIB_DIR} && mkdir -p ${LIB_DIR} -tar -xf ${LIB_TMP_DIR}native_client.tflite.Linux.tar --directory ${LIB_DIR} +# Fetch the binary library release. +scripts/download_libs.sh mkdir -p ${DEB_LIB_DIR} cp -r --verbose ${LIB_DIR}*.so ${DEB_LIB_DIR} diff --git a/scripts/download_libs.sh b/scripts/download_libs.sh new file mode 100755 index 0000000..8812ed2 --- /dev/null +++ b/scripts/download_libs.sh @@ -0,0 +1,13 @@ +#!/bin/bash -xe + +BUILD_DIR=build/ +LIB_URL="https://github.com/coqui-ai/STT/releases/download/v1.1.0/native_client.tflite.Linux.tar.xz" +LIB_TMP_DIR=${BUILD_DIR}lib_tmp/ +LIB_DIR=${BUILD_DIR}lib/ + +# Download, extract and copy the libraries from Coqui's binary release. +rm -rf ${LIB_TMP_DIR} && mkdir -p ${LIB_TMP_DIR} +wget -q ${LIB_URL} -O ${LIB_TMP_DIR}native_client.tflite.Linux.tar.xz +unxz ${LIB_TMP_DIR}native_client.tflite.Linux.tar.xz +rm -rf ${LIB_DIR} && mkdir -p ${LIB_DIR} +tar -xf ${LIB_TMP_DIR}native_client.tflite.Linux.tar --directory ${LIB_DIR} diff --git a/scripts/download_models.py b/scripts/download_models.py index c762902..f1d3d62 100755 --- a/scripts/download_models.py +++ b/scripts/download_models.py @@ -4,7 +4,7 @@ os.system("mkdir -p build/models") -with open('coqui_releases.csv') as csvfile: +with open('scripts/coqui_releases.csv') as csvfile: reader = csv.reader(csvfile) for line_index, row in enumerate(reader): if line_index == 0: