shivasiddharth / GassistPi

Google Assistant for Single Board Computers
Other
1.02k stars 303 forks source link

Was there a change to the HEADLESS AUTOSTART on BOOT SERVICE SETUP? #677

Closed cdmack closed 5 years ago

cdmack commented 5 years ago

IMPORTANT NOTICE
If you do not complete the template below it is likely that your issue will not be addressed. When providing information about your issue please be as extensive as possible so that it can be solved by as little as possible responses.

FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED

Board and OS details:

Open a terminal and run

cat /proc/cpuinfo  
cat /etc/os-release  
Paste your Board and OS details here.   

processor   : 0
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 76.80
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 1
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 76.80
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 2
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 76.80
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 3
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 76.80
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

Hardware    : BCM2835
Revision    : a22082
Serial      : 0000000026e0905b

### Describe the bug:

I have been using the headless start for about a year. Ive needed to turn it on and off while using facial recognition software due to the high cpu demand (cant run both), but recently I have not been able to disable the service with "sudo systemctl disable gassistpi.service " and "sudo systemctl stop gassistpi.service".

I am prompted with "Failed to disable unit: No such file or directory" and "Failed to stop gassistpi.service: Unit gassistpi.service not loaded."


### Did you go through or search the issues section to check if your issue was already discussed (either currently open issues or closed issues).
Yes

### 2. Is the issue related to assistant installation ?
No

### If answer to question 2 is Yes, then paste the contents of the terminal below.

### If answer to question 2 is No, then proceed further.
### 3. Does the assistant service start normally?
Yes

### 4. Is the assistant service restarting automatically?
Yes

### If answer to question 4 is Yes, then paste the contents of the terminal below.

The service works as it should, but I am trying to stop the service and the normal disable and stop no longer work for me.


### If answer to question 4 is No, then proceed further.
### Manually start the assistant. For guidelines to start the assistant manually refer [this](https://github.com/shivasiddharth/GassistPi#manually-start-the-assistant)

### Paste the command below, that crashed the assistant

### Paste the contents of the terminal below
shivasiddharth commented 5 years ago

Are you sure , you ran the systemd service installer? After running the service installer, it should be enabled. Looks like it has not been enabled.

fragolinux commented 5 years ago

problems here, too... just installed on rpi0w, audio tests were ok, but going to start service i get this:

pi@raspberrypi:~ $ cd /home/${USER}
pi@raspberrypi:~ $ cat GassistPi/systemd/gassistpi.service
[Unit]
Description=Google Assistant-Voice
Wants=network-online.target
After=network-online.target

[Service]
Environment=VIRTUAL_ENV=/home/pi/env
Environment=PATH=/home/pi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

WorkingDirectory=/home/pi/
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

pi@raspberrypi:~ $ sudo chmod +x ./GassistPi/scripts/service-installer.sh
pi@raspberrypi:~ $ sudo ./GassistPi/scripts/service-installer.sh
pi@raspberrypi:~ $ sudo systemctl enable gassistpi.service
Created symlink /etc/systemd/system/multi-user.target.wants/gassistpi.service → /lib/systemd/system/gassistpi.service.
pi@raspberrypi:~ $ sudo systemctl start gassistpi.service
Failed to start gassistpi.service: Unit gassistpi.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status gassistpi.service' for details.
pi@raspberrypi:~ $ systemctl status gassistpi.service
● gassistpi.service - Google Assistant-Voice
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Dec 29 21:08:22 raspberrypi systemd[1]: gassistpi.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
shivasiddharth commented 5 years ago

Did you run the installer multiple times? The line with the execute command is missing. Please check the service file from the master. You can replace the existing service file from master, and remove the line with main.py and just retain the line with pushbutton.py. After that disable the service, re-run the service installer.

fragolinux commented 5 years ago

unfortunately yes, it was stuck at grpcio and i hit ENTER to see if something was still working or stuck... but so the installer "saved" that "enter" for when it asked to visit the url to get the authcode and failed... so i rerun, it went waaaaaay faster than before, i waited for the url, got the authcode, put there, made the audio tests, all fine... so, i just need this, with proper mods in there, and i'm fine? https://github.com/shivasiddharth/GassistPi/blob/master/systemd/gassistpi.service and for changing language, i can change it now in src/config.yaml or need to recompile? and as i'm on pi0w, no mqtt, right? when run manually, it does not react to "ok googlel", and if i press the button on the aiy-hat kit, it says the following instead of being ready to answer:

