mirror of
https://github.com/TaterTotterson/microWakeWord-Trainer-Nvidia-Docker.git
synced 2026-06-12 20:10:19 -06:00
Add VAD trimming and Docker publishing
This commit is contained in:
66
run.sh
66
run.sh
@@ -26,6 +26,16 @@ echo "-> URL: http://localhost:${PORT}/"
|
||||
|
||||
mkdir -p "${DATA_DIR}"
|
||||
|
||||
install_ui_deps() {
|
||||
${PIP} install \
|
||||
"fastapi==${FASTAPI_VERSION}" \
|
||||
"uvicorn[standard]==${UVICORN_VERSION}" \
|
||||
"python-multipart==${PY_MULTIPART_VERSION}" \
|
||||
"esphome==${ESPHOME_VERSION}" \
|
||||
"silero-vad>=5.0.0" \
|
||||
"numpy>=1.24.0"
|
||||
}
|
||||
|
||||
# -----------------------------
|
||||
# Trainer UI venv (separate)
|
||||
# -----------------------------
|
||||
@@ -40,32 +50,54 @@ source "${VENV_DIR}/bin/activate"
|
||||
if [[ ! -f "${PIN_FILE}" ]]; then
|
||||
echo "Installing pinned trainer UI deps"
|
||||
${PIP} install -U pip setuptools wheel
|
||||
${PIP} install \
|
||||
"fastapi==${FASTAPI_VERSION}" \
|
||||
"uvicorn[standard]==${UVICORN_VERSION}" \
|
||||
"python-multipart==${PY_MULTIPART_VERSION}" \
|
||||
"esphome==${ESPHOME_VERSION}"
|
||||
install_ui_deps
|
||||
touch "${PIN_FILE}"
|
||||
else
|
||||
echo "Reusing existing trainer UI venv (no upgrades)"
|
||||
if ! "${PY}" - "${ESPHOME_VERSION}" <<'PY' >/dev/null 2>&1
|
||||
import importlib.metadata
|
||||
if ! "${PY}" - "${FASTAPI_VERSION}" "${UVICORN_VERSION}" "${PY_MULTIPART_VERSION}" "${ESPHOME_VERSION}" <<'PY' >/dev/null 2>&1
|
||||
import importlib.metadata as md
|
||||
import sys
|
||||
|
||||
expected = sys.argv[1]
|
||||
installed = importlib.metadata.version("esphome")
|
||||
raise SystemExit(0 if installed == expected else 1)
|
||||
fastapi_version, uvicorn_version, multipart_version, esphome_version = sys.argv[1:5]
|
||||
|
||||
def version_tuple(value):
|
||||
parts = []
|
||||
for token in str(value).replace("-", ".").split("."):
|
||||
if token.isdigit():
|
||||
parts.append(int(token))
|
||||
else:
|
||||
digits = "".join(ch for ch in token if ch.isdigit())
|
||||
if digits:
|
||||
parts.append(int(digits))
|
||||
break
|
||||
return tuple(parts)
|
||||
|
||||
exact = {
|
||||
"fastapi": fastapi_version,
|
||||
"uvicorn": uvicorn_version,
|
||||
"python-multipart": multipart_version,
|
||||
"esphome": esphome_version,
|
||||
}
|
||||
minimum = {
|
||||
"silero-vad": "5.0.0",
|
||||
"numpy": "1.24.0",
|
||||
}
|
||||
present = ("torch", "zeroconf")
|
||||
|
||||
for package, expected in exact.items():
|
||||
if md.version(package) != expected:
|
||||
raise SystemExit(1)
|
||||
for package, minimum_version in minimum.items():
|
||||
if version_tuple(md.version(package)) < version_tuple(minimum_version):
|
||||
raise SystemExit(1)
|
||||
for package in present:
|
||||
md.version(package)
|
||||
PY
|
||||
then
|
||||
echo "Firmware tab dependencies missing or stale; installing ESPHome firmware dependencies"
|
||||
${PIP} install \
|
||||
"fastapi==${FASTAPI_VERSION}" \
|
||||
"uvicorn[standard]==${UVICORN_VERSION}" \
|
||||
"python-multipart==${PY_MULTIPART_VERSION}" \
|
||||
"esphome==${ESPHOME_VERSION}"
|
||||
echo "UI dependencies missing or stale; installing recorder dependencies"
|
||||
install_ui_deps
|
||||
fi
|
||||
fi
|
||||
|
||||
# -----------------------------
|
||||
# Trainer server env
|
||||
# -----------------------------
|
||||
|
||||
Reference in New Issue
Block a user