No audio from snips, (sam test speakers works)

Hey there,
I am currently having som problems with audio out here.

Fresh installed snips:

    Connected to device snips
    OS version ................... Raspbian GNU/Linux 9 (stretch)
    Installed assistant .......... Snips
    Language ..................... de
    Hotword ...................... hey_snips
    ASR engine ................... snips
    Status ....................... Live

    Service status:

    snips-analytics .............. (not running)
    snips-asr .................... 0.63.2 (running)
    snips-audio-server ........... 0.63.2 (running)
    snips-dialogue ............... 0.63.2 (running)
    snips-hotword ................ 0.63.2 (running)
    snips-nlu .................... 0.63.2 (running)
    snips-skill-server ........... 0.63.2 (running)
    snips-tts .................... 0.63.2 (running)

“sam test speaker” works well and gives audio output to speakers.

aplay -L output:
    null
        Discard all samples (playback) or generate zero samples (capture)
    default
    sysdefault:CARD=ALSA
        bcm2835 ALSA, bcm2835 ALSA
        Default Audio Device
    dmix:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Direct sample mixing device
    dmix:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Direct sample mixing device
    dsnoop:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Direct sample snooping device
    dsnoop:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Direct sample snooping device
    hw:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Direct hardware device without any conversions
    hw:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Direct hardware device without any conversions
    plughw:CARD=ALSA,DEV=0
        bcm2835 ALSA, bcm2835 ALSA
        Hardware device with all software conversions
    plughw:CARD=ALSA,DEV=1
        bcm2835 ALSA, bcm2835 IEC958/HDMI
        Hardware device with all software conversions
arecord -L output:
    null
        Discard all samples (playback) or generate zero samples (capture)
    default
    sysdefault:CARD=seeed4micvoicec
        seeed-4mic-voicecard,
        Default Audio Device
    dmix:CARD=seeed4micvoicec,DEV=0
        seeed-4mic-voicecard,
        Direct sample mixing device
    dsnoop:CARD=seeed4micvoicec,DEV=0
        seeed-4mic-voicecard,
        Direct sample snooping device
    hw:CARD=seeed4micvoicec,DEV=0
        seeed-4mic-voicecard,
        Direct hardware device without any conversions
    plughw:CARD=seeed4micvoicec,DEV=0
        seeed-4mic-voicecard,
        Hardware device with all software conversions
asound.conf
    cm.!default {               
        type asym               
        playback.pcm {          
            type plug           
            slave.pcm "hw:0,0"  
        }                       
        capture.pcm {           
            type plug           
            slave.pcm "hw:1,0"  
        }                       
    }                           

but syslog contains the following:

	INFO:snips_audio_portaudio      : Playing "27d72cc2-1e86-4144-82e0-a2870b00968c" using output "bcm2835 ALSA: IEC958/HDMI (hw:0,1)",
    Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2043

I expected snips_audio to play the feedback sounds and tts on the configured audio device not the hdmi audio.

But no audio from snips :frowning:
Can please someone give me an hint?

Hi! Try this:

    pcm.!default {               
        type asym               
        playback.pcm {          
            rate 16000
            type plug           
            slave.pcm "hw:0,0"  
        }                       
        capture.pcm {           
            type plug           
            slave.pcm "hw:1,0"  
        }                       
    }   
1 Like

The solution @Psycho can work

also, Portaudio seems to have some issues with the latest kernel update.

You can fallback on alsa directly

add the following options to the snips-audio-server configuration in your snips.toml

[snips-audio-server]
alsa_capture = "default"
alsa_playback = "default"

seems to solve a lot of issue

1 Like

Hello and thank you!
I changed to

asound.conf

    cm.!default {               
        type asym               
        playback.pcm {          
            rate 16000
            type plug                           
            slave.pcm "hw:0,0"  
        }                       
        capture.pcm {           
            type plug           
            slave.pcm "hw:1,0"  
        }                       
    }                           

