Using a different api to communicate with amazon lex


#1

as posted here: https://stackoverflow.com/questions/54854052/using-a-different-api-to-record-on-a-amazon-lex-bot-nodejs

if someone could help me out that’d be great the project is due soon and i’m stumped


#2

Hi @Mashiro,

I’m a little unclear on exactly what you’re asking.

ALSA lib pcm_file.c:763:(snd_pcm_file_open) file format “raw” is unknown
sox FAIL formats: can't open input  `default': snd_pcm_open error: Invalid 
argument

^Is this the error you get when you run lex.js?

What happens when you run this command in your Raspberry Pi’s terminal?

sox -d -t wavpcm -c 1 -b 16 -r 16000 -e signed-integer --endian little - silence 1 0 1% 5 0.3t 2% > request.wav


#3

When I run the following on my Raspberry Pi with the MATRIX Voice in the terminal,

sox -d -t wavpcm -c 1 -b 16 -r 16000 -e signed-integer --endian little - silence 1 0 1% 5 0.3t 2% > request.wav

request.wav gets recorded through the MATRIX Voice mics and I can play it back using aplay.

For this to work, you have to download the MATRIX kernel modules as shown here and then download the sox alsa-utils package using the following command.

sudo apt-get install sox alsa-utils

Maybe this will help your lex.js file to run with sox.

Also, this is my /etc/asound.conf file

pcm.!default {
type asym
capture.pcm “mic”
playback.pcm “speaker”
}

pcm.mic {
type softvol
slave {
pcm “array”
}
control {
name “MicArray Master”
card 0
}
}

pcm.speaker {
type plug
slave {
pcm “hw:0,0”
}
}

pcm.array {
type plug
slave {
pcm “hw:2,0”
}
}


#4

Yes, that’s the error it throws when I run lex.js or the sox command

I tried asound.conf you posted and now i get this error

ALSA lib conf.c:1852:(snd_config_load1) _toplevel_:18:1:Unexpected char
ALSA lib conf.c:3615:(config_file_open) /etc/asound.conf may be old or corrupted: consider to 
remove or fix it
ALSA lib conf.c:3537:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid 
argument

EDIT: I am also up to date on all the packages needed including alsa-utils, sox and the matrix kernel modules and still the same error occurs


#5

@Mashiro,

Did you backup and delete the previous .asoundrc file you had? If not, try that and see if it works.

Best,
Samreen


#6

I did that, unfortunately no dice. seems to throw the same error:

pi@raspberrypi:~ $ arecord temp.wav
ALSA lib conf.c:1852:(snd_config_load1) _toplevel_:18:1:Unexpected char
ALSA lib conf.c:3615:(config_file_open) /etc/asound.conf may be old or corrupted: consider to 
remove or fix it
ALSA lib conf.c:3537:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid 
argument
ALSA lib conf.c:3986:(snd_config_update_r) hooks failed, removing configuration
arecord: main:788: audio open error: Invalid argument
pi@raspberrypi:~ $ aplay temp.wav
ALSA lib conf.c:1852:(snd_config_load1) _toplevel_:18:1:Unexpected char
ALSA lib conf.c:3615:(config_file_open) /etc/asound.conf may be old or corrupted: consider to 
remove or fix it
ALSA lib conf.c:3537:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid 
argument
ALSA lib conf.c:3986:(snd_config_update_r) hooks failed, removing configuration
aplay: main:788: audio open error: Invalid argument

as you can see it happens on arecord and aplay. I’m using stretch if that helps


#7

@Mashiro,

I would recommend trying on a fresh install of Raspbian Stretch with the MATRIX kernel modules installed. You shouldn’t need to touch the asound.conf and .asoundrc files in that case since the kernel module installation should take care of that.

For me, it worked instantly on a fresh install so if you could back this up or try with another SD card, that might work for you. It’s possible that other changes you made on this install have changed other ALSA files and is causing these errors.


#8

alright, I’ll give it a shot. I’ll post an update if necessary

EDIT: the mic works after a fresh install and reinstall of the matrix core. Thanks! although the lex bot doesn’t respond properly (i think it may be an AWS issue) it still receives input which is what I needed