snipsco / snips-issues

Feel free to share your bugs with us.
14 stars 5 forks source link

[Platform][Audio-Server][PortAudio] Cannot play sound sampled at 22050Hz when playback is set at 16000Hz #148

Closed Psychokiller1888 closed 4 years ago

Psychokiller1888 commented 5 years ago

What's the issue? Always worked with my usb mic, can't get the audio server running on latest version

Use Cases Impacted No start

How to reproduce Use a USB dongle mic

Expected behavior Well, the audio server to start at least

Logs

ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 923
Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 923
[11:59:21.385278] DEBUG:snips_audio_portaudio : Portaudio: Ok("PortAudio V19-devel (built May  9 2019 13:17:19)")
[11:59:21.385367] DEBUG:snips_audio_portaudio : Looking for default input device
[11:59:21.385555] INFO :snips_audio_portaudio : Use input device: "USB PnP Sound Device: Audio (hw:1,0)"
[11:59:21.385671] DEBUG:snips_audio_portaudio : Start capture: InputSettings { params: Parameters { device: Index(DeviceIndex(1)), channel_count: 1, suggested_latency: 0.008684807256235827, is_interleaved: true, sample_format: PhantomData }, sample_rate: 16000.0, frames_per_buffer: 256, flags:  }
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2043
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->capture, inParams, self->primeBuffers, hwParamsCapture, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2714
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2838
[11:59:21.387713] DEBUG:snips_audio_portaudio : Mike source capture ended
[11:59:21.407851] DEBUG:snips_audio_portaudio : Attempt 1
[11:59:21.408018] ERROR:snips_audio_server    : InvalidSampleRate

[11:59:21.408024] ERROR:rumqtt::client        : snips-audio-server|915-raspberrypi-1 Disconnected: (Error(SyncMpsc(Disconnected), State { next_error: None, backtrace: None }))
[11:59:21.408064] DEBUG:rumqtt::client        : snips-audio-server|915-raspberrypi-1: Entering reconnecting loop
[11:59:21.408132] INFO :rumqtt::client        : not seeking reconnection
[11:59:21.408155] INFO :rumqtt::client        : client thread done
[11:59:21.408180] ERROR:snips_common_cli::cli : Unable to reconnect to the mqtt broker, ending the program.
pi@raspberrypi:~ $

[Edit cpoisson]

ROOT CAUSE(s)

Workaround This one solve seem to solve most of the issues.

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

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

Workaround 2

this configuration seems to work in most cases:

# The IPC key of dmix or dsnoop plugin must be unique
# If 555555 or 666666 is used by other processes, use another one

# use samplerate to resample as speexdsp resample is bad
defaults.pcm.rate_converter "samplerate"

pcm.!default {
    type asym
    playback.pcm "playback"
    capture.pcm "capture"
}

pcm.playback {
    type plug
    slave.pcm "dmixed"
}

pcm.capture {
    type plug
    slave.pcm "array"
}

pcm.dmixed {
    type dmix
    slave {
        pcm "hw:seeed2micvoicec"
        period_time 0
        period_size 1024
        buffer_size 4096
        # rate 48000, commented, it should be the default output rate for most audio cards
    }
    ipc_key 555555
    ipc_perm 0666 # allow all users to use the dmix interface
}

pcm.array {
    type dsnoop
    slave {
        pcm "hw:seeed2micvoicec"
        channels 2
        rate 16000 # drastically reduce the audio-server cpu consumption by avoiding resampling
        # Warning, for piHAT 2, the playback interface will be also forced to 16000 Hz, you must use alsa_playback="default" option or comment this rate configuration.
    }
    ipc_key 666666
    ipc_perm 0666 # allow all users to use the dsnoop interface
}
Psychokiller1888 commented 5 years ago

Ok, for some reason I need to specify the "speaker" sample rate to 16000 in asound.conf now for the audio server to work

cpoisson commented 5 years ago

