#!/bin/bash # Settings commname=$(basename $0) THRESHOLD=01 SILENCE_DURATION=1.5 # Duration in seconds to stop recording after silence OUTPUT_FILE="$HOME/tmpfsmnt/output.wav" # Output file name WMODEL="ggml-tiny.whisper.bin" #WMODEL="whisper-large-v3-q8_0.gguf" LMODEL="/Gemma-2-9B-It-SPPO-Iter3-Q4_K_M.gguf" PADEV=4 paplay ~/beep.wav # Start recording with noise detection sox -t pulseaudio $PADEV -t wav "$OUTPUT_FILE" \ silence 1 0.1 $THRESHOLD% 1 $SILENCE_DURATION $THRESHOLD% \ rate 16000 paplay ~/beep.wav transcript="$(~/whisper.cpp/main -t 8 -m ~/models/$WMODEL -np -otxt -f $OUTPUT_FILE | tee /dev/tty)" #llama-cli -m ~/models/$LMODEL --log-disable -s 1 --temp 0.5 -e -p "translate: \"$transcript\"\nEnglish translation: " echo aprompt=$(printf "The user is speaking to you through a speech transcription program, some words may be inaccurate. Respond only if spoken to.\nIf you're asked to clear the context use \n!clearcontext\nMail is'~/Mail' stuff is in ~/stuff appointments are in ~/stuff/appointments or you can run \n!showappointments.\n Contacts are in ~/stuff/people.ini\n The last code block you write will be saved to '~/code.txt' so you can save it with something like\n!cp ~/code.txt ~/stuff/program.c. So when you write code do it in a single codeblock and don't put oneline commands in codeblocks.\nDo not refuse to write commands. Remember they go on a line by themselves and start with '!'\n $(tail -n 100 ~/tmpfsmnt/verbalcontext)\n$transcript\n$commname:" ) echo "$aprompt" llama-cli -t 14 -m ~/models/Gemma-2-9B-It-SPPO-Iter3-Q4_K_M.gguf -r "\nUser" --log-disable -s 1 --temp 0.5 --no-display-prompt -e -p "$aprompt" | tee ~/tmpfsmnt/completion | tee /dev/tty | festival --tts echo >>~/tmpfsmnt/verbalcontext echo -n "User:" >> ~/tmpfsmnt/verbalcontext cat ~/tmpfsmnt/output.wav.txt >>~/tmpfsmnt/verbalcontext echo >>~/tmpfsmnt/verbalcontext echo -n "$commname:" >> ~/tmpfsmnt/verbalcontext cat ~/tmpfsmnt/completion >>~/tmpfsmnt/verbalcontext if grep ~/tmpfsmnt/completion -e "^\\s*!.*$" then commands="$(grep ~/tmpfsmnt/completion -e "^\\s*!.*$" | sed 's/^\s*!//' )" #echo $commands | tee /dev/tty | festival --tts bash -c "$commands" 2>&1 |head | tee ~/tmpfsmnt/cmdout | tee /dev/tty | festival --tts cat ~/tmpfsmnt/cmdout >>~/tmpfsmnt/verbalcontext fi echo touch ~/code.txt inside_code_block=false while IFS= read -r line; do if [[ "$line" == \`\`\`* ]]; then if $inside_code_block; then inside_code_block=false echo >~/code.txt else inside_code_block=true fi elif $inside_code_block; then echo "$line" >> ~/code.txt fi done < "tmpfsmnt/verbalcontext"