脚本
#!/bin/bash --
# record from microphone
rec --channels 1 /tmp/rec.sox trim 0.9 band 4k noiseprof /tmp/noiseprof &&
# convert to mp3
sox /tmp/rec.sox --compression 0.01 /tmp/rec.mp3 trim 0 -0.1 &&
# play recording to test for noise
play /tmp/rec.mp3 &&
printf "\nRemove noise? "
read reply
# If there's noise, remove it
if [[ $reply == "y" ]]; then
sox /tmp/rec.sox --compression 0.01 /tmp/rec.mp3 trim 0 -0.1 noisered /tmp/noiseprof 0.1
play /tmp/rec.mp3
fi
错误与:read error: 0: Resource temporarily unavailable
但-e
,如果我使用标志 onread
来启用,则脚本可以工作readline