Thanks for the tip,

We are looking also on our side, here is the result:

Kernel 4.14 - Works fine by only updating the hw address of the usb microphone (like before)

Kernel 4.19 - Does not work when doing the same. We obtain the same results as yours.

After two reboots, the problem was fixed. 🤔

cpoisson commented 5 years ago

I have upgraded my Pi, I confirm that the problem disappear after two reboot. (Without having to set an explicit sample rate)

But now I have lost the piHAT, seems that I need to update its driver.

Psychokiller1888 commented 5 years ago

Hmmm, I did reboot maybe 150 times since this morning? Maybe 120 until I posted the bug report ;) I'm creating ProjectAlice installer, rebooting all the time....

cpoisson commented 5 years ago

Urm... same thing for the piHAT, after a hard reboot the board is back.

Psychokiller1888 commented 5 years ago

Well, I'm gonna wipe the sd an an hour or so, i'll report back ;)

paulvt commented 5 years ago

I have a similar problem, but then with snips-satellite on the Raspberry Pi 3 since upgrading it (including the Snips platform) and switching to using snips-satellite:

May 22 21:05:56 voice snips-satellite[1659]: INFO:snips_audio_portaudio       : Playing "160b3816-c277-4d89-a7d9-a4dc777ee2ce" using output "bcm2835 ALSA: IEC958/HDMI (hw:0,1)", wav spec: WavSpec { channels: 2, sample_rate: 22050, bits_per_sample: 16, sample_format: Int }
May 22 21:05:56 voice snips-satellite[1659]: Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2043
May 22 21:05:56 voice snips-satellite[1659]: Expression 'PaAlsaStreamComponent_InitialConfigure( &self->playback, outParams, self->primeBuffers, hwParamsPlayback, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2717
May 22 21:05:56 voice snips-satellite[1659]: Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2838
May 22 21:05:56 voice snips-satellite[1659]: thread 'portaudio.player' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"ERROR:snips_audio_server_hermes   : could not play "160b3816-c277-4d89-a7d9-a4dc777ee2ce"
May 22 21:05:56 voice snips-satellite[1659]:  -> caused by: InvalidSampleRate
May 22 21:05:56 voice snips-satellite[1659]: ', src/libcore/result.rs:997:5

Note that using ALSA's speaker-test seems to have no issues doing playback using the set channels/sample rate/bits per sample as logged above:

$ speaker-test -Dhw:0,1 -c 1 -f 4000 -r 22050

speaker-test 1.1.3

Playback device is hw:0,1
Stream parameters are 22050Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 22050Hz (requested 22050Hz)
Buffer size range from 512 to 65536
Period size range from 512 to 65536
Using max buffer size 65536
Periods = 4
was set period_size = 16384
was set buffer_size = 65536
 0 - Front Left
Time per period = 0.011003
 0 - Front Left
[...]
dnknth commented 5 years ago

Same here on RPi3, reboot (as suggested by cpoisson) does not make any difference. Also, we seem to have two issues here:

Psychokiller1888 commented 5 years ago

@cpoisson Ok, I have reinstalled my pi about 20 times since yesterday and what I can say is that, on a freshly flashed sd I install Snips and the asound.conf contains the sample rate, everything goes fine. Yes, before installing Snips I force a dist-upgrade, so I'm using the latest headers

Psychokiller1888 commented 5 years ago

@dnknth I have to configure the speaker sample rate

cpoisson commented 5 years ago

All those issues seem linked to audio configuration issues and somehow portaudio

@paulvt

There is two things that cause issues:

Nominal configuration

On my side, everything seems ok using the basic configuration.

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

everything means:

Advanced Configuration

but...

Things got a bit weird when I tried a more advanced configuration, then I could not play 2 channels wav files.

The audio-server does not crash but produces an error related to the configuration of the sound card I try to use. (like @paulvt)

