~ubuntu-branches/ubuntu/precise/checkbox/precise-201204040741

« back to all changes in this revision

Viewing changes to scripts/audio_detect_silence

  • Committer: Package Import Robot
  • Author(s): Ara Pulido, Ara Pulido, Brendan Donegan, Daniel Manrique, Jeff Lane, Marc Tardif
  • Date: 2011-09-01 12:23:07 UTC
  • Revision ID: package-import@ubuntu.com-20110901122307-ryc7ctlg9oa6b1wr
Tags: 0.12.5
New upstream release (LP: #838745):

[Ara Pulido]
* Created a "suspend" suite and renamed relevant tests.

[Brendan Donegan]
* Removed redundant tests in power-management suite.
* Fixed dependencies in power-management suite.

[Daniel Manrique]
* Changed name of apt-get test to reflect the suite it's in.
* Fixed typos in job definitions that caused them to not be run.
* Added missing description to info/hdparm test (LP: #832351)
* Quote command to obtain bluetooth address, to avoid hanging if 
  a device is not present (LP: #836756).
* Added BLUETOOTH category to udev parser.
* Removed some tests from default whitelist.
* Fixed dependencies for keys/sleep.

[Jeff Lane]
* Added new USB storage transfer test
* Re-worked and added automated audio test

[Marc Tardif]
* Added WIRELESS category to udev parser.

Show diffs side-by-side

added added

removed removed

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