rgrokett / RaspiAsteriskGoogle

Integrating Asterisk with Google Assistant Voice Service on a Raspberry Pi Zero using AGI
GNU General Public License v3.0
39 stars 12 forks source link

"googlesamples-assistant-pushtotalk" not working #5

Closed jstibenpb closed 5 years ago

jstibenpb commented 6 years ago

Hi Mr. Russell, I've tried to run this line "googlesamples-assistant-pushtotalk --credentials" in the terminal and It worked properly but when I run the Perl code, this code line looks like not working properly because I don't receive the Google Assistant's response, in fact, I'm not sure if the records had been sent to Google Assistant. I appreciate if you could help me in this problem. Thank you in advance.

rgrokett commented 6 years ago

Did you take a look at the closed issue #2 here?
https://github.com/rgrokett/RaspiAsteriskGoogle/issues/2

It has some info that may be similar to your problem and has debugging info. Most likely is that the permissions of the JSON credentials file is set to rw-------- (600) but it needs to be set to 644 rw-r--r-- so that the asterisk userid can access it.

jstibenpb commented 6 years ago

Yeah, I did but I could not solve the problem, "credentials.json" is set to 644. The only thing I made different to your project was to use IAX instead of SIP and in "extensions.conf" I used the same context for both extension lines (I commented [google_api]): "5000" the one from I call and "5001" the one connected to Google Assistant. Otherwise I was not able to call 5001 from 5000. Everything works properly, no errors but the file "..._out.wav" is not created neither using the Perl script nor using a similar Python script. The only strange thing is that the call shuts down when the code arrives to the line "googlesamples-assistant-pushtotalk". In the Asterisk debug console there are no any error nor warnings.

rgrokett commented 6 years ago

Did the test.sh program work ok? It does a query to Google including audio, so if it worked then the credentials and permissions in your Google account are good. Then the problem is located in the local environment that asterisk calls to the googlesamples-assistant-pushtotalk program.

Note that the test.sh (and google api) is running as user "pi" while the Asterisk is running as user "asterisk". So if the asterisk id cannot access /home/pi/... files, there may be a problem there. I assume the /home/pi directory is 755? $ ls -ld /home/pi Also the /home/pi/client_secret.json should be 644.

If you get the custom google_hello audio prompts when you dial and the google.agi executes, then the extensions.conf part should be ok.

One last try is to use the "asterisk" user to run the test.sh pgm: chmod 777 /home/pi/RaspiAsteriskGoogle This is just to allow asterisk to write into this directory for test only sudo chsh -s /bin/bash asterisk sudo su - asterisk id Should be asterisk user now cd /home/pi/RaspiAsteriskGoogle bash ./test.sh You can reverse these changes by exit chmod 755 /home/pi/RaspiAsteriskGoogle sudo chsh -s /bin/false asterisk

BTW, I assume you are not using FreePBX as its directory structure is quite different and the install scripts won't work so everything would need to be manually set up into FreePBX.

jstibenpb commented 6 years ago

Ok, I found out the mistake by running the script as Asterisk user. Basically, Asterisk could not reach to the credential directory. Now, it works properly.

I've tried to replicate your project by using SIP and IAX. The command to record the audio was the following:

agi.record_file(filename, format='wav', escape_digits='#', timeout=20000, silence = 3)

I used the Python library "pyst2"; I found out that the previous command works properly when SIP us used but when I use IAX, after recording the call hangs up immediately without executing the following instructions. Do you know why it is happening?