Skip to content

Commit

Permalink
Updated build process
Browse files Browse the repository at this point in the history
  • Loading branch information
petewarden committed Jan 3, 2022
1 parent 8d4a968 commit 6e9c891
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,2 +1,3 @@
spchcat
build
build
audio*
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions definitions.mk
Expand Up @@ -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

Expand Down
10 changes: 3 additions & 7 deletions 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."
Expand Down Expand Up @@ -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}

Expand Down
13 changes: 13 additions & 0 deletions 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}
2 changes: 1 addition & 1 deletion scripts/download_models.py
Expand Up @@ -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:
Expand Down

0 comments on commit 6e9c891

Please sign in to comment.