-1

Edit: All of this was probably caused by a terribly configured microphone (or a faulty one, I changed laptops and now use Ubuntu instead of Arch Linux, so I actually don't have any idea). To record to a wav file, all I do now is run:

arecord -d $DURATION -f cd -t wav $OUTPUT_FILE_PATH

...replacing $DURATION with the duration of the recording in seconds, and $OUTPUT_FILE_PATH with the path to the desired file to write. I omitted the -D sysdefault argument as it caused problems for me (as with most things, your mileage may vary, so if the command doesn't work for you, try playing with several variables until it works).

Goes without saying, but all of this requires alsa-utils to be installed.

(The original question is left below, for those that still want to see it.)


Tl;dr version: arecord not recognizing plughw:1,0 , nor hw:1,0 , nor anything without the -D option

Whole story: I'm trying to make a simple voice assistant using a Bash script (I don't find Python/Perl easy for me to use, but that's just me). Dialogs are made in Zenity/KDialog. Voice recognition isn't included yet, so one has to type in the phrase/command. For now the program is represented in Spanish, but I plan to have an English version as well.

Doing my research, I found: http://blog.oscarliang.net/raspberry-pi-voice-recognition-works-like-siri/

But it doesn't work correctly on my machine.

    [owner@arch-hp-2000-notebook-pc ~]$ ~/test-speech-input 
    “Recording… Press Ctrl+C to Stop.”
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM “plughw:1,0″
    arecord: main:722: audio open error: No such file or directory
    “Processing…”
    ^C
    [owner@arch-hp-2000-notebook-pc ~]$

It apparently has to do with the arecord -D "plughw:1,0" -q -f cd -t wav part.

Output of arecord -l:

    [owner@arch-hp-2000-notebook-pc ~]$ arecord -l
    **** List of CAPTURE Hardware Devices ****
    card 1: Generic_1 [HD-Audio Generic], device 0: ALC269VC Analog [ALC269VC Analog]
      Subdevices: 1/1
      Subdevice #0: subdevice #0

Output of arecord -L:

    [owner@arch-hp-2000-notebook-pc ~]$
    null
        Discard all samples (playback) or generate zero samples (capture)
    pulse
        PulseAudio Sound Server
    default
        Default ALSA Output (currently PulseAudio Sound Server)
    sysdefault:CARD=Generic_1
        HD-Audio Generic, ALC269VC Analog
        Default Audio Device
    front:CARD=Generic_1,DEV=0
        HD-Audio Generic, ALC269VC Analog
        Front speakers
    surround21:CARD=Generic_1,DEV=0
        HD-Audio Generic, ALC269VC Analog
        2.1 Surround output to Front and Subwoofer speakers
    surround40:CARD=Generic_1,DEV=0
        HD-Audio Generic, ALC269VC Analog
        4.0 Surround output to Front and Rear speakers
    surround41:CARD=Generic_1,DEV=0
        HD-Audio Generic, ALC269VC Analog
        4.1 Surround output to Front, Rear and Subwoofer speakers
    surround50:CARD=Generic_1,DEV=0
        HD-Audio Generic, ALC269VC Analog
        5.0 Surround output to Front, Center and Rear speakers
    surround51:CARD=Generic_1,DEV=0
        HD-Audio Generic, ALC269VC Analog
        5.1 Surround output to Front, Center, Rear and Subwoofer speakers
    surround71:CARD=Generic_1,DEV=0
        HD-Audio Generic, ALC269VC Analog
        7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
    [owner@arch-hp-2000-notebook-pc ~]$

Following the first part of the answer by @CharlesDuffy (thanks for the help):

    [owner@arch-hp-2000-notebook-pc ~]$ ~/test-speech-input 
    Recording… Press Ctrl+C to Stop.
    Processing…
    You Said: [owner@arch-hp-2000-notebook-pc ~]$

Following the new answer, also by @CharlesDuffy (although this system is all AMD I think, no intel):

   [owner@arch-hp-2000-notebook-pc ~]$ test-speech-input
    Recording… Press Ctrl+C to Stop.
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM CARD=Generic_1
    arecord: main:722: audio open error: No such file or directory
    Processing…
    You Said: [owner@arch-hp-2000-notebook-pc ~]$ 

Following the newest answer by @CharlesDuffy:

    [owner@arch-hp-2000-notebook-pc ~]$ 
    Recording… Press Ctrl+C to Stop.
    ALSA lib pcm_dsnoop.c:614:(snd_pcm_dsnoop_open) unable to open slave
    arecord: main:722: audio open error: No such file or directory
    Processing…
    ^C
    [owner@arch-hp-2000-notebook-pc ~]$ 

Double-checked the volume of the internal mic, and it seemed to have selected a non-existent mic. Switching to the real mic yielded the same results.

I'm lost right now. Any other ideas? Is there any other command-line voice recording tool that might work or that might be easier to use (at least for me)?

Machine: HP 2000 Notebook PC, Arch Linux, uname -a returns Linux HOST_NAME 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015 x86_64 GNU/Linux

Jonathan Precise
  • 327
  • 3
  • 12
  • Please edit these links into your question - thanks! – Maximillian Laumeister Aug 05 '15 at 01:50
  • @MaximillianLaumeister Sorry!, they just let me put in 2 links, so i just let the commands alone and put the other three links below. – Jonathan Precise Aug 05 '15 at 11:56
  • Oh my bad! Forgot about the new user restrictions, sorry! Just edited those links in for you. – Maximillian Laumeister Aug 05 '15 at 16:55
  • @MaximillianLaumeister thanks! – Jonathan Precise Aug 06 '15 at 20:29
  • @CharlesDuffy Sorry about that, just edited the question. – Jonathan Precise Aug 06 '15 at 20:29
  • Personally, btw, I'd ask this more focused on the immediate cause. "arecord on Raspian version XXX doesn't recognize plughw driver", or such. That you're recording something to run through a recognition engine later is pretty much irrelevant to the immediate issue. – Charles Duffy Aug 07 '15 at 15:40
  • @CharlesDuffy thanks for the tip! I'll change it accordingly. – Jonathan Precise Aug 07 '15 at 17:14
  • Much better! Could you edit your question to include the output of `arecord -l` (a list of detected devices)? – Charles Duffy Aug 07 '15 at 17:28
  • @CharlesDuffy just edited the question! I didn't even know that existed in arecord. (Again, I'm new to this alsa stuff) – Jonathan Precise Aug 08 '15 at 19:32
  • In hindsight, I should have asked for `arecord -L` rather than `arecord -l`. Can make a reasonably educated guess, but not quite as good as having a device name directly from the horse's mouth. – Charles Duffy Aug 08 '15 at 19:42
  • @CharlesDuffy edited the question to include arecord -L – Jonathan Precise Aug 09 '15 at 15:06
  • The output you now quote looks a lot like "working" should. If arecord is doing its thing correctly, it may be time to start looking at the rest of the system. – Charles Duffy Aug 09 '15 at 15:10
  • Which is to say: You have an answer that fixes `arecord` (which runs with no errors in the second-to-last run quoted in your question as currently written). If you want to verify that the files it's creating actually contain microphone input, I'd suggest using `aplay` for that, rather than assuming that your speech-recognition tooling will actually work as advertised (and using its failure as an indication that something's wrong with the input end of the process). – Charles Duffy Aug 10 '15 at 22:04
  • (I'd also start looking at volume control panel settings, mic gain, &c. if `aplay` finds that your created file contains an appropriately-sized span of silence). – Charles Duffy Aug 10 '15 at 22:04

1 Answers1

2

The plughw:1,0 suggestion is specific to Raspberry Pi hardware, and doesn't necessarily apply elsewhere.

The first thing I'd suggest is removing the -D DEVICE argument entirely.


If that doesn't work, I'd suggest trying:

-D sysdefault

...for your basic on-board audio, as listed by arecord -L.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441