Resource icon

TUTORIAL Asterisk Speech Recognition

pilovis

New Member
Joined
Feb 5, 2014
Messages
12
Reaction score
2
Yes I did and it worked well since then, but Yesterday after a friend called me to tell me that the speech recognition stopped working for him, I tested it and discovered that also mine stopped working. :(
The result of the speech recognition is always "-1"
I tried to regenerate the key, put the new one in the agi and restarted Asterisk, but with no results :(
The last modification I did on my PBX since last time I tested speech recognition has been the reinstallation of the new Skype client 4.3.0.37 (freeswitch + pulseaudio).

Ubuntu server 10.04.4 - Asterisk 1.6.2.4 - FreePBX 2.8.1.5 - Freeswitch 2.10 (Skype channel)
 

pilovis

New Member
Joined
Feb 5, 2014
Messages
12
Reaction score
2
I've just tried to activate Speech API in Chrome-Dev Group from another Google account, but it seems that this API is no more available, at least from Italy :(

Browse APIs
Speech API
No results found

P.S.: Another friend in France told me that the speech recognition still works for him (identical PBX configuration as mine)
 

pilovis

New Member
Joined
Feb 5, 2014
Messages
12
Reaction score
2
I've just rebooted the PBX after installing the new regenerated key and it seems that speech recognition works again :) (how long?)
Now I would like to understand why the old key stopped working ...
 

chris_c_

Active Member
Joined
Aug 19, 2010
Messages
509
Reaction score
67
Either there's a small error in the instructions, or Google has changed its requirements slightly for the developers console. The API key alone is not enough, it causes key invalid error. You have to also go into Credentials and create a "Service account" with its own API key. You don't have to use that service account API key for anything, but it has to exist on the google dev console. Note a "service account" is different from your "google account", they're associated with one another but not the same.
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,634
Reaction score
845
As I said before, your are chasing your tail down a rabbit hole that changes every few days, google is cleverer than you and ultimately wants you to pay, (I can't disagree with that concept) is saving 20 cents a day worth it?
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
Either there's a small error in the instructions, or Google has changed its requirements slightly for the developers console. The API key alone is not enough, it causes key invalid error. You have to also go into Credentials and create a "Service account" with its own API key. You don't have to use that service account API key for anything, but it has to exist on the google dev console. Note a "service account" is different from your "google account", they're associated with one another but not the same.

We use nothing but the developer's API key all the time and don't have any service accounts. Try 843-606-0555 and choose option 1 and say Delta Airlines. Perhaps for new users there has been a change, but it did not affect existing users. We'll take a look, but we just set a new one up about a week ago without any such limitation. As @dicko said, the slippery slope of Google services changes regularly.
 

chris_c_

Active Member
Joined
Aug 19, 2010
Messages
509
Reaction score
67
@wardmundy
Here's the before and after logs as proof.

Before: exactly according to the original directions posted here. Using API key associated with the "google account".

Code:
[2016-09-14 21:20:08] VERBOSE[15910][C-00000000] pbx.c: Executing [949@from-internal:5] AGI("PJSIP/701-00000000", "picotts.agi,"After the beep say the city $
[2016-09-14 21:20:08] VERBOSE[15910][C-00000000] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/picotts.agi
[2016-09-14 21:20:08] VERBOSE[15910][C-00000000] res_agi.c: <PJSIP/701-00000000> Playing '/tmp/494da6a93b80b8d608f3d0f4e48ee41f.slin' (escape_digits=) (samp$
[2016-09-14 21:20:15] VERBOSE[15910][C-00000000] res_agi.c: <PJSIP/701-00000000>AGI Script picotts.agi completed, returning 0
[2016-09-14 21:20:15] VERBOSE[15910][C-00000000] pbx.c: Executing [949@from-internal:6] AGI("PJSIP/701-00000000", "speech-recog.agi,en-US") in new stack
[2016-09-14 21:20:15] VERBOSE[15910][C-00000000] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
[2016-09-14 21:20:15] VERBOSE[15910][C-00000000] file.c: <PJSIP/701-00000000> Playing 'beep.gsm' (language 'en')
[2016-09-14 21:20:17] VERBOSE[15910][C-00000000] res_agi.c: speech-recog.agi,en-US: url: https://www.google.com/speech-api/v2/recognize?key=xxxxxxxxxxxxxxxx$
[2016-09-14 21:20:17] VERBOSE[15910][C-00000000] res_agi.c: speech-recog.agi,en-US: The response was:
[2016-09-14 21:20:17] VERBOSE[15910][C-00000000] res_agi.c: speech-recog.agi,en-US: Unable to get recognition data.
[2016-09-14 21:20:17] VERBOSE[15910][C-00000000] res_agi.c: <PJSIP/701-00000000>AGI Script speech-recog.agi completed, returning 0

After: Created the "service account," under the google account, with an associated API key specifically for the service account, yet not using the service account's API key for the calls to Speech API. Using the original API key, associated with the google account, created from these original instructions, for calls to the Speech API.

Code:
[2016-09-14 21:47:09] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:5] AGI("PJSIP/701-00000002", "picotts.agi,"After the beep say the city $
[2016-09-14 21:47:09] VERBOSE[19154][C-00000002] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/picotts.agi
[2016-09-14 21:47:09] VERBOSE[19154][C-00000002] res_agi.c: <PJSIP/701-00000002> Playing '/tmp/494da6a93b80b8d608f3d0f4e48ee41f.slin' (escape_digits=) (samp$
[2016-09-14 21:47:16] VERBOSE[19154][C-00000002] res_agi.c: <PJSIP/701-00000002>AGI Script picotts.agi completed, returning 0
[2016-09-14 21:47:16] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:6] AGI("PJSIP/701-00000002", "speech-recog.agi,en-US") in new stack
[2016-09-14 21:47:16] VERBOSE[19154][C-00000002] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
[2016-09-14 21:47:16] VERBOSE[19154][C-00000002] file.c: <PJSIP/701-00000002> Playing 'beep.gsm' (language 'en')
[2016-09-14 21:47:19] VERBOSE[19154][C-00000002] res_agi.c: speech-recog.agi,en-US: url: https://www.google.com/speech-api/v2/recognize?key=xxxxxxxxxxxxxxxx$
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] res_agi.c: speech-recog.agi,en-US: The response was:
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] res_agi.c: <PJSIP/701-00000002>AGI Script speech-recog.agi completed, returning 0
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:7] NoOp("PJSIP/701-00000002", "= Script returned:  ,  , 0.98267901 , Ha$
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:8] GotoIf("PJSIP/701-00000002", "1?proceed:retry") in new stack
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] pbx_builtins.c: Goto (from-internal,949,9)
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:9] AGI("PJSIP/701-00000002", "picotts.agi,"Please hold a moment while w$
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/picotts.agi
[2016-09-14 21:47:20] VERBOSE[19154][C-00000002] res_agi.c: <PJSIP/701-00000002> Playing '/tmp/pico__SgJDf.slin' (escape_digits=) (sample_offset 0) (languag$
[2016-09-14 21:47:24] VERBOSE[19154][C-00000002] res_agi.c: <PJSIP/701-00000002>AGI Script picotts.agi completed, returning 0
[2016-09-14 21:47:24] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:10] AGI("PJSIP/701-00000002", "nv-weather-google.php,Hartford") in new $
[2016-09-14 21:47:24] VERBOSE[19154][C-00000002] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/nv-weather-google.php
[2016-09-14 21:47:25] VERBOSE[19154][C-00000002] res_agi.c: <PJSIP/701-00000002>AGI Script nv-weather-google.php completed, returning 0
[2016-09-14 21:47:25] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:11] NoOp("PJSIP/701-00000002", "Forecast: Here are the latest weather c$
[2016-09-14 21:47:25] VERBOSE[19154][C-00000002] pbx.c: Executing [949@from-internal:12] AGI("PJSIP/701-00000002", "picotts.agi,"Here are the latest weather$
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
I believe you. I'm just saying it's not an across-the-board change, at least not yet. But thanks.
 

chris_c_

Active Member
Joined
Aug 19, 2010
Messages
509
Reaction score
67
OK. Someone, anyone, should try to independently verify this change, requiring the creation of the service account API key, as soon as it's convenient.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
Please document the actual steps you went through, and we will follow up.
 

Amarnath

New Member
Joined
Nov 2, 2018
Messages
3
Reaction score
0
Speech Recognition for Asterisk - This tutorial walks you through activating Speech Recognition for Asterisk applications.

After following above steps and calling below dialplan line
exten => 1234,n,agi(speech-recog.agi,en-US,10)

it is giving following error:

<SIP/alice-00000008>AGI Rx << verbose "Failed to execute '/var/lib/asterisk/agi-bin/speech-recog.agi': Permission denied" 1
speech-recog.agi,en-US,10: Failed to execute '/var/lib/asterisk/agi-bin/speech-recog.agi': Permission denied


what would be the issue, please help with and thanks in advance
 

mainenotarynet

Not really a Guru - Just a long time user
Joined
May 29, 2010
Messages
754
Reaction score
155
Check the owner of the file -- if it is root, asterisk can't use it (I use WinSCP into my box to check the permissions and who the owner is), some files are set so only the owner can use them but others Read and Execute them - numerically 744 in Unix rwxr-xr-x the owner if root, only root has full access, so try this:

chown asterisk:asterisk /var/lib/asterisk/agi-bin/speech-recog.agi

then try the script again.
 

Amarnath

New Member
Joined
Nov 2, 2018
Messages
3
Reaction score
0
I have tried chown asterisk:asterisk /var/lib/asterisk/agi-bin/speech-recog.agi but getting same as permissoin denied

following are "agi set debug" results

-- Executing [1234@from-internal:2] AGI("SIP/alice-00000005", "speech-recog.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
<SIP/alice-00000005>AGI Tx >> agi_request: speech-recog.agi
<SIP/alice-00000005>AGI Tx >> agi_channel: SIP/alice-00000005
<SIP/alice-00000005>AGI Tx >> agi_language: en
<SIP/alice-00000005>AGI Tx >> agi_type: SIP
<SIP/alice-00000005>AGI Tx >> agi_uniqueid: 1541228186.7
<SIP/alice-00000005>AGI Tx >> agi_version: 16.0.0
<SIP/alice-00000005>AGI Tx >> agi_callerid: alice
<SIP/alice-00000005>AGI Tx >> agi_calleridname: unknown
<SIP/alice-00000005>AGI Tx >> agi_callingpres: 0
<SIP/alice-00000005>AGI Tx >> agi_callingani2: 0
<SIP/alice-00000005>AGI Tx >> agi_callington: 0
<SIP/alice-00000005>AGI Tx >> agi_callingtns: 0
<SIP/alice-00000005>AGI Tx >> agi_dnid: 1234
<SIP/alice-00000005>AGI Tx >> agi_rdnis: unknown
<SIP/alice-00000005>AGI Tx >> agi_context: from-internal
<SIP/alice-00000005>AGI Tx >> agi_extension: 1234
<SIP/alice-00000005>AGI Tx >> agi_priority: 2
<SIP/alice-00000005>AGI Tx >> agi_enhanced: 0.0
<SIP/alice-00000005>AGI Tx >> agi_accountcode:
<SIP/alice-00000005>AGI Tx >> agi_threadid: 139748435793664
<SIP/alice-00000005>AGI Tx >>
<SIP/alice-00000005>AGI Rx << verbose "Failed to execute '/var/lib/asterisk/agi-bin/speech-recog.agi': Permission denied" 1
speech-recog.agi: Failed to execute '/var/lib/asterisk/agi-bin/speech-recog.agi': Permission denied
<SIP/alice-00000005>AGI Tx >> 200 result=1
 

ostridge

Guru
Joined
Jan 22, 2015
Messages
1,634
Reaction score
523
numerically 744 in Unix rwxr-xr-x
I just checked those permissions on my RPi; I don't see why it makes any difference but FWIW
Code:
ls -al /var/lib/asterisk/agi-bin/speech-recog.agi || chmod 775 /var/lib/asterisk/agi-bin/speech-recog.agi
-rwxrwxr-x 1 asterisk asterisk 8293 Nov  1  2017 /var/lib/asterisk/agi-bin/speech-recog.agi
 
Last edited:

Amarnath

New Member
Joined
Nov 2, 2018
Messages
3
Reaction score
0
Hi,
I am using Speech Recognition API in my asterisk project and I'm unable to activate grammar file by SpeechActivateGrammer please help why I'm getting the following result.

it's my extenstions.conf
exten => s,1,Answer()
exten => s,n,Playback(hello-world)
exten => s,n,SpeechCreate()
exten => s,n,SpeechActivateGrammar(company-directory)
exten => s,n,SpeechStart()
exten => s,n,SpeechBackground(who-would-you-like-to-dial)
exten => s,n,SpeechDeactivateGrammar(company-directory)

these are asterisk CLI output:-
-- Executing [6599@from-internal:1] Goto("SIP/alice-00000002", "dial-by-name,s,1") in new stack
-- Goto (dial-by-name,s,1)
-- Executing [s@dial-by-name:1] Answer("SIP/alice-00000002", "") in new stack
-- Executing [s@dial-by-name:2] Playback("SIP/alice-00000002", "hello-world") in new stack
-- <SIP/alice-00000002> Playing 'hello-world.ulaw' (language 'en')
-- Executing [s@dial-by-name:3] SpeechCreate("SIP/alice-00000002", "") in new stack
-- Executing [s@dial-by-name:4] SpeechActivateGrammar("SIP/alice-00000002", "company-directory") in new stack
== Spawn extension (dial-by-name, s, 4) exited non-zero on 'SIP/alice-00000002'

please help with thanks in advance
 

Members online

No members online now.

Forum statistics

Threads
25,815
Messages
167,790
Members
19,246
Latest member
aegodoyr
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top