Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Oct 22, 2024
1 parent 432cca7 commit 4d89d89
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 0 deletions.
Binary file added .docker-compose.yaml.swp
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dirs
Binary file added .start.sh.swp
Binary file not shown.
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG BUILD_FROM
FROM ${BUILD_FROM}

# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install wyoming-vosk
WORKDIR /usr/src
ARG WYOMING_VOSK_VERSION
ENV PIP_BREAK_SYSTEM_PACKAGES=1

RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
netcat-traditional \
python3 \
python3-pip \
libatomic1 \
&& pip3 install --no-cache-dir -U \
setuptools \
wheel \
&& pip3 install --no-cache-dir \
--extra-index-url https://www.piwheels.org/simple \
-f . \
"wyoming-vosk[limited] @ https://github.com/rhasspy/wyoming-vosk/archive/refs/tags/v${WYOMING_VOSK_VERSION}.tar.gz" \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /
COPY start.sh /start.sh
ENTRYPOINT ["bash", "start.sh"]
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BUILD_FROM=ghcr.io/home-assistant/amd64-base-debian:bookworm
WYOMING_VOSK_VERSION=1.5.0
docker build --build-arg BUILD_FROM=${BUILD_FROM} \
--build-arg WYOMING_VOSK_VERSION=${WYOMING_VOSK_VERSION} \
-t wyoming-vosk-standalone:${WYOMING_VOSK_VERSION} \
-f Dockerfile .
17 changes: 17 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"
services:
vosk:
image: wyoming-vosk-standalone:1.5.0
environment:
- CORRECT_SENTENCES=0.0
- PRELOAD_LANGUAGE=en
- DEBUG_LOGGING=TRUE
- LIMIT_SENTENCES=TRUE
- ALLOW_UNKNOWN=False
volumes:
- ./dirs/data:/data
- ./dirs/sentences:/share/vosk/sentences
ports:
- 10300:10300


42 changes: 42 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
flags=()

CORRECT_SENTENCES="${CORRECT_SENTENCES:-0.0}"
PRELOAD_LANGUAGE="${PRELOAD_LANGUAGE:-en}"

if [ "${DEBUG_LOGGING}" == "TRUE" ]; then
flags+=('--debug')
fi

if [ "${LIMIT_SENTENCES}" == "TRUE" ]; then
flags+=('--limit-sentences')
fi

if [ "${ALLOW_UNKNOWN}" == "TRUE" ]; then
flags+=('--allow-unknown')
fi

echo CORRECT_SENTENCES = ${CORRECT_SENTENCES}
echo PRELOAD_LANGUAGE = ${PRELOAD_LANGUAGE}
echo DEBUG_LOGGING = ${DEBUG_LOGGING}
echo LIMIT_SENTENCES = ${LIMIT_SENTENCES}
echo ALLOW_UNKNOWN = ${ALLOW_UNKNOWN}

if [ -d '/share/vosk/models' ]; then
# Each directory is a language name with a model inside
while read -r lang_dir; do
# Override the model for this language
lang="$(basename "${lang_dir}")"
flags+=('--model-for-language' "${lang}" "$(realpath "${lang_dir}")")
done < <(find '/share/vosk/models' -mindepth 1 -maxdepth 1 -type d)
fi

echo flags = ${flags[@]}
python3 -m wyoming_vosk \
--uri 'tcp://0.0.0.0:10300' \
--data-dir /data \
--download-dir /data \
--data-dir /share/vosk/models \
--sentences-dir /share/vosk/sentences \
--correct-sentences $CORRECT_SENTENCES \
--language $PRELOAD_LANGUAGE \
--preload-language $PRELOAD_LANGUAGE ${flags[@]}

0 comments on commit 4d89d89

Please sign in to comment.