Giter VIP home page Giter VIP logo

assistants's Issues

Question: ReSpeakerLED.c file modification for more LESs

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] = {

/*

  • RespeakerLED.c
  • Copyright 2018 dimeiza. All Rights Reserved.
  • Licensed to the Apache Software Foundation (ASF) under one
  • or more contributor license agreements. See the NOTICE file
  • distributed with this work for additional information
  • regarding copyright ownership. The ASF licenses this file
  • to you under the Apache License, Version 2.0 (the
  • "License"); you may not use this file except in compliance
  • with the License. You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing,
  • software distributed under the License is distributed on an
  • "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  • KIND, either express or implied. See the License for the
  • specific language governing permissions and limitations
  • under the License.
    */

#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;

}

not working google assistant

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

Schizzo

GA no audio using respeaker 2mic hat.

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?

bash setupAssistantControl.sh error

bash setupAssistantControl.sh
fatal: destination path 'snowboy' already exists and is not an empty directory.
Reading package lists... Done
Building dependency tree
Reading state information... Done
libatlas-base-dev is already the newest version (3.10.3-8+rpi1).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pyaudio is already the newest version (0.2.11-1+b2).
python3-pyaudio is already the newest version (0.2.11-1+b2).
sox is already the newest version (14.4.2+git20190427-1).
swig is already the newest version (3.0.12-2).
swig3.0 is already the newest version (3.0.12-2).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyaudio
Using cached PyAudio-0.2.11.tar.gz (37 kB)
Collecting spidev
Using cached https://www.piwheels.org/simple/spidev/spidev-3.4-cp37-cp37m-linux_armv7l.whl (39 kB)
Requirement already satisfied: posix_ipc in /home/pi/Assistants/env/lib/python3.7/site-packages (1.0.4)
Collecting gpiozero
Using cached gpiozero-1.5.1-py2.py3-none-any.whl (138 kB)
Collecting numpy
Using cached https://www.piwheels.org/simple/numpy/numpy-1.18.1-cp37-cp37m-linux_armv7l.whl (10.4 MB)
Collecting RPi.GPIO
Using cached https://www.piwheels.org/simple/rpi-gpio/RPi.GPIO-0.7.0-cp37-cp37m-linux_armv7l.whl (69 kB)
Collecting colorzero
Using cached colorzero-1.1-py2.py3-none-any.whl (33 kB)
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (setup.py) ... 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'"'"'))' bdist_wheel -d /tmp/pip-wheel-1sb83nw8
cwd: /tmp/pip-install-984rasg8/pyaudio/
Complete output (16 lines):
running bdist_wheel
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: 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

Help me please. [ERROR] Missing parameters!

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=]+

  1. <config.json file> can be downloaded from developer portal and must contain the following:
    "clientId": ""
    "productId": ""
  2. <device_serial_number> specifies the deviceInfo deviceSerialNumber in the output json file.
  3. specifies the path to where the databases will be located.
  4. specifies the root directory to where the avs-device-sdk source code is located.
  5. output file
  6. Configure different variables that can be used to fill up extra information in the final configuration. Avaiable variables are:
    "SDK_CONFIG_MANUFACTURER_NAME": The name of the device manufacturer. This variable is required.
    "SDK_CONFIG_DEVICE_DESCRIPTION": The description of the device. This variable is required.

startAssistantControl issue

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

How do I install your build in my raspberry pi ?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.