dimeiza / assistants Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Hello Dimeiza
For the respeker 2 mic hat, where in your code can i change the number of LEDs from 3 to 9 please?
I am using a Respeaker 2 mic hat and I have added a strip of 9 additional APA102 LEDs but only 3 of them light up (3 on the Respeaker board and 3 on my LED strip). I tested the LED strip it works for sure.
I tried to modify your code like this but i cant make all 9 LEDs to light up.
Please refer to the line bellow uint8_t led_rgb_data_2Mic[8][12] = {
/*
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
#include <string.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
static void pabort(const char *s)
{
perror(s);
abort();
}
static const char *device = "/dev/spidev0.1";
static uint8_t mode;
static uint8_t bits = 8;
static uint32_t speed = 800000;
static uint16_t delay;
struct LEDPatternRecord {
char *LEDPatternName;
int LEDPatternIndex;
};
struct MicHatRecord {
char *MicName;
int MicID;
};
static const struct MicHatRecord MicList[] = {
{ "2mic", 0 },
{ "4mic", 1 },
};
static const struct LEDPatternRecord LEDPatternList[] = {
{"LED_TURN_OFF",0,},
{"ALEXA_LISTENING",1},
{"ALEXA_THINKING",2},
{"ALEXA_SPEAKING",3},
{"GOOGLEASSISTANT_ON_CONVERSATION_TURN_STARTED",4},
{"GOOGLEASSISTANT_ON_RECOGNIZING_SPEECH_FINISHED",5},
{"GOOGLEASSISTANT_ON_RESPONDING_STARTED",6},
};
uint8_t led_rgb_data_4Mic[8][48] = {
// LED_TURN_OFF
{255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, },
// ALEXA_LISTENING
{255, 24, 0, 0,255, 24, 0, 0, 255, 24, 0, 0,255, 24, 0, 0,255, 24, 0, 0,255, 24, 0, 0,255, 24, 48, 0, 255, 24, 0, 0,255, 24, 0, 0, 255, 24, 0, 0, 255, 24, 0, 0, 255, 24, 0, 0},
// ALEXA_THINKING
{255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0},
// ALEXA_SPEAKING
{255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0},
// GOOGLEASSISTANT_ON_CONVERSATION_TURN_STARTED
{255, 48, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 48, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 24, 24, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 48, 0, 255, 0, 0, 0, 255, 0, 0, 0},
// GOOGLEASSISTANT_ON_RESPONDING_STARTED
{255, 48, 0, 0, 255, 48, 0, 0, 255, 0, 0, 0, 255, 0, 0, 48, 255, 0, 0, 48, 255, 0, 0, 0, 255, 0, 24, 24, 255, 0, 24, 24, 255, 0,0,0, 255, 0, 48, 0, 255, 0, 48, 0, 255, 0, 0, 0},
// GOOGLEASSISTANT_ON_RECOGNIZING_SPEECH_FINISHED
{255, 48, 0, 0, 255, 48, 0, 0, 255, 48, 0, 0, 255, 0, 0, 48, 255, 0, 0, 48, 255, 0, 0, 48, 255, 0, 24, 24, 255, 0, 24, 24, 255, 0, 24, 24, 255, 0, 48, 0, 255, 0, 48, 0, 255, 0, 48, 0},
};
**uint8_t led_rgb_data_2Mic[8][12] = {
// LED_TURN_OFF
{255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, },
//{255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, },
// ALEXA_LISTENING
{255, 24, 0, 0,255, 24, 0, 0, 255, 24, 0, 0,255, 24, 0, 0,255, 24, 0, 0,255, 24, 0, 0,255, 24, 48, 0, 255, 24, 0, 0,255, 24, 0, 0},
//{255, 48, 0, 0, 255, 255, 255, 255,255, 48, 0, 0,},
// ALEXA_THINKING
{255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0, 255, 24, 0, 0, 255, 12, 12, 0},
//{255, 48, 0, 0, 255, 24, 24, 0, 255, 48, 0, 0,} ,
// ALEXA_SPEAKING
{255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0},
//{255, 12, 12, 0, 255, 12, 12, 0, 255, 12, 12, 0, },**
// GOOGLEASSISTANT_ON_CONVERSATION_TURN_STARTED
{255, 0, 48, 0, 255, 0, 0, 0, 255, 0, 0, 0,},
// GOOGLEASSISTANT_ON_RECOGNIZING_SPEECH_FINISHED
{255, 0, 48, 0, 255, 48, 0, 0, 255, 0, 0, 0,},
// GOOGLEASSISTANT_ON_RESPONDING_STARTED
{255, 0, 48, 0, 255, 48, 0, 0,255, 0, 0, 48, },
};
uint8_t startFrame[] = { 0x00, 0x00, 0x00, 0x00 };
uint8_t endFrame[] = { 0x00,0x00 };
static int getMicID(char *MicName){
for(int i = 0;i < ARRAY_SIZE(MicList);i++){
if(!strcmp(MicList[i].MicName,MicName)){
return MicList[i].MicID;
}
}
return -1;
}
static int getLEDPatternIndex(char *LEDPatternName){
for(int i = 0;i < ARRAY_SIZE(LEDPatternList);i++){
if(!strcmp(LEDPatternList[i].LEDPatternName,LEDPatternName)){
return LEDPatternList[i].LEDPatternIndex;
}
}
return -1;
}
static int sendSPI(int fd,unsigned char *sendData,int length){
int ret;
uint8_t rx[256] = {0};
struct spi_ioc_transfer transferMessage = {
.tx_buf = (unsigned long)sendData,
.rx_buf = (unsigned long)rx,
.len = length,
.delay_usecs = delay,
.speed_hz = speed,
.bits_per_word = bits,
};
return ioctl(fd, SPI_IOC_MESSAGE(1), &transferMessage);
}
static void controlLED(int hatID ,int pattern){
uint8_t *LEDPattern = NULL;
int patternLength = 0;
int fd = open(device, O_RDWR);
if (fd < 0){
pabort("can't open device");
}
switch(hatID){
case 0:
LEDPattern = led_rgb_data_2Mic[pattern];
patternLength = ARRAY_SIZE(led_rgb_data_2Mic[pattern]);
break;
case 1:
LEDPattern = led_rgb_data_4Mic[pattern];
patternLength = ARRAY_SIZE(led_rgb_data_4Mic[pattern]);
break;
default:
pabort("This hat is not supported.");
break;
}
// If we want to use the APA102 RGB LEDs, please write HIGH to GPIO5 first to enable VCC of the LEDs.
system("gpio -g mode 5 out");
system("gpio -g write 5 1");
if(sendSPI(fd,startFrame,ARRAY_SIZE(startFrame)) < 1){
pabort("can't send start frame");
}
if(sendSPI(fd,LEDPattern,patternLength) < 1){
pabort("can't send LED Control Data");
}
if(sendSPI(fd,endFrame,ARRAY_SIZE(endFrame)) < 1){
pabort("can't send end frame");
}
close(fd);
}
static const struct option lopts[] = {
{ "device", 1, 0, 'D' },
{ NULL, 0, 0, 0 },
};
static void print_usage(const char *prog)
{
printf("Usage: %s [-D] pattern-name\n", prog);
puts("-D --device device to use (2mic or 4mic, default:2mic)");
puts("pattern-name LED pattern name ");
for(int i = 0;i < ARRAY_SIZE(LEDPatternList);i++){
puts(LEDPatternList[i].LEDPatternName);
}
exit(1);
}
int main(int argc, char *argv[])
{
int pattern = 0;
int hatID = 3;
int c;
char *target="2mic";
c = getopt_long(argc, argv, "D:",lopts, NULL);
switch (c) {
case 'D':
target = optarg;
break;
}
hatID = getMicID(target);
if(hatID == -1){
print_usage(argv[0]);
}
if(argv[optind] == NULL){
print_usage(argv[0]);
}
pattern = getLEDPatternIndex(argv[optind]);
if(pattern == -1){
print_usage(argv[0]);
}
controlLED(hatID,pattern);
return 0;
}
Hi! Please help.
RaspberriPI Zero: not work led. I am installing led library. I am used respeaker 6 mic
hi, you have do great work con the Assistant, i have try to install on my Raspberry B+, but not working, when i run google assistant
gives me a message:
pi@raspberrypi:~/Assistants $ ./startGoogleAssistant.sh
INFO:root:Connecting to embeddedassistant.googleapis.com
Traceback (most recent call last):
File "/home/pi/Assistants/env/bin/googlesamples-assistant-posixqueue", line 11, in <module> sys.exit(main())
File "/home/pi/Assistants/env/lib/python3.5/site-packages/click/core.py", line 722, in __call__ return self.main(*args, **kwargs)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/click/core.py", line 535, in invoke return callback(*args, **kwargs)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/posixqueue.py", line 351, in main isOutput=False
File "/home/pi/Assistants/env/lib/python3.5/site-packages/googlesamples/assistant/grpc/audio_helpers_for_queue.py", line 187, in __init__ blocksize=int(block_size/2), # blocksize is in number of frames.
File "/home/pi/Assistants/env/lib/python3.5/site-packages/sounddevice.py", line 1264, in __init__ **_remove_self(locals()))
File "/home/pi/Assistants/env/lib/python3.5/site-packages/sounddevice.py", line 681, in __init__ samplerate)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/sounddevice.py", line 2490, in _get_stream_parameters info = query_devices(device)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/sounddevice.py", line 488, in query_devices raise PortAudioError('Error querying device {0}'.format(device)) sounddevice.PortAudioError: Error querying device -1
instead when I start ./startAssistantControl.sh the error is
pi@raspberrypi:~/Assistants $ ./startAssistantControl.sh
Listening... Press Ctrl+C to exit
connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
Traceback (most recent call last):
File "AssistantControl.py", line 102, in <module>sleep_time=0.03)
File "/home/pi/Assistants/AssistantControl/snowboydecoder.py", line 176, in start stream_callback=audio_callback)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/pyaudio.py", line 750, in open stream = Stream(self, *args, **kwargs)
File "/home/pi/Assistants/env/lib/python3.5/site-packages/pyaudio.py", line 441, in __init__ self._stream = pa.open(**arguments)
OSError: [Errno -9996] Invalid input device (no default output device)
can you help me solve the problem?
PS
when i start alexa tells me # Alexa is currently idle! # but if tell but if I say the activation word doesn't respond, I don't know if it's normal? because I have to start also ./startAssistantControl.sh or not.
PLEASE HELP MEEEEEEEEEEE
Hi! Maybe use a new engine for your project?
https://github.com/Picovoice/Porcupine
It is more accurate and use much smaller cpu usage.
It will be great!
Hi i have alamost finished your build acording to your instructions and i am in the step before instaling it as a service. I am using pi zero w, respeaker 2mic hat and the latest stretch.
I start the 3 terminals, Alexa works fine with audio and LEDs, But GA i see only the LEDs when is say "Snowboy" but no audio.
Mind you when i run the GA terminal i do get and "iligal instruction" error but i think this is becuse of the SDK detecting the Pi zero ARM processor.
Any ideas why i get no audio on GA?
ERROR: Failed building wheel for pyaudio
Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio, spidev, colorzero, gpiozero, numpy, RPi.GPIO
Running setup.py install for pyaudio ... error
ERROR: Command errored out with exit status 1:
command: /home/pi/Assistants/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-984rasg8/pyaudio/setup.py'"'"'; file='"'"'/tmp/pip-install-984rasg8/pyaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-_sowol3l/install-record.txt --single-version-externally-managed --compile --install-headers /home/pi/Assistants/env/include/site/python3.7/pyaudio
cwd: /tmp/pip-install-984rasg8/pyaudio/
Complete output (16 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-armv7l-3.7
copying src/pyaudio.py -> build/lib.linux-armv7l-3.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-armv7l-3.7
creating build/temp.linux-armv7l-3.7/src
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/pi/Assistants/env/include -I/usr/include/python3.7m -c src/_portaudiomodule.c -o build/temp.linux-armv7l-3.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^~~~~~~~~~~~~
compilation terminated.
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/pi/Assistants/env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-984rasg8/pyaudio/setup.py'"'"'; file='"'"'/tmp/pip-install-984rasg8/pyaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-_sowol3l/install-record.txt --single-version-externally-managed --compile --install-headers /home/pi/Assistants/env/include/site/python3.7/pyaudio Check the logs for full command output.
make: Nothing to be done for 'all'.
cp: cannot stat 'snowboy/examples/Python3/snowboy-1.2.0b1-py2-none-any.whl': No such file or directory
mkdir: cannot create directory 'resources': File exists
fatal: destination path 'mic_hat' already exists and is not an empty directory.
fatal: destination path 'mic_hat_4' already exists and is not an empty directory.
mv: cannot stat 'alexa_led_pattern.py': No such file or directory
mv: cannot stat 'google_home_led_pattern.py': No such file or directory
I don't know how to fix them.
please help to me.
Thank you.
==============> SAVING CONFIGURATION FILE ==============
[ERROR] Missing parameters!
Usage: genConfig.sh <config.json file> <device_serial_number>
[-D=]+
startAssistantControl.sh failed to start
(instaled on RPI B+ fresh raspbian 2018-11-13 )
Listening... Press Ctrl+C to exit
Traceback (most recent call last):
File "AssistantControl.py", line 96, in
alexa_mq = posix_ipc.MessageQueue("/AlexaQueue", posix_ipc.O_CREAT)
posix_ipc.PermissionsError: Permission denied
Alexa and Google are working ....
and thank you for your work
Where have you defined http://127.0.0.1:3000 ?
Need to be ale to change it to my local subnet IP as I am doing this via SSH and the Pi is on IP 192.168.1.2 and that is the IP i defined in the AVS development web side at port 3000.
Your kind support please.
Thanks
Hello this is grate work, how do instal this build in my pi please?
What commands and what scripts do I need to execute first ?
Can I use Raspbian Jessie lite?
Can I install this on a pi zero w and also have the respeaker leds change colours in both assistants ?
Will both GA and AVS start automatically at boot and if not how can I do that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.