Day: December 7, 2012

Testing if your sound card can record at 16KHz needed by some voice recognition engines

These are the commands I use to verify if the sound card can record at 16KHz:

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC275 Analog [ALC275 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
alan@aureo:~$ arecord -B 120000 -D "hw:CARD=0,DEV=0" -r 16000 -c 1 -f S16_LE file.wav -v
Recording WAVE 'file.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
arecord: set_params:1087: Channels count non available

$ arecord -B 120000 -D "hw:CARD=0,DEV=0" -r 16000 -c 2 -f S16_LE file_2ch.wav -v
Recording WAVE 'file_2ch.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
Warning: rate is not accurate (requested = 16000Hz, got = 44100Hz)
please, try the plug plugin
Hardware PCM card 0 'HDA Intel PCH' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 5292
period_size : 1323
period_time : 30000
tstamp_mode : NONE
period_step : 1
avail_min : 1323
period_event : 0
start_threshold : 1
stop_threshold : 5292
silence_threshold: 0
silence_size : 0
boundary : 1387266048
appl_ptr : 0
hw_ptr : 0

^C
Aborted by signal Interrupt...

$ mplayer file_2ch.wav
MPlayer svn r34540 (Ubuntu), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing file_2ch.wav.
libavformat version 53.21.0 (external)
Mismatching header version 53.19.0
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 12.7 (12.7) of 13.0 (13.0) 0.1%

(pressed Ctrl+C to finish recording)
Exiting... (End of file)

In this case the sound card cannot manage audio record at 16KHz and changed it to 44100 Hz