Initializing GPIO 25 for assistant activity indication
Stopped
stopping vlc
shivasiddharth commented 5 years ago

For the systemd files, yup those mods and you should be fine. For changing the language, add a --langargument along with the modelid and device id. The language change in the config.yaml is only for the custom say function. to change the language of the assistant, you need to use the --lang argument.

The pushbutton.py/pi zero assitsant comes with two different methods of assistant activation. 1. custom wakeword 2. Pushbutton They are mutually exclusive so you can have only one at a time. The default custom wakewords are alexa and snowboy. If you want a "Ok google" wakeword, you need to create your own model in snowboy. The pushbutton trigger is on GPIO 22 and the AIY's GPIO 23 is set as a stop button for music. You can interchange them in the config.yaml.

And yes Pizero does not support MQTT

fragolinux commented 5 years ago

i added " --lang 'it' " to the service, disabled previous, reinstalled new, enabled new, started new, in systemctl status i see that it started with the --lang parameter, but once it produces sound, it says HI instead of "ciao" (hi in italian)... and i swapped 22 and 23 in config.yaml with no results, in systemctl status i continue to see vlc stopped and google don't start asking or answering... i even disabled both youtube and gmusicapi in config.yaml but i see warnings in systemctl status about missing json/api/keys need to recompile after changing the config.yaml? man, thanks for your work and your help, very appreciated, tell me how can do a donation :)

fragolinux commented 5 years ago

if i say "alexa", both my echo dot and the rpi start flashing (rpi the aiykit led in the button), but if i ask something in italian, only "real" alexa answers, while the rpi continues blinking with the button... and does not react saying "snowboy", to prevent actual alexa to answer... Thanks

shivasiddharth commented 5 years ago

Never mind the warnings, they are caused by the import of the modules/packages. The language code that you have given for the argument is wrong, for the language codes, refer to this page https://developers.google.com/assistant/sdk/reference/rpc/languages. The starting Hi is a pre-generated tone, I never found time to generate tones for other languages. Will do it sometime in the near future. The models that i have provided for snowboy are universal models, its always better to generate your own voice models and use. Visit this page to create your own voice model https://snowboy.kitt.ai/dashboard Remember to have a noise free environment while generating a voice model and try to use the existing pi setup itself that will give a better accuracy while triggering. For contributions to the project, you can use the donation button on the project page (https://github.com/shivasiddharth/GassistPi)

fragolinux commented 5 years ago

oh, ok, i was thinking the code was the same as in the config.yaml i'll do my snowboy model tomorrow, thanks and for the other problems? Even if i say alexa, it does not answer, and keeps blinking the aiy led in the top button... and swap 22 and 23 in config.yaml didn't produce anything... need recompile? donation done! :)

fragolinux commented 5 years ago

how can i check logs... now that i set lang to "it-IT", when it starts it plays the sound various times, as it crashes while playing it or the like, and after 3 or 4 times (delayed about 30 seconds 1 with each next) it finally completes the startup sound and says HI... but finally it now answers if i ask something :)

edit: nope, something is happening... it answered 2 times, the third it was as the startup sound, it's like it crashed while answering... and never came back to life, had to restart service...

re-edit: and after it said HI, it's like is dead again... after restarting service, it sometimes starts answering then crashes...

shivasiddharth commented 5 years ago

are you using the pushbutton/custom wakeword ? in the config.yaml scroll right to the bottom and set custom wakeword to disabled if you want to use the pushbutton. Like i said before, they are mutually exclusive either one mode of trigger only. can you manually start the assistant on a terminal after stopping the service and then try the commands ? that will give you an idea as to what is happening. Also you can post the terminal contents here for me to take a look.

GitterKEIS commented 5 years ago

Was testing with a Pi3B+ Found also some trouble with the headless startup. Checked first in terminal: systemctl list-unit-files Seems gassistpi.service was disabled.

Used the link: https://github.com/shivasiddharth/GassistPi/blob/master/systemd/gassistpi.service