[15:03:46.826433] INFO :snips_audio_portaudio      : Playing "dd6b17ed-61b9-435c-b989-bbb027d740a1" using output "default", wav spec: WavSpec { channels: 2, sample_rate: 22050, bits_per_sample: 16, sample_format: Int }
[15:03:46.834631] DEBUG:snips_audio_portaudio      : Padding output with 87 frames
Expression 'alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, NULL )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3196
Expression 'paUnanticipatedHostError' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->playback, outParams, self->primeBuffers, hwParamsPlayback, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2717
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2838
[15:03:46.841516] ERROR:snips_audio_server_hermes  : could not play "dd6b17ed-61b9-435c-b989-bbb027d740a1"
 -> caused by: UnanticipatedHostError

One channel wave file are still played correctly.

[15:07:14.628654] INFO :snips_audio_portaudio      : Playing "8ewnjksdf093jb42" using output "default", wav spec: WavSpec { channels: 1, sample_rate: 44100, bits_per_sample: 16, sample_format: Int }
[15:07:14.681155] DEBUG:snips_audio_portaudio      : Padding output with 173 frames
[15:07:18.907815] INFO :snips_audio_portaudio      : Playing of "8ewnjksdf093jb42" finished

The error comes from PortAudio (An open source library we use to play and record sound to abstract the platform used)

Workaround

It is possible to use alsa directly and bypass this middle man using the following options of snips-audio-server

        --alsa_capture <ALSA_CAPTURE>      Use the specified ALSA device instead of the default as a source
        --alsa_playback <ALSA_PLAYBACK>    Use the specified ALSA device instead of the default as a playback

In this case, things get back to normal

using sudo -u _snips snips-audio-server -v --alsa_playback default (using snips.toml, just add alsa_playback = "default" in the snips-audio-server section.

[15:08:58.887233] INFO :snips_broadcast_mqtt_server: Starting broadcasting audio on hermes as site "default"
[15:09:01.689453] INFO :snips_audio_alsa::playback : Using ALSA output Some("playback") ("USB Audio") for "efc6b6f6-da07-40f1-ac81-f94f4d46a6e9", WavSpec { channels: 2, sample_rate: 22050, bits_per_sample: 16, sample_format: Int }
[15:09:02.186136] INFO :snips_audio_alsa::playback : Playback for efc6b6f6-da07-40f1-ac81-f94f4d46a6e9 finished
[15:09:07.002661] INFO :snips_audio_alsa::playback : Using ALSA output Some("playback") ("USB Audio") for "51566ca0-efb4-4390-bbb7-667440a74302", WavSpec { channels: 2, sample_rate: 22050, bits_per_sample: 16, sample_format: Int }
[15:09:08.128028] INFO :snips_audio_alsa::playback : Playback for 51566ca0-efb4-4390-bbb7-667440a74302 finished
[15:09:08.165773] INFO :snips_audio_alsa::playback : Using ALSA output Some("playback") ("USB Audio") for "18c7a675-dddd-4338-a34e-f7f9d6759a8b", WavSpec { channels: 2, sample_rate: 44100, bits_per_sample: 16, sample_format: Int }
[15:09:08.541095] INFO :snips_audio_alsa::playback : Playback for 18c7a675-dddd-4338-a34e-f7f9d6759a8b finished

I'll investigate a bit more on alsa configuration and why portaudio chokes on it in some cases.

HakanL commented 5 years ago

I have the same issue with a brand new install on RPi 3B+ and Respeaker 4-mic hat. I'm using the 3.5mm audio jack on the RPi for playback. Snips can record fine, it detects the wake word, but it fails to playback the ACK sound with an error of paInvalidSampleRate in the log file. The built-in RPi audio output seems to be limited to 44.1kHz, and I can confirm that with the above speaker-test commands as well. But if I use "plughw:0,1" instead of "hw:0,1" in speaker-test then it works fine. However asound.conf already has "type plug", so my guess is that PortAudio is using the "hw" identifier directly instead of going via the "plug" (I don't know ALSA that well to confirm this theory). If I plug in a USB soundcard then it all works fine, but I want it to all to be integrated, and since we have the "plug" in ALSA I don't see any reason for it to not work.

HakanL commented 5 years ago

I was able to figure out a workaround. I updated the snips-audio-server.service file in /etc/systemd/system/multi-user.target.wants to set the environmental variable PA_ALSA_PLUGHW=1 and now it works!

[Service]
Environment="PA_ALSA_PLUGHW=1"
...
cpoisson commented 5 years ago

@HakanL interesting, thanks for the tip

pointing to the source

cpoisson commented 5 years ago

Another thing I found out is that the output produce the error only when declared as a dmix plugin, plug seems to work well.

cpoisson commented 5 years ago

Ok, It is getting clearer (not the root cause tough)

e.g.

pcm.playback_pihat {
    type plug
    slave.pcm {
        type dmix
        ipc_key 555555
        slave {
            pcm "hw:1,0"
            period_time 0
            period_size 1024
            buffer_size 4096
            #format S16_LE
            #rate 16000
            #channels 2
         }
    }
}

Here's a link to more documentation about alsa ring buffer.

And more info about alsa plugin documentation

cpoisson commented 5 years ago

Anyway, I'm closing this one as it's more related to alsa configuration.

cpoisson commented 5 years ago

Same issue using pyaudio (based on portaudio)

Here is the output when playing a two channels, 16bits wave file at 22050Hz on a respeaker piHAT2

Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 924
Expression 'alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, &dir )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 924
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:583:(snd_pcm_dsnoop_open) unable to create IPC semaphore
ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
ALSA lib pcm_dmix.c:990:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
ALSA lib pcm_dsnoop.c:583:(snd_pcm_dsnoop_open) unable to create IPC semaphore
ALSA lib pcm_dsnoop.c:556:(snd_pcm_dsnoop_open) The dsnoop plugin supports only capture stream
ALSA lib pcm_dsnoop.c:583:(snd_pcm_dsnoop_open) unable to create IPC semaphore
Expression 'alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, NULL )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3201
Expression 'paUnanticipatedHostError' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2053
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->playback, outParams, self->primeBuffers, hwParamsPlayback, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2722
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
  File "test.py", line 20, in <module>
    output=True)
  File "/home/pi/venv-pyaudio/local/lib/python2.7/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/home/pi/venv-pyaudio/local/lib/python2.7/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno -9999] Unanticipated host error

Those issue are also driver dependant.

We will patch snips-audio-server to use alsa directly to avoid those issues for makers.

Psychokiller1888 commented 5 years ago

I'm still unable to dsnoop my mic. Any idea how to get around this?

cpoisson commented 5 years ago

@Psychokiller1888

Did you try to configure the snips audio server to use alsa_capture directly?

Psychokiller1888 commented 5 years ago

@cpoisson Yeah tried and tried agin with everything... Can't get to share my mic when snips is running

Do you have a working dsnoop config for snips?

cpoisson commented 5 years ago

Porting here the alsa configuration provided in #165

# The IPC key of dmix or dsnoop plugin must be unique
# If 555555 or 666666 is used by other processes, use another one

pcm.!default {
    type asym
    playback.pcm "playback"
    capture.pcm "capture"
}

pcm.playback {
    type plug
    slave.pcm "dmixed"
}

pcm.capture {
    type plug
    slave.pcm "array"
}

pcm.dmixed {
    type dmix
    slave {
        pcm "hw:seeed2micvoicec"
        period_time 0
        period_size 1024
        buffer_size 4096
    }
    ipc_key 555555
    ipc_perm 0666
}

pcm.array {
    type dsnoop
    slave {
        pcm "hw:seeed2micvoicec"
        channels 2
        rate 16000 # drastically reduce the audio-server cpu consumption by avoiding resampling.
    }
    ipc_key 666666
    ipc_perm 0666
}
farfade commented 5 years ago

