# /bin/bash main() { set -eo pipefail tty && read -p "git refresh? [yN] " a && test "$a" == "y" && ( git config --global credential.helper store git submodule init git pull --recurse-submodules --jobs=10 git submodule foreach git pull origin master ) _tts _mayhem_party _discord _stt _dolphin while read; do pkill -SIGUSR1 -f mayhem-party done } _cleanup() { pkill -f larynx pkill -f hotwords.py pkill -f rust-whisper pkill -f mayhem-party } cleanup() { pkill -f server.sh _cleanup } _cleanup trap cleanup EXIT log() { echo "$(date) > $*" >&2 } _discord() { echo read -p "pls start discord" echo } _dolphin() { echo read -p "pls start dolphin" echo } _mayhem_party() { log mayhem-party pushd ./git.d/mayhem-party.d go build popd log launching mayhem-party ( source ./config.d/mayhem-party.d/env.env ./git.d/mayhem-party.d/mayhem-party ) & } _tts() { log launching tts pushd ./git.d/tts.d/larynx.d/ chmod -R 777 ./mnt.d || true bash ./run.sh popd } _stt() { log stt ( export HOME="$PWD/mnt.d/stt.d" mkdir -p "$HOME" cd "$HOME" bash ../../git.d/stt.d/rust-whisper.d/download_models.sh if [ -n "$PIP" ]; then pip3 install -r ../../git.d/stt.d/rust-whisper.d/requirements.txt fi local device=$( pactl list \ | grep Monitor.Source \ | grep -v hdmi \ | awk "{print \$NF}" \ | head -n 1 ) if ! test -f /etc/asound.conf || ! grep "$device" /etc/asound.conf; then ( echo "pcm.pulse_monitor {" echo " type pulse" echo " device $device" echo "}" echo "ctl.pulse_monitor {" echo " type pulse" echo " device $device" echo "}" ) | sudo tee /etc/asound.conf fi for i in $(pactl list short modules | grep secret | cut -f1); do pactl unload-module $i done name='my_secret_sink' for i in 1 2; do if ! pactl list | grep -q $name$i; then pactl load-module module-null-sink sink_name=$name$i channels=1 pactl load-module module-remap-source master=$name$i.monitor source_name=shared-$name$i source_properties="device.description=shared-$name$i" mic_name="$(pactl list | grep -A 100 Name:.$name$i.monitor | grep device.description.=. | head -n 1 | sed 's/.* = //' | tr -d '"') Monitor" fi done echo read -p "pavucontrol to change input to $name, ok? " echo log launching stt ( export HOTWORDS=../../config.d/mayhem-party.d/v01-live.yaml@.users[].state.gm.alias export MIC_TIMEOUT=2 export URL=http://localhost:17071/gm/rpc/broadcastSomeoneSaidAlias?message={{hotword}} export HEADERS=say="Eye herd {{hotword}}" export MIC_NAME="${MIC_NAME:-pulse_monitor}" export MODEL=tiny.en export P=2 while ! python3 ../../git.d/stt.d/rust-whisper.d/hotwords.py; do sleep 5 done ) & ) } if [ "$0" == "$BASH_SOURCE" ]; then main "$@" fi