/usr/share/checkbox/scripts/audio_test is in checkbox 0.13.7.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/bin/bash
OUTPUT=`mktemp -u`.wav
GST_COMMAND_OLD="/usr/bin/gst-launch"
GST_COMMAND_NEW="/usr/bin/gst-launch-0.10"
GST_COMMAND_OPTS="audiotestsrc wave=sine freq=512 ! audioconvert !
audioresample ! gconfaudiosink"
#SOX_COMMAND="rec -q -r 44100 -p | sox -p $OUTPUT silence -l 1 00:00:00.5 -45d -1 00:00:00.5 -45d"
REC_COMMAND="rec -q -r 44100 $OUTPUT"
SOX_COMMAND="sox $OUTPUT $OUTPUT.1.wav silence -l 1 00:00:00.5 -45d -1 00:00:00.5 -45d"
# Start playing a sine wave
if [ -e $GST_COMMAND_OLD ]; then
$GST_COMMAND_OLD $GST_COMMAND_OPTS &
else
$GST_COMMAND_NEW $GST_COMMAND_OPTS &
fi
GST_PID=$!
# Listen for it on the audio input
$REC_COMMAND &
REC_PID=$!
# Wait a bit, then stop playing
sleep 2
echo "Killing REC_COMMAND PID: $REC_PID and GST_COMMAND PID: $GST_PID"
kill $REC_PID $GST_PID
# Look for silence
$SOX_COMMAND
# See if the filesize > 80 bytes on the output file
# (80 bytes is the largest wav file that will be generated for silence,
# so if we have that size we detected nothing but silence)
FILESIZE=`stat -c%s "$OUTPUT.1.wav"`
rm "$OUTPUT" "$OUTPUT.1.wav"
if [ "$FILESIZE" == "" ]
then
echo "Unable to find output file." >&2
exit 2
fi
if [ "$FILESIZE" -lt "81" ]
then
echo "No audio detected." >&2
exit 1
else
echo "$FILESIZE bytes of audio recorded."
exit 0
fi
|