Because I am using a Pi3B (In my case the +) with original Google Aiy Voice Hat. In terminal: sudo nano /home/pi/GassistPi/systemd/gassistpi.service Removed line 10 from the pushbutton.py Filled in in line 9 the 'saved-model-id' (My own model ID) Save and Exit....

Again In terminal: sudo ./GassistPi/scripts/service-installer.sh sudo systemctl enable gassistpi.service systemctl list-unit-files

And it seemed to be enabled, sudo systemctl start gassistpi.service After that in terminal: sudo systemctl start gassistpi.service sudo reboot

And it was headless starting up again.....Thx

Still finding some troubles with "Hey/Hi Google" - 'Shutdown' or 'Reboot' But now I am at least able to: in terminal: sudo systemctl stop gassistpi.service

Use now for the time being Crontab -e to start main.py at boot with Screen to see whats going on.... Handy tool sudo apt-get install screen More info about screen: https://raspi.tv/2012/using-screen-with-raspberry-pi-to-avoid-leaving-ssh-sessions-open

Hope it helps

shivasiddharth commented 5 years ago

I have fixed the issue in the last commit https://github.com/shivasiddharth/GassistPi/commit/5cc2e91b928553c0730b15f1a0f8a68cd3987971 from now on, even if the installer is re-run several times, that should not affect the service file.

fragolinux commented 5 years ago

running in console i get this, the vlc part goes on indefenitely, i had to kill the process from other ssh session (as you see i tried a ctrl-c without success)... it detected my hotword, i asked what time is it, then it crashed while answering, only half answer spoken:

pi@raspberrypi:~ $ /home/${USER}/env/bin/python -u /home/${USER}/GassistPi/src/pushbutton.py --project-id 'pi0w-aiy-XXXX'  --device-model-id 'pi0w-aiy-XXXX-model' --lang 'it-IT'
/home/pi/env/lib/python3.5/site-packages/gmusicapi/__init__.py:4: GmusicapiWarning: gmusicapi.clients.OAUTH_FILEPATH is deprecated and will be removed; use Musicmanager.OAUTH_FILEPATH
  from gmusicapi.clients import Webclient, Musicmanager, Mobileclient
/home/pi/env/lib/python3.5/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /home/pi/.local/share/gmusicapi/mobileclient.cred: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
2018-12-30 08:25:24,094 - gmusicapi.Mobileclient1 (shared:183) [WARNING]: could not retrieve oauth credentials from ''/home/pi/.local/share/gmusicapi/mobileclient.cred''
[01a48ac8] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
[01a4aed0] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
AIY-HAT
Initializing GPIO 25 for assistant activity indication
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
^CStopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
WARNING:root:SoundDeviceStream read overflow (3200, 6400)
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
INFO:snowboy:Keyword 1 detected at time: 2018-12-30 08:33:30
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc
Stopped
stopping vlc

this is my service (before applying it to system):

pi@raspberrypi:~ $ cat GassistPi/systemd/gassistpi.service
[Unit]
Description=Google Assistant-Voice
Wants=network-online.target
After=network-online.target

[Service]
Environment=VIRTUAL_ENV=/home/__USER__/env
Environment=PATH=/home/__USER__/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ExecStart=/home/__USER__/env/bin/python -u /home/__USER__/GassistPi/src/pushbutton.py --project-id 'pi0w-aiy-XXXX' --device-model-id 'pi0w-aiy-XXXX-model' --lang 'it-IT'

WorkingDirectory=/home/__USER__/
StandardOutput=inherit
StandardError=inherit
Restart=always
User=__USER__

[Install]
WantedBy=multi-user.target

and this my config.yaml:

pi@raspberrypi:~ $ cat GassistPi/src/config.yaml
#Config file for declaring custom actions'parameters. The parameters have been listed here in alphabetical order (A-Z).

#Custom conversation. Add your queries and expected assistant response. Do not add symbols or special charecters.
Conversation:
  Conversation_Control: 'Enabled'
  question:
    1:
      - 'Who are you'
    2:
      - 'Do you have a family'
  answer:
    1:
      - 'I am not the one you expect to be'
      - 'Who do you think I am'
      - 'What bothers you'
    2:
      - 'Nope i am forever alone'
      - 'The whole world is my family'

