[Linux] Voice activation/Open mic
devel
Join Date: 2014-09-13 Member: 198444Members
Script for Linux to have a button-less microphone:
(it also needs a 50-100ms delay to be set up in Pavucontrol, so the first word isn't cut)
(it also needs a 50-100ms delay to be set up in Pavucontrol, so the first word isn't cut)
#!/bin/bash # Voice activation/Open mic # Presses N key when voice is detected. # 'threshold' defines the sensivity, `post_tx` - amount of silence before releasing the key. # Also set 50-100ms delay in the PulseAudio settings. # Ubuntu 15.04 set -e threshold=17 post_tx=10 active= silent_count=0 arecord -D pulse -c 2 -d 0 -f S16_LE -B 100000 -vvv /dev/null 2>&1 | stdbuf -oL sed -n 's/.*\s\([0-9]\+\)%/\1/p'| while read v; do if ((v > threshold)); then if [ -z "$active" ]; then echo 'keydown n' active=1 fi silent_count=0 else if [ -n "$active" ] && ((++silent_count > post_tx)); then active= echo 'keyup n' fi fi done | xte