Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up Alice for first time, getting invalid sample error [help wanted] #343

Open
Ricardo-Osorio opened this issue Nov 10, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Ricardo-Osorio
Copy link

Hi, I am currently trying to install and get Alice up and running on my Raspberry pi but sadly I am facing some issues that I can't seem to fix myself or find a workaround online that fixes this for me.

At the moment I can't hear and can't seem to trigger the wake-up word.

I understand from my little research this most likely is an issue with my raspberry pi/devices but still I have run out of options to try and failed to try to fix it myself. Any help would be much appreciated.
If you need the output from a command please ask!

I am running an up to date version of buster on my RaspberryPi with no packages needing to be updated.
I have a USB microphone that seems to record my voice fine and Headphones plugged in through the 3.5mm jack (I don't have another way of playing back sounds at the moment).
I have tested both by recording a quick sample with arecord --rate=48000 -t raw and playing it back with aplay --rate=48000. I can hear my voice just fine through the headphones (with just a little bit of noise).

When I start up Alice these are the logs I get

(...)

[DeviceManager]           Loaded 1 device
[AudioManager]            Starting
[AudioManager]            Using USB PnP Sound Device for audio input
[AudioManager]            Using dmix for audio output
[AudioManager]            Starting audio publisher
Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->capture, inParams, self->primeBuffers, hwParamsCapture, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
[ThreadManager]           Started new thread audioPublisher, thread count: 2
[InternetManager]         Starting
Exception in thread audioPublisher:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/ProjectAlice/core/server/AudioServer.py", line 126, in publishAudio
    blocksize=self.FRAMES_PER_BUFFER,
  File "/home/pi/ProjectAlice/venv/lib/python3.7/site-packages/sounddevice.py", line 1187, in __init__
    **_remove_self(locals()))
  File "/home/pi/ProjectAlice/venv/lib/python3.7/site-packages/sounddevice.py", line 895, in __init__
    'Error opening {}'.format(self.__class__.__name__))
  File "/home/pi/ProjectAlice/venv/lib/python3.7/site-packages/sounddevice.py", line 2738, in _check
    raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening RawInputStream: Invalid sample rate [PaErrorCode -9997]

[ThreadManager]           Started new thread internetCheckThread, thread count: 2
[DatabaseManager]         Starting

(...)

[DialogTemplateManager]   Checking data for skill Telemetry
[DialogTemplateManager]   Cache uptodate
Expression 'paInvalidSampleRate' 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: 2722
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
[AudioManager]            Playing wav failed with error: Error opening RawOutputStream: Invalid sample rate [PaErrorCode -9997]
[ThreadManager]           Started new thread checkHeartbeats, thread count: 10
[ThreadManager]           Started new thread heartBeatThread-1605017487, thread count: 10
[RedQueen]                Scheduled next random speaking in 1313 seconds
[SnipsNlu]                Starting Snips NLU
[Project Alice]           Started in 14.26 seconds

From this I noticed at the beginning it only loads 1 device even though I manually specified both "inputDevice" and "outputDevice" in config.json as follows

(...)

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

(...)

"inputDevice": "USB PnP Sound Device",
"outputDevice": "bcm2835 Headphones",

(...)

FYI here are the contents of both my
~/.asoundrc

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

and /usr/share/alsa/alsa.conf where I edited these two lines from 0 to 1 in an attempt to make the Headphones the default device and as such try to see if Alice would pick it up and use it... no luck.

(...)

defaults.ctl.card 1
defaults.pcm.card 1

(...)

Output of both
arecord -l

**** List of CAPTURE Hardware Devices ****
card 2: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

and aplay -l
**** List of PLAYBACK Hardware Devices ****

card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3

The webUI is working and it's accessible from my laptop so from there I have tried the "ALICEWATCH" from which I only see this no matter what I say or try to do:

In the Audio setting on the Admin section the only options I have available are the ones Alice seems to pick up, which is the USB microphone and the dmix (failed to detect headphones?)

I am using snip for the wakeup engine and as such am trying to wake her up with "Hey snips"

In alsamixer both the Headphones and Microphone are set to their loudest record and play sounds.

I know only the very basics of python myself but still tried to look at what could be obvious here for my specific issue and in I tried to update the code at core/server/AudioServer.py and change the SAMPLERATE value to 48000 but to no avail (I am not too sure of this change myself if that's not clear 😆 )

And also tried to check what was coming from the call at ln59, here's the output

>>> sd.query_devices(kind='output')
{'default_high_output_latency': 0.021333333333333333, 'default_low_output_latency': 0.021333333333333333, 'default_samplerate': 48000.0, 'nam
e': u'dmix', 'max_output_channels': 2, 'default_low_input_latency': -1.0, 'max_input_channels': 0, 'default_high_input_latency': -1.0, 'hosta
pi': 0}
>>> sd.query_devices(kind='input')
{'default_high_output_latency': -1.0, 'default_low_output_latency': -1.0, 'default_samplerate': 44100.0, 'name': u'USB PnP Sound Device: Audi
o (hw:2,0)', 'max_output_channels': 0, 'default_low_input_latency': 0.008684807256235827, 'max_input_channels': 1, 'default_high_input_latenc
y': 0.034829931972789115, 'hostapi': 0}
@mjlill
Copy link

mjlill commented Nov 10, 2020

Check in on discord so someone may be able to help you. Your settings look incorrect.

@Ricardo-Osorio
Copy link
Author

I will do just that 👍 Thank you

@Psychokiller1888 Psychokiller1888 self-assigned this Nov 11, 2020
@Psychokiller1888 Psychokiller1888 added the bug Something isn't working label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants