diff --git a/server-baremetal.sh b/server-baremetal.sh new file mode 100644 index 0000000..36efea0 --- /dev/null +++ b/server-baremetal.sh @@ -0,0 +1,18 @@ +# /bin/bash + +main() { + trap cleanup exit + log tts +} + +cleanup() { + kill -9 $(jobs -p) +} + +log() { + echo "$(date) > $*" >&2 +} + +if [ "$0" == "$BASH_SOURCE" ]; then + main "$@" +fi diff --git a/server-vm.sh b/server-vm.sh new file mode 100644 index 0000000..212103e --- /dev/null +++ b/server-vm.sh @@ -0,0 +1,116 @@ +# /bin/bash + +main() { + trap cleanup exit + _discord + _dolphin + _stt + _mayhem_party + while read; do + pkill -SIGUSR1 -f mayhem-party + done +} + +cleanup() { + kill -9 $(jobs -p) +} + +log() { + echo "$(date) > $*" >&2 +} + +_discord() { + if ! _snap info discord; then + sudo snap install discord + fi + log launching discord + snap run discord &> /tmp/mayhem-party.discord.log & +} + +_dolphin() { + log dolphin + if ! _snap info dolphin; then + sudo snap install dolphin-emulator --beta + fi + log launching dolphin + snap run dolphin-emulator &> /tmp/mayhem-party.dolphin.log & +} + +_mayhem_party() { + log dolphin + if ! go version; then + sudo snap install go --classic + cd ./git.d/mayhem-party.d + go install + fi + log launching mayhem-party + ( + source ../../config.d/mayhem-party.d/env.env + while true; do + "$HOME"/Go/bin/mayhem-party + sleep 5 + done + ) &> /tmp/mayhem-party.mayhem-party.log & +} + +_stt() { + if ! python3 -m pip info PyAudio; then + sudo apt -y install \ + portaudio19-dev \ + python3-pyaudio \ + python3-pip \ + git \ + pulseaudio + sudo python3 -m pip install --no-cache-dir \ + git+https://github.com/openai/whisper.git \ + soundfile \ + PyAudio \ + SpeechRecognition \ + PyYAML + fi + log launching stt + ( + export HOME="$PWD/mnt.d/stt.d" + mkdir -p "$HOME" + cd "$HOME" + local device=$( + pactl list \ + | grep Monitor.Source \ + | grep -v hdmi \ + | awk "{print \$NF}" \ + | head -n 1 + ) + ( + 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 + cd ../../git.d/stt.d/whisper-2023 + export HOTWORDS=../../config.d/mayhem-party.d/v01.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=pulse_monitor + while true; do + python3 ./hotwords.py + sleep 5 + done + ) &> /tmp/mayhem-party.stt.log & +} + +_snap() { + if ! which snap; then + sudo apt -y install snap + fi + snap "$@" +} + +if [ "$0" == "$BASH_SOURCE" ]; then + main "$@" +fi +