Syslog:

	 snips-hotword [17623]INFO:snips_hotword_lib::audio    : Audio thread for site default stopped.
	 snips snips-audio-server[17639]: INFO:snips_audio_portaudio      : Playing "ddde2676-35c4-4628-9122-dd4ee4a576d6" using output "bcm2835 ALSA: IEC958/HDMI (hw:0,1)", wav spec: WavSpec { channels: 1, sample_rate: 16000, bits_per_sample: 16, sample_format: Int }
	 snips-audio-server[17639]: Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2043

Rate switching did no help :/.
But the device snips is playing audio to is not the device I set up in asound.conf. (hw:0,0 -> hw:0,1)
Where does Snips get this Info from? Obviously not fom alsa…

There is small typo at the very beginning of the asound.conf, so yes it cannot find your sound card.

use pcm.!default { ...

if you still stumble on portaudio error logs (e.g. paSomething), switch to the direct use of alsa by the audio-server. (it is the issue described here)

Thank you for the hint. :slight_smile:

when forcing output to alsa like you described, still getting errors in the sylog:

May 29 22:03:42 snips snips-audio-server[601]: ERROR:snips_audio_server_hermes  : could not play "8c49f42d-0976-4802-9f32-82320d248d94"
May 29 22:03:42 snips snips-audio-server[601]:  -> caused by: ALSA function 'snd_pcm_drain' failed with error 'EIO: I/O error'

@Psycho
rate 16000 in asound.conf leads to:

May 29 22:08:00 snips snips-audio-server[1736]: ERROR:snips_audio_server_hermes  : could not play "dd655856-10bc-4d9a-9712-1231fd1f9eed"
May 29 22:08:00 snips snips-audio-server[1736]:  -> caused by: ALSA function 'snd_pcm_open' failed with error 'EINVAL: Invalid argument'

How can I debug this further ?
Have I to wait for a bugfix for this issue?

Thank you guys for your time…

1 Like

Hello
i have the same problem and i resolve it by updated the snips-audio-server.service file in /etc/systemd/system/multi-user.target.wants by setting the environmental variable PA_ALSA_PLUGHW=1 under [service]
thanks to this post

2 Likes

Hello @LauDela and thank you.
Setting this EnvVariable unfortunately did not change anything.

Still get

 -> caused by: ALSA function 'snd_pcm_drain' failed with error 'EIO: I/O error'

I used the alsa-info script to get this (gist)[https://gist.github.com/shufflecode/15313bb171d6bbdffd9fb13b1fa0e032]

OK, seems that finally the following combination of settings is working: (showing only the relevant ones)
I drop them here, maybe they help others too.

/etc/snips.toml

...
[snips-audio-server]
# alsa_capture = "default"
# alsa_playback = "default"
...

/etc/asound.conf

pcm.jack {                  
        type hw             
        card 0              
        device 0            
        rate 16000          
}                           
pcm.!default {              
    type asym               
    playback.pcm {          
        type plug           
        slave.pcm "jack"    
    }                       
    capture.pcm {           
        type plug           
        slave.pcm "hw:1,0"  
    }                       
}                           

/etc/systemd/system/multi-user.target.wants/snips-audio-server.service

...
[Service]
Environment="PA_ALSA_PLUGHW=1" 
...

Thank you @LauDela, @Psycho @SakanaSan for the help ! :heart:

3 Likes

Thanks Micha, the configs worked for me. Very grateful thanks

It also worked for me. Thanks!

Going full pulse audio also worked for me:

pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}

pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

This is on a Raspberry Pi 4B

If you have the issue where by default it wants to play over HDMI and not your audio jack, try this:

amixer cset numid=3 1

i was facing the same issue and trying micha’s steps leaves me with the following errors

pi@snips:~ $ snips-audio-server
[00:19:21.939870] INFO :snips_audio_server_cli: Starting audio server on mqtt for site default
[00:19:21.995983] INFO :snips_audio_alsa::capture: Starting ALSA capture on device “default”
[00:19:22.040738] ERROR:snips_audio_server : ALSA function ‘snd_pcm_open’ failed with error ‘ENOENT: No such file or directory’

I’m not sure how to proceed with this particular error as any googling of the error doesn’t point me in the right direction. Would anyone have any advice please ?
As a result my snips voice only gets through part of a sentence if i’m lucky and then crashes