element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Wolfson sound card working fine when I test, but not with pocketsphinx
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 8 replies
  • Subscribers 706 subscribers
  • Views 1462 views
  • Users 0 members are here
  • raspberry_pi
  • raspeberry_pi_accessories
Related

Wolfson sound card working fine when I test, but not with pocketsphinx

e14 Contributor
e14 Contributor over 11 years ago

I have tested recording and playback with my wolfson audio card, and both work fine. The problem is, when I try to use pocketsphinx with the card, it gives this error:

 

"Failed to set PCM device to mono: Invalid argument

FATAL: "continuous.c", line 239: Failed to open audio device"

 

It may problem with the .asoundrc or another hidden config file...

I found this .asoundrc file on the internet that supposedly works with the wolfson:

 

  1. ####################################################################### 
  2. # 
  3. # Use libsamplerate instead of internal resampler. 
  4. # You might have to: sudo apt-get install libasound2-plugins 
  5. # Or just comment out the next line if the internal one is good enough for your needs. 
  6. defaults.pcm.rate_converter "samplerate" 
  7.  
  8. ###################################################################### 
  9. # 
  10. # Wolfson Audio Card for Raspberry Pi 
  11. # 
  12. pcm.wolfson_pi_soundcard { 
  13.   type hw 
  14.   card sndrpiwsp 
  15.   device 0 
  16. } 
  17. # Create a Master volume control 
  18. pcm.softvol { 
  19.   type softvol 
  20.   slave { 
  21.   pcm "pduplex" 
  22.   } 
  23.   control { 
  24.   name "Master" 
  25.   card 0 
  26.   } 
  27. } 
  28.  
  29. pcm.!default { 
  30.   type asym 
  31.   playback.pcm "plug:softvol" 
  32.   capture.pcm "pduplex" 
  33. } 
  34.  
  35. ##################################################################### 
  36. # 
  37. # Mixing and resampling goodness :-) 
  38. # 
  39. # Several clients can record and play back simultaneously. 
  40. # The dmix and dsnoop plugins operate at 48kHz by default, i.e. the sound card will be kept at 48kHz at all times. 
  41. # All playback streams are converted to 2 channels/48kHz/16bit. 
  42. # All recording streams are converted from the card's 2 channels/48kHz/16bit 
  43. # to the requested number of channels, sample rate and bit depth. 
  44.  
  45. # We define one pcm device called "playmixer" for playback. 
  46. pcm.playmixer { 
  47.   ipc_key 140324 # Any number will do, as long as it's unique in the system. 
  48.   ipc_key_add_uid true 
  49.   type dmix 
  50.   slave.pcm "wolfson_pi_soundcard" 
  51. } 
  52.  
  53. # Define another one called "recmixer" for capture. 
  54. # The sound card will run at 48kHz and input is resampled to the requested rate. 
  55. pcm.recmixer { 
  56.   ipc_key 140325 
  57.   ipc_key_add_uid true 
  58.   type dsnoop 
  59.   slave.pcm "wolfson_pi_soundcard" 
  60. } 
  61.  
  62. # Define a duplex device, with both in- and outputs. 
  63. pcm.duplex { 
  64.   type asym 
  65.   playback.pcm "playmixer" 
  66.   capture.pcm "recmixer" 
  67. } 
  68.  
  69. # Add a "plug" plugin for the above "duplex" device. 
  70. # This is where all the converting takes place. 
  71. # Sample rate, number of channels, bit depth. 
  72. # By the way, who thought that "plug" was a good name for a plugin? 
  73. # 
  74. # Use this device for all your playback and recording resampling needs. 
  75. pcm.pduplex { 
  76.   type plug 
  77.   slave.pcm "duplex" 
  78. } 
  79.  
  80. # A ctl device to keep xmms happy 
  81. ctl.pduplex { 
  82.   type hw 
  83.   card 0 
  84. } 
  85.  
  86. # A DSP to keep the alsa-oss layer happy: 
  87. pcm.dsp0 { 
  88.   type plug 
  89.   slave.pcm "duplex" 
  90. } 
  91.  
  92. ctl.mixer0 { 
  93.   type hw 
  94.   card 0 
  95. } 


Why is the wolfson not working with pocketsphinx when it worked when I recorded .wav files?

  • Sign in to reply
  • Cancel
Parents
  • clem57
    0 clem57 over 11 years ago

    First which Pi version 1 or version 2? This makes big difference. I would look at PocketSphinx on Raspberry Pi |

    • You’ll need to download both sphinxbase and pocketsphinx.
    • The short version is that you must, at the minimum, install alsa-utils:
    • You’ll also need bison and libasound2-dev.

     

    To test: ./src/programs/pocketsphinx_continuous -adcdev plughw:1,0 -nfft 2048 -samprate 48000

     

    See A close look at ALSA for more help.

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 11 years ago in reply to clem57

    I am using the DMIC, and it won't let me record in mono. I used this command: arecord -Dhw:0 -r 48000 -c 2 -f S32_LE test2.wav and it worked, but when I set -c to 1, it didn't work. Can the DMIC not record in mono?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 11 years ago in reply to e14 Contributor

    Yes it can if setup correctly. http://www.cirrus.com/en/pubs/appNote/WAN0263_1.pdf under CONNECTION TO CODECS describes how mono works.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 11 years ago in reply to clem57

    I see that stereo sound with the DMICs is just mono in parallel, but how would I configure the software side of ALSA to allow mono recording?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 11 years ago in reply to clem57

    Never mind, I got it working correctly.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 11 years ago in reply to e14 Contributor

    Good to hear. But what fixed it?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • e14 Contributor
    0 e14 Contributor over 11 years ago in reply to clem57

    I found that this command allows me to record in mono for some reason: arecord --device=plughw:0,0 -r 44100 -c1 -f S16_LE test.wav, so I combined all the parameters that I could with the pocketsphinx_continuous command to get this: pocketsphinx_continuous -adcdev plughw:0,0 -nfft 2048 -samprate 48000 -inmic yes. I also modified one of the wolfson card case scripts to only deal with one channel, but I am not sure if that was what fixed it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • e14 Contributor
    0 e14 Contributor over 11 years ago in reply to clem57

    I found that this command allows me to record in mono for some reason: arecord --device=plughw:0,0 -r 44100 -c1 -f S16_LE test.wav, so I combined all the parameters that I could with the pocketsphinx_continuous command to get this: pocketsphinx_continuous -adcdev plughw:0,0 -nfft 2048 -samprate 48000 -inmic yes. I also modified one of the wolfson card case scripts to only deal with one channel, but I am not sure if that was what fixed it.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • e14 Contributor
    0 e14 Contributor over 10 years ago in reply to e14 Contributor

    I encountered the same situation could you share some hints to me ? thank you.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube