Sam quits with "Unexpected token"

#1

I installed sam on my Lubuntu 16.04 machine. However, it won’t do anything except quit with

/usr/local/lib/node_modules/snips-sam/bin/sam:3
const {run} = require(’…/lib/sam’)
^

SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions…js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

Can anyone help?

#2

Your node.js version seems to be outdated. If so, could you update it and try again?

#3

Thank you, but updating node.js on the Lubuntu 16.04 (32-bit) machine didn’t help, as the version stayed at v4.2.6. However, I then switched to a Lubuntu 18.04 (64-bit) machine with version v8.10.0 and was able to run sam init, which resulted in “Successfully installed the Snips Platform” on a Raspberry Pi with Raspbian GNU/Linux 8 (jessie).

But when I run “sam status”, the answer I get is “Snips Platform not installed”. In red, even.

What next?

#4

You can run sam init -v to show apt-get logs. There might be an issue during the installation.

#5

OK; this is what sam init --verbose prints out:
__________________________________________________________________-
Updating aptitude repository
E: The method driver /usr/lib/apt/methods/https could not be found.
Installing dirmngr
Reading package lists…
Building dep_endency tree…
Reading state information…
dirmngr is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Adding Snips APT source list
Adding Snips PGP public key
Updating aptitude repository
E: The method driver /usr/lib/apt/methods/https could not be found.
Installing Snips Platform, this could take a while, grab a cup of tea & relax
Reading package lists…
Building dependency tree…
Reading state information…
E: Unable to locate package snips-platform-voice
E: Unable to locate package snips-watch
E: Unable to locate package snips-template
E: Unable to locate package snips-skill-server
Adding current user to snips-skills-admin group for security
Disabling Mosquitto persistence
:heavy_check_mark: Successfully installed the Snips Platform
i You can now setup your audio with sam setup audio


So, it’s “Successfully installed”. But sam status still says


Connected to device raspberrypi.local

OS version … Raspbian GNU/Linux 8 (jessie)
Status … Snips Platform not installed

You may install the Snips Platform using sam init


So, not installed. What am I doing wrong?

#6

On ubuntu the GPG key is not the same as Pi. Sam doesn’t support installing the platform on Ubuntu for now.

You’ll need to install it manually with these commands :

sudo apt-get update
sudo apt-get install -y dirmngr
sudo apt-get install -y apt-transport-https
sudo bash -c ‘echo “deb https://debian.snips.ai/stretch stable main” > /etc/apt/sources.list.d/snips.list’
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F727C778CCB0A455
sudo apt-get update
sudo apt-get install -y mosquitto mosquitto-clients alsa-utils
sudo apt-get install -y snips-platform-voice
sudo apt-get install -y snips-audio-server snips-asr snips-nlu snips-hotword snips-dialogue snips-tts
sudo apt-get install -y snips- watch
sudo apt-get install -y snips-template snips-skill-server

Then you’ll be able to run the rest of the commands via Sam.

#7

Thank you, but I’m getting very confused. You say “Sam doesn’t support installing the platform on Ubuntu for now.” But I thought the platform was supposed to be installed on the Raspberry Pi, not on the Ubuntu machine. So - do I run the apt-gets on the Ubuntu machine or the Raspberry Pi? Is nothing installed on the Pi?

#8

Ok my bad I thought you were installing the platform on Ubuntu. Then you don’t need to run the commands I sent you.
From the logs it seems that the HTTPS package didn’t install successfully.
Try running on the Pi :
sudo apt-get install apt-transport-https

#9

Thank you; the Snips package now seems have been installed. However, a microphone is needed, and while I have one, the Pi does not have an audio input jack. So I bought a USB “sound card” to solve that problem. Well, I have already bought two of these. Neither works reliably, and the few WAV files I have been able to record are extremely low-quality. I would say they are so bad as to be unusable. (I compare the recordings to ones made with a smartphone and a tablet, and the difference is, well, huge.)

I got started on this project because of a magazine article that estimated the cost as 45€. No problem, I can afford that, but now, I have already spent about 35€ on the two USB sound cards – that do not work. What kind of expensive, high-end equipment do I really need for the Snips project?

#10

However, a microphone is needed, and while I have one, the Pi does not have an audio input jack.

We provide a list of recommended microphones on this page: https://docs.snips.ai/articles/raspberrypi/hardware/microphones

What kind of expensive, high-end equipment do I really need for the Snips project?

The respeaker 2 pi-hat costs $9.90 and works pretty well:

And it is also compatible with SAM that can install the drivers and configure it out of the box.

#11

Thank you; I just ordered one. Expected delivery is May 31 – June 3.