My two cents, even if I don't understand them... I think it could get brighter people on the way to solve the real problem :

I performed an update from stretch to buster, then I tried to update my fully functional snips installation from 0.63.2 to 0.63.3. I'm using pulseaudio.

Snips-audio-server failed to start with the "InvalidSampleRate" error. I added the

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

and the "InvalidSampleRate" error let place to a clearer error :

PulseAudio: Unable to connect: Access denied

I added the snips user ("_snips") to the pulse-access group, removed it from the "audio" group, and removed

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

and it's allright now.

As far as I understand, before buster, there was no control of "pulse-access" membership but "audio" was sufficient; and things changed with buster.

cpoisson commented 5 years ago

@farfade

Thanks for the tip, It is more pulse audio related but yes you need to set correctly the rights to do so.

cpoisson commented 5 years ago

For the records,

Crawling on the the raspberry pi forum, it seems that since that last May kernel update, many users got also audio related troubles.

https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=240819

cpoisson commented 4 years ago

1.3.0 is release with a mitigation change for this issue. doc

farfade commented 4 years ago

Hello @cpoisson

(edit) Maybe I solved my problem using pulseaudio. I don't understand why, but my Debian distro has this file :

/etc/pulse/client.conf.d/00-disable-autospawn.conf

containing a directive disabling pulse autospawn.

Commenting this directive enabled the pulse autospawn when running the snips-audio-server at boot time. For an unknown reason, restarting the snips-audio-server manually after boot time did not take into account the autospawn disable directive, making thinks work as expected.

--

My initial problem and investigations :

It worked for me with pulseaudio before, and now it does not work anymore with 1.3.0 I understand you changed the default back to ALSA. How can I force in my configuration file to use Pulseaudio exactly like it was before ?

More precisely, I tried to add : portaudio_capure="default" portaudio_playback="default"

but it does not work at boot.

More precisely, it does not work at boot even if snips-audio-server does not report nothing in particular :

systemd[1]: Started Snips Audio Server. INFO:snips_audio_server_cli: Starting audio server on mqtt for site corridor INFO:snips_audio_alsa::capture: Starting ALSA capture on device "default" INFO:snips_audio_server_hermes::player: started hermes audio player thread INFO:snips_broadcast_mqtt_server : Starting broadcasting audio on hermes for site "corridor"

but it works when I manually restart snips-audio-server (systemctl restart snips-audio-server) after the initial boot launch (and snips-audio-server reports exactly the same logs)

Adding in snips-audio-server.service

Requires sound.target After sound.target

does not solve the problem.

Trying to delay snips-audio-server start (with ExecStartPre=/bin/sleep 10) makes snips-audio-server fail to start because of :

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

Curious...

Regards

Romain

cpoisson commented 4 years ago

I'm no expert on pulse but it seems that the user under which the process is run notice has to be authorized to use pulse audio. (look above)

Do you have the same behavior using ?

sudo -u _snips snips-audio-server 

Regarding the usage of the configuration options to use portaudio or alsa backend:

Using the command line it looks like:

sudo -u _snips snips-audio-server --portaudio_playback="default" --portaudio_capture="default"

Using '/etc/snips.toml' configuration file it looks like:

...

[snips-audio-server]
portaudio_playback = "default"
portaudio_capture = "default"

...
farfade commented 4 years ago

@cpoisson : Yes, all the behaviour I described where observed under the _snips user.

I'm not an expert either... I read PulseAudio - Should users be in the "audio" group? and learnt that Debian belongs to group 1 distros, so there is the need to put the _snips user in the audio group.

As of today, everything is alright (including at bootime) with

portaudio_capure="default"
portaudio_playback="default"
pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}

pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}
# autospawn=no

Hope it helps a little...

Romain