# Deezer user credentials
Deezer:
  Deezer_Control: 'Enabled'
  User_id: '2247762504'

# DIY-HUE declarations
DIYHUE:
  DIYHUE_Control: 'Enabled'

# Domoticz declarations
Domoticz:
  # Set this to 'Enabled' to control devices registered to Domoticz server.
  Domoticz_Control: 'Disabled'
  Server_IP:
    # If you are running the server on the Pi itself, then change the ip to 'localhost'
    - '192.168.0.10'
  Server_port:
    - '443'
  Devices:
    #The number of names and number of ids should be equal
    #List the device names that you want to control
    Name:
      - 'Lamp1'
      - 'Lamp2'
      - 'Lamp3'
    #Assign the device ids in the same order as the devices listed above
    Id:
      - '1'
      - '2'
      - '3'

#ESP control declarations. Follow a similar pattern to add your own list.
ESP:
  ESP_Control: 'Enabled'
  IP: 'xxxxxxxxxxxx' #Enter your ESP's IP here.
  devicename:
    - 'Device 1'
    - 'Device 2'
    - 'Device 3'
  deviceid:
    - '/Device1'
    - '/Device2'
    - '/Device3'

#Streaming songs from Gaana.com
Gaana:
  Gaana_Control: 'Disabled'
  Playlist:
    # Enter your desired playlists
    - 'https://gaana.com/playlist/gaana-dj-bollywood-top-50-1'
    - 'https://gaana.com/playlist/alka-yagnik-bday'

#Enter your Google Login Credentials
Gmusicapi:
  Gmusic_Control: 'Disabled'

#API Key for YouTube and Kickstarter Search Engine
Google_cloud_api_key: ENTER-YOUR-GOOGLE-CLOUD-API-KEY-HERE

#GPIOS used in the project. Feel free to change in case.
Gpios:
  AIY_indicator:
    - 25
  assistant_indicators:
    - 05
    - 06
  picontrol:
    - 12
    - 13
    - 24
  pushbutton_trigger:
    - 23
  servo:
    - 27
  stopbutton_music_AIY_pushbutton:
    - 22

#KODI custom declarations change IP, music directory and video directory according to your device
Kodi:
  Kodi_Control: 'Disabled'
  ip: 192.168.88.226
  port: 8080
  username: kodi
  password: kodi
  musicdirectory: '/home/osmc/Music/'
  videodirectory: '/home/osmc/Movies/'
  windowcmd:
    - Home
    - Settings
    - Weather
    - Videos
    - Music
    - Player
  window:
    - home
    - settings
    - weather
    - videos
    - music
    - playercontrols

#Change you language. Default is english
Language:
  Choice: 'it'
  Language options:
     - 'en' #'English'
     - 'fr' # 'French'
     - 'de' # 'German'
     - 'it' # 'Italian'
     - 'es' # 'Spanish'
     - 'nl' # 'Dutch'
     - 'sv' # 'Swedish'

# Enter your Magic Mirror IP
Mmmip: 'ENTER_YOUR_MAGIC_MIRROR_IP'

#MQTT credentials
MQTT:
  MQTT_Control: 'Disabled'
  IP: 'Enter your MQTT IP ADDRESS here'
  UNAME: 'Enter your MQTT USERNAME here'
  PSWRD: 'Enter your MQTT PASSWORD here'
  TOPIC: 'ENTER your MQTT TOPIC here'

#Radio station declarations. Follow a similar pattern to add your own stations.
#Google may not pickup the pronunciation of radio station names, hence 'Radio 1' etc is required.
Radio_stations:
  Radio_Control: 'Enabled'
  stationnames:
    - 'Radio 1'
    - 'Radio 2'
    - 'Radio 3'
    - 'Radio 4'
    - 'Radio 5'
    - 'Radio 6'
  stationlinks:
    - 'http://stream.100p.nl/100pctnl.mp3'
    - 'http://stream.radiocorp.nl/100pnl_feest_mp3'
    - 'http://playerservices.streamtheworld.com/api/livestream-redirect/SKYRADIO.mp3'
    - 'https://stream.slam.nl/slam_mp3'
    - 'http://icecast.omroep.nl/3fm-bb-mp3'
    - 'http://playerservices.streamtheworld.com/api/livestream-redirect/VERONICA.mp3'
  stationradio:
    - '100% NL'
    - '100% NL Party'
    - 'Skyradio'
    - 'Slam FM'
    - '3 FM'
    - 'Veronica'

