From 24b2e2abfd349fa743673302eda856927e1efc35 Mon Sep 17 00:00:00 2001 From: Tanner Davis Date: Sun, 3 Dec 2023 23:09:43 -0700 Subject: [PATCH] Rhasspy Voice Assistant (#3) * initial scripts for rhasspy * setup install script to use docker similar to the home assistant install script * add a bit more disk space * script for updating containers * for testing purposes * change to debian 11 FOR TESTING * another testing commit * Revert "another testing commit" This reverts commit a4cc0a0efc891965f24920a50bf61410369b75cb. * more testing * remove fuse overlayfs * actually use the correct variable * pull image correctly * no sound card passthrough * try again... * Revert "more testing" This reverts commit 93a00ca81c3ffbf41af8486bcde53abd42331674. * Revert "for testing purposes" This reverts commit 36d66a919d4354e9b4b46ea2a3cc69b5a52ea505. * default to debian 12 --- ct/rhasspy.sh | 100 +++++++++++++++++++++++++++++++++++++ install/rhasspy-install.sh | 67 +++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 ct/rhasspy.sh create mode 100644 install/rhasspy-install.sh diff --git a/ct/rhasspy.sh b/ct/rhasspy.sh new file mode 100644 index 00000000..caebe145 --- /dev/null +++ b/ct/rhasspy.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/tteck/Proxmox/main/misc/build.func) +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +function header_info { +clear +# Print Rhasspy +cat <<"EOF" + ____ __ + / __ \/ /_ ____ _______________ __ __ + / /_/ / __ \/ __ `/ ___/ ___/ __ \/ / / / + / _, _/ / / / /_/ (__ |__ ) /_/ / /_/ / +/_/ |_/_/ /_/\__,_/____/____/ .___/\__, / + /_/ /____/ +EOF +} +header_info +echo -e "Loading..." +APP="Rhasspy" +var_disk="16" +var_cpu="2" +var_ram="2048" +var_os="debian" +var_version="12" +variables +color +catch_errors + +function default_settings() { + CT_TYPE="0" + PW="" + CT_ID=$NEXTID + HN=$NSAPP + DISK_SIZE="$var_disk" + CORE_COUNT="$var_cpu" + RAM_SIZE="$var_ram" + BRG="vmbr0" + NET="dhcp" + GATE="" + DISABLEIP6="no" + MTU="" + SD="" + NS="" + MAC="" + VLAN="" + SSH="no" + VERB="no" + echo_default +} + +function update_script() { + if [[ ! -d /var/lib/docker/volumes/rhasspy_profiles/_data ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --radiolist --cancel-button Exit-Script "Spacebar = Select" 11 58 4 \ + "1" "Update ALL Containers" ON \ + "2" "Remove ALL Unused Images" OFF \ + 3>&1 1>&2 2>&3) + header_info + + if [ "$UPD" == "1" ]; then + msg_info "Updating All Containers" + CONTAINER_LIST="${1:-$(docker ps -q)}" + for container in ${CONTAINER_LIST}; do + CONTAINER_IMAGE="$(docker inspect --format "{{.Config.Image}}" --type container ${container})" + RUNNING_IMAGE="$(docker inspect --format "{{.Image}}" --type container "${container}")" + docker pull "${CONTAINER_IMAGE}" + LATEST_IMAGE="$(docker inspect --format "{{.Id}}" --type image "${CONTAINER_IMAGE}")" + if [[ "${RUNNING_IMAGE}" != "${LATEST_IMAGE}" ]]; then + echo "Updating ${container} image ${CONTAINER_IMAGE}" + DOCKER_COMMAND="$(runlike "${container}")" + docker rm --force "${container}" + eval ${DOCKER_COMMAND} + fi + done + msg_ok "Updated All Containers" + exit + fi + if [ "$UPD" == "2" ]; then + msg_info "Removing ALL Unused Images" + docker image prune -af + msg_ok "Removed ALL Unused Images" + exit + fi + + +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${APP} should be reachable by going to the following URL. + ${BL}http://${IP}:12101${CL}\n" + \ No newline at end of file diff --git a/install/rhasspy-install.sh b/install/rhasspy-install.sh new file mode 100644 index 00000000..65d92796 --- /dev/null +++ b/install/rhasspy-install.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2023 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/tteck/Proxmox/raw/main/LICENSE + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y curl +$STD apt-get install -y sudo +$STD apt-get install -y mc +msg_ok "Installed Dependencies" + +msg_info "Updating Python" +$STD apt-get install -y \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv +msg_ok "Updated Python" + +get_latest_release() { + curl -sL https://api.github.com/repos/$1/releases/latest | grep '"tag_name":' | cut -d'"' -f4 +} + +DOCKER_LATEST_VERSION=$(get_latest_release "moby/moby") +RHASSPY_LATEST_VERSION=$(get_latest_release "rhasspy/rhasspy") + +msg_info "Installing Docker $DOCKER_LATEST_VERSION" +DOCKER_CONFIG_PATH='/etc/docker/daemon.json' +mkdir -p $(dirname $DOCKER_CONFIG_PATH) +$STD sh <(curl -sSL https://get.docker.com) +msg_ok "Installed Docker $DOCKER_LATEST_VERSION" + +msg_info "Pulling Rhasspy $RHASSPY_LATEST_VERSION Image" +$STD docker pull rhasspy/rhasspy:latest +msg_ok "Pulled Rhasspy $RHASSPY_LATEST_VERSION Image" + +msg_info "Installing Rhasspy" +$STD docker volume create rhasspy_profiles +$STD docker run -d \ + -p 12101:12101 \ + --name=rhasspy \ + --restart=always \ + -v "rhasspy_profiles:/profiles" \ + -v "/etc/localtime:/etc/localtime:ro" \ + rhasspy/rhasspy:latest \ + --user-profiles /profiles \ + --profile en +mkdir /root/rhasspy_profiles +msg_ok "Installed Rhasspy" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get autoremove +$STD apt-get autoclean +msg_ok "Cleaned" \ No newline at end of file