#Pi GPIO control declarations. Follow a similar pattern to add your own list of GPIOs
Raspberrypi_GPIO_Control:
  GPIO_Control: 'Enabled'
  lightnames:
    - 'kitchen lights'
    - 'bathroom lights'
    - 'bedroom lights'

#Spotify credentials. Register for a spotify developer and get the credentials.
Spotify:
  Spotify_Control: 'Enabled'
  client_id: 'ENTER YOUR SPOTIFY CLIENT ID HERE'
  client_secret: 'ENTER YOUR SPOTIFY CLIENT SECRET HERE'
  username: 'ENTER YOUR SPOTIFY USERNAME HERE'

#Enter your Tasmota Device details below
Tasmota_devicelist:
  Tasmota_Control: 'Enabled'
  friendly-names:
    - 'Desk Light'
    - 'Table Light'
  ipaddresses:
    - '192.168.1.36'
    - '192.168.1.35'
  portID:
    - '1'
    - '1'

#Voice for the "SAY" function or text to speech. Set it to 'Female' or 'Male' depending on your preference.
#Note: This does not change Google's voice. this is only for the speech generated within custom actions.
Voice_Custom_Actions: 'Female'

#Custom wakeword On/Off.
#To enable custom wakeword, change status to Enabled and restart the assistant.
Wakewords:
  Ok_Google: 'Enabled'
  Custom_Wakeword: 'Enabled'
  Custom_wakeword_models:
    - '/home/pi/GassistPi/src/resources/alexa.umdl'
    - '/home/pi/GassistPi/src/resources/snowboy.umdl'

YouTube:
  YouTube_Control: 'Disabled'

oh, i'm just using the wakeword "alexa" for now

shivasiddharth commented 5 years ago

Seems like GPIO 22 on AIY HAT has been pulled down by default. Can you try changing it to some other pin ?

fragolinux commented 5 years ago

Seems like GPIO 22 on AIY HAT has been pulled down by default. Can you try changing it to some other pin ?

ehm, i'm using the stock original (1st version) hat with its own connector (second from the right), 2 wires for the led, 2 for the button... but button is fine, as i tested yesterday when they were configured as standard config.yaml, each time i pressed it, on console appeared the vlc error, so the button is not stuck...

image

fragolinux commented 5 years ago

i'll try in the afternoon to shut down gassistpi and test with some basic gpio script, but as said, yesterday button was working just fine (at least, it triggered vlc every time i pressed it)...

shivasiddharth commented 5 years ago

GPIO 23 is the AIY HAT's arcade button (for triggering) GPIO 22 is the stopbutton that i have set for stoping music. In the config.yaml, can you change the stupbutton GPIO to 26 instead of 22

fragolinux commented 5 years ago

GPIO 23 is the AIY HAT's arcade button (for triggering) GPIO 22 is the stopbutton that i have set for stoping music. In the config.yaml, can you change the stupbutton GPIO to 26 instead of 22

so not what you wrote me yesterday? to just swap 22 and 23 in config.yaml, as you can see in my config file in previous comment?

shivasiddharth commented 5 years ago

To clear things up, first AIY HAT's arcade button (23) was set to stop and Triggering button was (22). As you wanted the arcade button to trigger, i asked you to swap them both. Now 23 is for triggering and 22 is for stopping music. The AIY' 22 has been pulled low by default, so i asked you to change the 22 to 26. The config file should look like this now:

#GPIOS used in the project. Feel free to change in case.
Gpios:
  AIY_indicator:
    - 25
  assistant_indicators:
    - 05
    - 06
  picontrol:
    - 12
    - 13
    - 24
  pushbutton_trigger:
    - 23
  servo:
    - 27
  stopbutton_music_AIY_pushbutton:
    - 26
fragolinux commented 5 years ago

now as you said with stopbutton 26, no more vlc problems in console, but randomly as it's answering it just crashes in the middle of the sentence... if i can do some logs, tell me how...

shivasiddharth commented 5 years ago

Its an ongoing issue with the grpc https://github.com/googlesamples/assistant-sdk-python/issues/303