zaf / asterisk-speech-recog Goto Github PK
View Code? Open in Web Editor NEWSpeech recognition script for Asterisk that uses google's speech engine.
License: GNU General Public License v2.0
Speech recognition script for Asterisk that uses google's speech engine.
License: GNU General Public License v2.0
Does this have a feature that can accept multiple digits for interrupt and get the digits press? I mean for example 0123456789 can be my interrupt keys and when I press 1 this will interrupt then have the digit pressed return?
Thanks
Hello Zaf,
Have you considered implementing the integration of Asterisk with Google's ASR streaming mode using grcp?
Thanks and regards,
How to we set this up to actually stop the previous command and allow the caller to immediately be detected and recognized?
is it possible to parse a recorded file ? For example, I was thinking of converting a voicemail message into an email
Using Asterisk version 13.17 on ubuntu 17.10 the file sln takes time to be persisted. So then flac conversion fails with 256 error code returned (file does not exist).
There could be a parallel process running on asterisk saving the sln files. If I add a sleep before converting the file it works.
Wondering if it would be better to check the file presence and if it's locked.
Here is the full output of AGI debug. Asterisk 13.17.1, Centos 7.3 – it just says -1. Did a packet capture to see, whether any packet has been send to cloud none.
– Executing [2017@india:3] AGI(“SIP/2018-000051cd”, “speech-recog.agi,en-EN”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
<SIP/2018-000051cd>AGI Tx >> agi_request: speech-recog.agi
<SIP/2018-000051cd>AGI Tx >> agi_channel: SIP/2018-000051cd
<SIP/2018-000051cd>AGI Tx >> agi_language: en
<SIP/2018-000051cd>AGI Tx >> agi_type: SIP
<SIP/2018-000051cd>AGI Tx >> agi_uniqueid: 1527178246.147414
<SIP/2018-000051cd>AGI Tx >> agi_version: 13.17.1
<SIP/2018-000051cd>AGI Tx >> agi_callerid: 2018
<SIP/2018-000051cd>AGI Tx >> agi_calleridname: IT-Paul
<SIP/2018-000051cd>AGI Tx >> agi_callingpres: 0
<SIP/2018-000051cd>AGI Tx >> agi_callingani2: 0
<SIP/2018-000051cd>AGI Tx >> agi_callington: 0
<SIP/2018-000051cd>AGI Tx >> agi_callingtns: 0
<SIP/2018-000051cd>AGI Tx >> agi_dnid: 2017
<SIP/2018-000051cd>AGI Tx >> agi_rdnis: unknown
<SIP/2018-000051cd>AGI Tx >> agi_context: india
<SIP/2018-000051cd>AGI Tx >> agi_extension: 2017
<SIP/2018-000051cd>AGI Tx >> agi_priority: 3
<SIP/2018-000051cd>AGI Tx >> agi_enhanced: 0.0
<SIP/2018-000051cd>AGI Tx >> agi_accountcode: 2018
<SIP/2018-000051cd>AGI Tx >> agi_threadid: 139844844660480
<SIP/2018-000051cd>AGI Tx >> agi_arg_1: en-EN
<SIP/2018-000051cd>AGI Tx >>
<SIP/2018-000051cd>AGI Rx << SET VARIABLE “utterance” “-1”
<SIP/2018-000051cd>AGI Tx >> 200 result=1
<SIP/2018-000051cd>AGI Rx << SET VARIABLE “confidence” “-1”
<SIP/2018-000051cd>AGI Tx >> 200 result=1
– <SIP/2018-000051cd>AGI Script speech-recog.agi completed, returning 0
When testing with a voicemail message on the CLI,
/tmp/asterisk-speech-recog/samples$ ./speech-recog-cli.pl msg0000.wav
Openning msg0000
Failed to get data for file:/tmp/recg_43pLYz.flac at ./speech-recog-cli.pl line 188.
The msg0000.wav is in the same directory, the file /tmp/... is gone. (commenting out the UNLINK line leaves it in place but still unable to test.
Before the script worked well, now every time I get "Error -1"
I use Ubuntu server 10.04 and Asterisk 1.6.2.4.
Could it depend on some Ubuntu update?
No useful indication on full debug output from the asterisk console.
-- Executing [1235@from-internal:1] Answer("SIP/270-00000007", "") in new stack
-- Executing [1235@from-internal:2] AGI("SIP/270-00000007", "googletts.agi,"Say something in English, when done press the pound key.",en") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/googletts.agi
-- Playing '/tmp/ggl_0mapTb' (escape_digits=) (sample_offset 0)
-- <SIP/270-00000007>AGI Script googletts.agi completed, returning 0
-- Executing [1235@from-internal:3] AGI("SIP/270-00000007", "speech-recog.agi,en-US") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
-- <SIP/270-00000007> Playing 'beep.alaw'
-- <SIP/270-00000007>AGI Script speech-recog.agi completed, returning 0
-- Executing [1235@from-internal:4] Verbose("SIP/270-00000007", "1,Script returned: -1 , -1") in new stack
Script returned: -1 , -1
-- Executing [1235@from-internal:5] GotoIf("SIP/270-00000007", "0?playback:retry") in new stack
-- Goto (from-internal,1235,9)
-- Executing [1235@from-internal:9] AGI("SIP/270-00000007", "googletts.agi,"Can you please repeat more clearly?",en") in new stack
I wounder what i am missing, any dependency? The API is defiantly reading. so whats going on here?
*CLI> -- speech-recog.agi: Clearing channel variables.
-- speech-recog.agi: Setting variable: utterance = -1
-- speech-recog.agi: Command returned: 200 result=1
-- speech-recog.agi: Setting variable: confidence = -1
-- speech-recog.agi: Command returned: 200 result=1
-- speech-recog.agi: Found flac in: /usr/bin/flac
Use of uninitialized value $AGI{"arg_2"} in length at /var/lib/asterisk/agi-bin/speech-recog.agi line 135, <STDIN> line 24.
Use of uninitialized value $AGI{"arg_3"} in length at /var/lib/asterisk/agi-bin/speech-recog.agi line 147, <STDIN> line 24.
Use of uninitialized value $AGI{"arg_4"} in length at /var/lib/asterisk/agi-bin/speech-recog.agi line 152, <STDIN> line 24.
-- speech-recog.agi: Checking channel status.
-- speech-recog.agi: Command returned: 200 result=6
-- speech-recog.agi: Command returned: 200 result=1 ((ulaw))
*CLI> -- <SIP/-00000009> Playing 'beep.ulaw' (language 'en')
*CLI> -- speech-recog.agi: Command returned: 200 result=99983 (timeout) endpos=8160
-- speech-recog.agi: Recording Format: sln, Rate: 8000 Hz, Language: en-US, s=5, Interrupt keys: #
-- speech-recog.agi: The response was:
Use of uninitialized value $response{"utterance"} in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 244.
-- speech-recog.agi: Setting variable: utterance =
Use of uninitialized value $response{"utterance"} in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 245.
-- speech-recog.agi: Command returned: 200 result=1
Use of uninitialized value $response{"confidence"} in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 244, <STDIN> line 28.
-- speech-recog.agi: Setting variable: confidence =
Use of uninitialized value $response{"confidence"} in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 245, <STDIN> line 28.
-- speech-recog.agi: Command returned: 200 result=1
-- speech-recog.agi: Cleaning temp files.
-- <SIP/-00000009>AGI Script speech-recog.agi completed, returning 0
-- Executing [123412@mycontext:4] Verbose("SIP/-00000009", "1,Script returned: , ") in new stack
Script returned: ,
-- Executing [123412@mycontext:5] GotoIf("SIP/-00000009", "0?playback:retry") in new stack
-- Goto (mycontext,123412,9)
When i did a curl https://speech.googleapis.com/v1beta1/speech:syncrecognize?key=XXXXXXX -X POST -d '{helo}' I got
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"{helo}\": Cannot bind query parameter. Field '{helo}' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [ {
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [ {
"description": "Invalid JSON payload received. Unknown name \"{helo}\": Cannot bind query parameter. Field '{helo}' could not be found in request message."
} ] } ] }}
[root@localhost Speex-with-header-bytes-master]# curl https://speech.googleapis.com/v1beta1/speech:syncrecognize?key=AIzaSyDGHsR7Vmd6xNwsAoQrjH2XAbyjmLZ_DFU -X POST -d '{helo}'
EDIT: I have found a Google Python client library that seems to work well with pyst and Asterisk 14 and I'll tidy the code up and post something here tomorrow!
Hi there; it looks like this project might be using v2 of the old "unofficial" speech recognition.
But, confusingly, it looks like Google have now officially launched a speech API, but called V1beta.
See https://cloud.google.com/speech/reference/rest/
The endpoints are https://speech.googleapis.com and the methods are /v1beta1/speech:asyncrecognize
For example https://speech.googleapis.com/v1beta1/operations/list?key=xxxxx
Before I start hacking away at stuff I don't really understand, are you aware of this and working on an update? Do these two links help? https://cloud.google.com/speech/docs/rest-tutorial https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/speech
On a fresh centos with astersiknow 11 installation, I try to use asterisk-speech-recog on a simple extension using Dialplan Injection v0.1.1:
Answer()
agi(speech-recog.agi,en-US)
Verbose(1,The text you just said is: ${utterance})
Verbose(1,The probability to be right is: ${confidence})
Hangup()
The console output is:
Connected to Asterisk 11.2.1 currently running on localhost (pid = 4148)
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
-- Executing [1234@from-internal:1] Goto("SIP/101-00000005", "injection-6,1234,1") in new stack
-- Goto (injection-6,1234,1)
-- Executing [1234@injection-6:1] NoOp("SIP/101-00000005", "Entering Injection: Simple-reconize-demo") in new stack
-- Executing [1234@injection-6:2] Answer("SIP/101-00000005", "") in new stack
-- Executing [1234@injection-6:3] AGI("SIP/101-00000005", "speech-recog.agi,en-US") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
-- <SIP/101-00000005> Playing 'beep.ulaw' (language 'en')
-- <SIP/101-00000005>AGI Script speech-recog.agi completed, returning 0
-- Executing [1234@injection-6:4] Verbose("SIP/101-00000005", "1,The text you just said is: -1") in new stack
The text you just said is: -1
-- Executing [1234@injection-6:5] Verbose("SIP/101-00000005", "1,The probability to be right is: -1") in new stack
The probability to be right is: -1
-- Executing [1234@injection-6:6] Hangup("SIP/101-00000005", "") in new stack
== Spawn extension (injection-6, 1234, 6) exited non-zero on 'SIP/101-00000005'
-- Executing [h@injection-6:1] Macro("SIP/101-00000005", "hangupcall,") in new stack
-- Executing [s@macro-hangupcall:1] GotoIf("SIP/101-00000005", "1?theend") in new stack
-- Goto (macro-hangupcall,s,3)
-- Executing [s@macro-hangupcall:3] ExecIf("SIP/101-00000005", "0?Set(CDR(recordingfile)=)") in new stack
-- Executing [s@macro-hangupcall:4] Hangup("SIP/101-00000005", "") in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'SIP/101-00000005' in macro 'hangupcall'
== Spawn extension (injection-6, h, 1) exited non-zero on 'SIP/101-00000005'
[2014-02-02 10:55:40] NOTICE[4167]: chan_sip.c:23248 handle_response_peerpoke: Peer '101' is now Lagged. (3121ms / 2000ms)
Speaking on the phone a work, the result is -1.
Where I'm wrong? As you now I opened an issue on asterisk-googletts.
Thanks in advance.
*** THIS IS JUST A SUGGESTION NOT ISSUE ***
See this Create your own Inline Translator like Skype Translator
Great tool! But I´m with some trouble...
If I call 1234 without any timeout set, it works just great (so I need to push '#' after saying something):
Executing [1234@interno:2] **AGI("SIP/1004-000000ef", "speech-recog.agi,pt-BR")** in new stack
Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
<SIP/1004-000000ef>AGI Script speech-recog.agi completed, returning 0
Executing [1234@interno:3] Verbose("SIP/1004-000000ef", "1,**The text you just said is: Oi**") in new stack
The text you just said is: Oi
If I use a timeout (silence or absolute), it really cuts the recognition in the right time, but it does not recognize anything.
Executing [1234@interno:2] **AGI("SIP/1004-000000ec", "speech-recog.agi,pt-BR,3,,,3")** in new stack
Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
<SIP/1004-000000ec>AGI Script speech-recog.agi completed, returning 0
Executing [1234@interno:3] Verbose("SIP/1004-000000ec", "1,**The text you just said is: "**) in new stack
The text you just said is:
I´m doing something wrong? My goal is to ask something short and wait only 3 seconds for the answer, without any dtmf iteration.
Thank you guys.
Edit: This guy have the same problem on this forum:
https://pbxinaflash.com/community/threads/asterisk-speech-recognition.20748/
My calls aren't currently processing, This might be the culprit.
http://www.reddit.com/r/raspberry_pi/comments/251yur/google_speech_api_has_changed/
My dream is to plug vintage rotary dial phones into a standard ATA/TDM, pick up the receiver, speak the phone number and have PIAF connect me. Here is the core of the dial plan code I am playing with:
exten => 777,1,agi(googletts.agi,"After the beep, say the phone number you wish to dial",en)
exten => 777,n,agi(speech-recog.agi,en-US)
exten => 777,n,Noop(= Script returned: ${status} , ${id} , ${confidence} , ${utterance} =)
exten => 777,n(proceed),agi(googletts.agi,"I think you said: ${utterance}. Please hold to dial",en)
exten => 777,n,Wait(3)
exten => 777,n,agi(googletts.agi,"Dialingl.",en)
exten => 777,n,Dial(Local/${utterance}@outbound-allroutes)
exten => 777,n,Hangup
The problem is that using ver. 0.5 of the speech-recog.agi script, I can't get it to time out with silence detection, it always requires a # to terminate. Am I doing something wrong?
I found that adding a lc (${utterance}); works great great in the perl script. I find that google sometimes Capitalizes things and sometimes not. So if your using a [mainmenu] goto(${utterance},1) command in your dialplan sometimes you need Two of the same otherwise, Like sales & Sales. Adding a LC to the variable from output can change all that.
I hope this script has additions to it to show alternative values. Like sometimes my customers word comes back as play instead of clay. If I could run a script to find alternative words returned and match it with words from a list it would be much better and functional.
If anyone has went further with this script such as above please help!
In practice everything seems to work but when he uses the google key it does not proceed and comes out with this error:
speech-recog.agi, it-IT: Unable to get recognition data.
Hi,
In current situation caller has to record after the beep.
Is it possible caller can record during the prompt?
Hi!
The fourth parameter is not read, independent parameter passed or not.
Congratulations for the work.
at,
Carrer
Has any work been done towards using the NEW Cloud Speech API?
https://cloud.google.com/speech/
I didn't have any luck with changing the host:
https://speech.googleapis.com/v1beta1/speech:syncrecognize
Hi, im getting "Unable to get recognition data." error.
Is this Script working yet?
Hi! great work!
I have a app in asterisk php-agi file, but i need to use speech recog directly in my php agi. Can you any of examples of spech doc directly in a agi file?
I successfully used speech-recog.agi for months but starting from last week, without any modification on my PBXes, the speech recognition engine does not correctly recognize Italian words anymore.
If anyone says '590' it recognizes '5000 90'
If he/she says 'Laura' it recognize 'Laura A' , if he/she says '551' it recognizes '5, zero second and 1'
It's Crazy!
Maurizio
i'm not sure what's going on [i've created and input my own API key and all that, but it seems to just error out every time with no debug messages.
-- Executing [547@from-lynx:4] AGI("IAX2/lynx-iax-15602", "speech-recog.agi,en-US") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
-- <IAX2/lynx-iax-15602>AGI Script speech-recog.agi completed, returning 0
this is the log of output. all it says is 0 for success. and there's no pause. it just returns 0 as soon as its run. no beep.
Hi,
When I execute the script it returns 0 but doesnt return the utterance and confidence .
Cant figure out the error .
The AGI Debug shows the following
<DAHDI/1-1>AGI Rx << EXEC AGI asterisk-speech-recog/speech-recog.agi,key=AIzaSyARee_mzuaaMJyw8xgUpjEPRMaiM
-- AGI Script Executing Application: (AGI) Options: (asterisk-speech-recog/speech-recog.agi,key=AIzaSyARee_mzuaaMJyw8xgUpjEPRMaiM)
-- Launched AGI Script /var/lib/asterisk/agi-bin/asterisk-speech-recog/speech-recog.agi
<DAHDI/1-1>AGI Tx >> agi_request: asterisk-speech-recog/speech-recog.agi
<DAHDI/1-1>AGI Tx >> agi_channel: DAHDI/1-1
<DAHDI/1-1>AGI Tx >> agi_language: en
<DAHDI/1-1>AGI Tx >> agi_type: DAHDI
<DAHDI/1-1>AGI Tx >> agi_uniqueid: 1423073509.44
<DAHDI/1-1>AGI Tx >> agi_version: 1.8.21.0
<DAHDI/1-1>AGI Tx >> agi_callerid: 9910044314
<DAHDI/1-1>AGI Tx >> agi_calleridname: unknown
<DAHDI/1-1>AGI Tx >> agi_callingpres: 0
<DAHDI/1-1>AGI Tx >> agi_callingani2: 0
<DAHDI/1-1>AGI Tx >> agi_callington: 0
<DAHDI/1-1>AGI Tx >> agi_callingtns: 0
<DAHDI/1-1>AGI Tx >> agi_dnid: unknown
<DAHDI/1-1>AGI Tx >> agi_rdnis: unknown
DAHDI/1-1>AGI Tx >> agi_context: from-zaptel
<DAHDI/1-1>AGI Tx >> agi_extension: s
<DAHDI/1-1>AGI Tx >> agi_priority: 2
<DAHDI/1-1>AGI Tx >> agi_enhanced: 0.0
<DAHDI/1-1>AGI Tx >> agi_accountcode:
<DAHDI/1-1>AGI Tx >> agi_threadid: 140492011169536
<DAHDI/1-1>AGI Tx >> agi_arg_1: key=AIzaSyARee_mzuaaMJyw8xgUpjEPRMaiM
<DAHDI/1-1>AGI Tx >>
-- <DAHDI/1-1>AGI Script asterisk-speech-recog/speech-recog.agi completed, returning 0
<DAHDI/1-1>AGI Tx >> 200 result=0
<DAHDI/1-1>AGI Rx << GET VARIABLE utterance
<DAHDI/1-1>AGI Tx >> 200 result=0
<DAHDI/1-1>AGI Rx << VERBOSE "The entered digit is " 1
dtmf1.php: The entered digit is
<DAHDI/1-1>AGI Tx >> 200 result=1
<DAHDI/1-1>AGI Rx << HANGUP
Hello Zaf,
Hope you are doing great.
I am getting this error
VERBOSE "Unable to get recognition data." 3
-- asterisk-speech-recog/speech-recog.agi,en-US: Unable to get recognition data.
What can be the issue?
Thanks in advance
Hello Zaf,
I use asterisk 1.4, Centos 6.5 and have update lib requeriments. I trye everything and debug code, but always appers that:
[Nov 24 00:25:26] NOTICE[38776]: rtp.c:1287 ast_rtp_read: Unknown RTP codec 95 received from '190.113.208.170'
AGI Rx << SET VARIABLE "utterance" "-1"
AGI Tx >> 200 result=1
AGI Rx << SET VARIABLE "confidence" "-1"
AGI Tx >> 200 result=1
AGI Rx << CHANNEL STATUS
AGI Tx >> 200 result=6
AGI Rx << GET FULL VARIABLE ${CHANNEL(audionativeformat)}
AGI Tx >> 200 result=1 (ulaw)
AGI Rx << RECORD FILE /tmp/stt_kxT7jG sln "#" "-1" BEEP "s=2"
-- <SIP/81-54014f50> Playing 'beep' (language 'en')
AGI Tx >> 200 result=35 (dtmf) endpos=25440
AGI Rx << VERBOSE "Unable to get recognition data." 3
Can u help me please.
Hi,
Google Speech API v.1 was stopped recently by google and it's give 404 error example.
the new service need API-Key .
Hi
the script returns always -1 what I should do
Dear Zaf,
The speech-recog.agi was working perfectly for months, but since some weeks ago I´m checking that It is not returning the "confidence" parameter anymore as you can see by Asterisk AGI debug attached file. And I was using that parameter to check how "confident" the recognition engine feels about the result.
Is there any trouble with this engine ? How can I start receive this parameter again ?
PS: Since then I realized that recognition has a certain drop in quality. Where, for example, my name was recognized in my tests often as "Daniels," "Daniel 1", "Danieles", and my correct name is 'Daniel'.
Earlier recognition is very in tune.
agi set debug on
<SIP/2555-0000000b>AGI Tx >> agi_request: speech-recog.agi
<SIP/2555-0000000b>AGI Tx >> agi_channel: SIP/2555-0000000b
<SIP/2555-0000000b>AGI Tx >> agi_language: pt_BR
<SIP/2555-0000000b>AGI Tx >> agi_type: SIP
<SIP/2555-0000000b>AGI Tx >> agi_uniqueid: pabx_ip-1444091299.11
<SIP/2555-0000000b>AGI Tx >> agi_version: 1.8.25.0
<SIP/2555-0000000b>AGI Tx >> agi_callerid: 99999999999
<SIP/2555-0000000b>AGI Tx >> agi_calleridname: unknown
<SIP/2555-0000000b>AGI Tx >> agi_callingpres: 0
<SIP/2555-0000000b>AGI Tx >> agi_callingani2: 0
<SIP/2555-0000000b>AGI Tx >> agi_callington: 0
<SIP/2555-0000000b>AGI Tx >> agi_callingtns: 0
<SIP/2555-0000000b>AGI Tx >> agi_dnid: 2555
<SIP/2555-0000000b>AGI Tx >> agi_rdnis: unknown
<SIP/2555-0000000b>AGI Tx >> agi_context: principal
<SIP/2555-0000000b>AGI Tx >> agi_extension: s
<SIP/2555-0000000b>AGI Tx >> agi_priority: 5
<SIP/2555-0000000b>AGI Tx >> agi_enhanced: 0.0
<SIP/2555-0000000b>AGI Tx >> agi_accountcode:
<SIP/2555-0000000b>AGI Tx >> agi_threadid: 140502816749312
<SIP/2555-0000000b>AGI Tx >> agi_arg_1: pt-BR
<SIP/2555-0000000b>AGI Tx >> agi_arg_2: 2
<SIP/2555-0000000b>AGI Tx >> agi_arg_3:
<SIP/2555-0000000b>AGI Tx >> agi_arg_4: NOBEEP
<SIP/2555-0000000b>AGI Tx >>
<SIP/2555-0000000b>AGI Rx << SET VARIABLE "utterance" "-1"
<SIP/2555-0000000b>AGI Tx >> 200 result=1
<SIP/2555-0000000b>AGI Rx << SET VARIABLE "confidence" "-1"
<SIP/2555-0000000b>AGI Tx >> 200 result=1
<SIP/2555-0000000b>AGI Rx << CHANNEL STATUS
<SIP/2555-0000000b>AGI Tx >> 200 result=6
<SIP/2555-0000000b>AGI Rx << GET FULL VARIABLE ${CHANNEL(audionativeformat)}
<SIP/2555-0000000b>AGI Tx >> 200 result=1 (ulaw)
<SIP/2555-0000000b>AGI Rx << RECORD FILE /tmp/stt_DA02Se sln "#" "-1" "s=2"
<SIP/2555-0000000b>AGI Tx >> 200 result=99980 (timeout) endpos=22560
<SIP/2555-0000000b>AGI Rx << SET VARIABLE "utterance" "Daniels"
<SIP/2555-0000000b>AGI Tx >> 200 result=1
<SIP/2555-0000000b>AGI Rx << SET VARIABLE "confidence" ""
<SIP/2555-0000000b>AGI Tx >> 200 result=1
agi set debug off
Thanks in advance.
I have tried looking for "Speech API" in the developer console, along with googling for how to get an API key, and am unable to find the api location.
Hi,
I've tried the AGI perl script with both "server application" and "browser application" API KEYs generated from my Developer console (Speech API)
Also tried these 4 settings on the "allowed IPs" field:
But still no luck. The script returns blank values for confidence and utterance.
My quota for the Speech API still 0%, so it's not even accepting/logging these tests.
Any ideas on what may I'm doing wrong? Is anyone aware of a origin-country limitation for this API?
Thanks in advance.
exten => 999,1,Playback(1.wav) ;
same => n,Goto(stmukesivr,s,1)
[stmukesivr]
exten => s,n,agi(googletranslate.agi,en)
exten => 1,1,Background(dayhours)
same => n,agi(googletranslate.agi,"is",en)
same => n(record),agi(speech-recog.agi,en-US)
same => n,Verbose(1,Script returned: ${status} , ${id} , ${confidence} , ${utterance})
same => n,GotoIf(
same => n(olddata),Goto(queues,111,1)
same => n(tryagain),GotoIf($["${utterance}" = "no"]?newdata:onemore)
same => n,(newdata),Goto(queues,222,1)
same => n(onemore),GotoIf($["${utterance}" = "menu"]?menu:sayagain)
same => n(menu),Background(welcome)
same => n,Goto(stmukesivr,s,1)
same => n(sayagain),Background(welcome)
;same => n,agi(googletts.agi,en)
same => n,goto(record)
;exten => _X,1,Background(invald)
;exten => _X,1,agi(googletts.agi,"You just pressed ${EXTEN}.",en,any)
;exten => _X,n,WaitExten()
Below is the error I am getting. I have used New "googletranslate.agi speech-recog.agi" both are new files which have updated on Github for V2 with API key. I have used Server KEY API which I have got from Console.
I have changed DEBUG-1 as well but still "Returning 0" in CLI log.
below is the error and I am not able to get any response from google on CLI.
OUTPUT:
Connected to Asterisk 11.2.1 currently running on patelsa1 (pid = 13937)
== Using SIP RTP CoS mark 5
-- Executing [999@LocalSets:1] Playback("SIP/0000FFFFABCD-00000001", "1.wav") in new stack
[2014-11-05 01:43:35] WARNING[14449][C-00000001]: file.c:698 ast_openstream_full: File 1.wav does not exist in any format
[2014-11-05 01:43:35] WARNING[14449][C-00000001]: file.c:1014 ast_streamfile: Unable to open 1.wav (format (ulaw)): No such file or directory
[2014-11-05 01:43:35] WARNING[14449][C-00000001]: app_playback.c:480 playback_exec: ast_streamfile failed on SIP/0000FFFFABCD-00000001 for 1.wav
-- Executing [999@LocalSets:2] Goto("SIP/0000FFFFABCD-00000001", "stmukesivr,s,1") in new stack
-- Goto (stmukesivr,s,1)
-- Executing [s@stmukesivr:1] Answer("SIP/0000FFFFABCD-00000001", "") in new stack
-- Executing [s@stmukesivr:2] WaitExten("SIP/0000FFFFABCD-00000001", "") in new stack
== CDR updated on SIP/0000FFFFABCD-00000001
-- Executing [1@stmukesivr:1] BackGround("SIP/0000FFFFABCD-00000001", "dayhours") in new stack
-- <SIP/0000FFFFABCD-00000001> Playing 'dayhours.slin' (language 'en')
-- Executing [1@stmukesivr:2] AGI("SIP/0000FFFFABCD-00000001", "googletranslate.agi,"is",en") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/googletranslate.agi
-- <SIP/0000FFFFABCD-00000001>AGI Script googletranslate.agi completed, returning 0
-- Executing [1@stmukesivr:3] AGI("SIP/0000FFFFABCD-00000001", "speech-recog.agi,en-US") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
-- <SIP/0000FFFFABCD-00000001>AGI Script speech-recog.agi completed, returning 0
-- Executing [1@stmukesivr:4] Verbose("SIP/0000FFFFABCD-00000001", "1,Script returned: , , , ") in new stack
Script returned: , , ,
-- Executing [1@stmukesivr:5] GotoIf("SIP/0000FFFFABCD-00000001", "0?olddata:tryagain") in new stack
-- Goto (stmukesivr,1,7)
-- Executing [1@stmukesivr:7] GotoIf("SIP/0000FFFFABCD-00000001", "0?newdata:onemore") in new stack
-- Goto (stmukesivr,1,9)
-- Executing [1@stmukesivr:9] GotoIf("SIP/0000FFFFABCD-00000001", "0?menu:sayagain") in new stack
-- Goto (stmukesivr,1,12)
-- Executing [1@stmukesivr:12] BackGround("SIP/0000FFFFABCD-00000001", "welcome") in new stack
-- <SIP/0000FFFFABCD-00000001> Playing 'welcome.slin' (language 'en')
-- Executing [1@stmukesivr:13] Goto("SIP/0000FFFFABCD-00000001", "record") in new stack
Let me know where I am wrong.
After recording the file in asterisk and converted it to flac,
google speech returns a status 5 error.
That seem to be a file format error in the flac file.
Is there anything to consider regarding asterisk recording settings/formats?
Hello, is there any way to make it work with IBM Watson instead of Google ? thaks!
Hi,
I am using the implantation sample from the installation steps:
exten => 1,n,agi(speech-recog.agi,en-US,5)
exten => 1,n,Verbose(1,The text you just said is: ${utterance})
exten => 1,n,Verbose(1,The probability to be right is: ${confidence})
exten => 1,n,Hangup()
the AGI is not waiting for voice, it is exiting immediately.
here is the log from the CLI:
-- Executing [1@call-routing:29] AGI("PJSIP/Cellcom_SIP_Trunk-00000007", "speech-recog.agi,en-US,5") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_request: speech-recog.agi
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_channel: PJSIP/Cellcom_SIP_Trunk-00000007
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_language: en
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_type: PJSIP
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_uniqueid: 1514877104.7
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_version: 13.14.0
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_callerid: 39269834
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_calleridname: 39269834
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_callingpres: 0
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_callingani2: 0
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_callington: 0
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_callingtns: 0
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_dnid: unknown
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_rdnis: 547779947
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_context: call-routing
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_extension: 1
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_priority: 29
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_enhanced: 0.0
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_accountcode:
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_threadid: 140621460821760
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_arg_1: en-US
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> agi_arg_2: 5
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >>
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Rx << SET VARIABLE "confidence" "-1"
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> 200 result=1
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Rx << SET VARIABLE "utterance" "-1"
<PJSIP/Cellcom_SIP_Trunk-00000007>AGI Tx >> 200 result=1
-- <PJSIP/Cellcom_SIP_Trunk-00000007>AGI Script speech-recog.agi completed, returning 0
-- Executing [1@call-routing:30] Verbose("PJSIP/Cellcom_SIP_Trunk-00000007", "1,The text you just said is: -1") in new stack
The text you just said is: -1
-- Executing [1@call-routing:31] Verbose("PJSIP/Cellcom_SIP_Trunk-00000007", "1,The probability to be right is: -1") in new stack
The probability to be right is: -1
-- Executing [1@call-routing:32] Hangup("PJSIP/Cellcom_SIP_Trunk-00000007", "") in new stack
== Spawn extension (call-routing, 1, 32) exited non-zero on 'PJSIP/Cellcom_SIP_Trunk-00000007'
how can I debug it to see where it is failed?
Thanks,
Guy
Everything was done according to the instructions (Google API key used). Text pronounced, but voice recording happens.
Something in remembering or I do query format that something is wrong?
-- Executing [1236@for-office:1] Answer("SIP/204-00000003", "") in new stack
-- Executing [1236@for-office:2] AGI("SIP/204-00000003", "googletts.agi,"Please say the number you want to dial.",en") in new stack
-- Launched AGI Script /usr/share/asterisk/agi-bin/googletts.agi
-- Playing '/tmp/2de614b4af8996e92b2fa2be27c25cd4' (escape_digits=) (sample_offset 0)
-- <SIP/204-00000003>AGI Script googletts.agi completed, returning 0
-- Executing [1236@for-office:3] AGI("SIP/204-00000003", "speech-recog.agi,en-US") in new stack
-- Launched AGI Script /usr/share/asterisk/agi-bin/speech-recog.agi
-- <SIP/204-00000003>AGI Script speech-recog.agi completed, returning 0
-- Executing [1236@for-office:4] GotoIf("SIP/204-00000003", "0?success:retry") in new stack
-- Goto (for-office,1236,6)
-- Executing [1236@for-office:6] AGI("SIP/204-00000003", "googletts.agi,"Can you please repeat?",en") in new stack
-- Launched AGI Script /usr/share/asterisk/agi-bin/googletts.agi
-- Playing '/tmp/b70a2b4f0891b80fb0211747e1f0fc78' (escape_digits=) (sample_offset 0)
-- <SIP/204-00000003>AGI Script googletts.agi completed, returning 4
== Spawn extension (for-office, 1236, 6) exited non-zero on 'SIP/204-00000003'
Hello im using your agi into my asterisk but im getting a error on apikey
i generated it on my google developer panel but it says that i dont have permission to use that key
please could you help me to generate a valid one?
I get the error "Unable to get recognition data" and the two variables are set to -1. I know that this means my connection to google was not sucessful, but I tested with this command (curl -X POST --data-binary @'/var/lib/asterisk/sounds/en/hello-world.wav' --header 'Content-Type: audio/l16; rate=8000;' 'https://www.google.com/speech-api/v2/recognize?output=json&lang=en-us&key=*******') and the connection was sucessful.
Here is my CLI output:
I noticed that if the reply from the wolfram api has a " in it that the text to speech with prematurely end. All " should be stripped from the reply.
below is my cli output. may be out of 20 tries it return one result other are blank. there is no error in the agi. please help
*CLI> == Using SIP RTP CoS mark 5
-- Executing [1234@custom:1] Answer("SIP/101-00000000", "") in new stack
> 0x2b03b000e300 -- Probation passed - setting RTP source address to 192.168.1.8:8306
-- Executing [1234@custom:2] NoOp("SIP/101-00000000", "(ulaw)") in new stack
-- Executing [1234@custom:3] AGI("SIP/101-00000000", "speech-recog.agi,en-US") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
-- speech-recog.agi: Clearing channel variables.
-- speech-recog.agi: Command returned: 200 result=1
-- speech-recog.agi: Command returned: 200 result=1
-- speech-recog.agi: Found speexenc in: /usr/local/bin/speexenc
Use of uninitialized value in length at /var/lib/asterisk/agi-bin/speech-recog.agi line 172, line 24.
Use of uninitialized value in length at /var/lib/asterisk/agi-bin/speech-recog.agi line 184, line 24.
Use of uninitialized value in length at /var/lib/asterisk/agi-bin/speech-recog.agi line 189, line 24.
-- speech-recog.agi: Checking channel status.
-- speech-recog.agi: Command returned: 200 result=6
-- speech-recog.agi: Command returned: 200 result=1 ((ulaw))
-- <SIP/101-00000000> Playing 'beep.slin' (language 'en')
-- speech-recog.agi: Command returned: 200 result=35 (dtmf) endpos=15200
-- speech-recog.agi: Recording Format: sln, Rate: 8000 Hz, Encoding format: speex
-- speech-recog.agi: Languge: en-US, SSL: no, s=2, Interrupt keys: #
-- speech-recog.agi: The response was:
{"result":[]}
Use of uninitialized value in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 290.
-- speech-recog.agi: Setting variable: utterance =
Use of uninitialized value in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 291.
-- speech-recog.agi: Command returned: 200 result=1
Use of uninitialized value in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 290, line 28.
-- speech-recog.agi: Setting variable: confidence =
Use of uninitialized value in concatenation (.) or string at /var/lib/asterisk/agi-bin/speech-recog.agi line 291, line 28.
-- speech-recog.agi: Command returned: 200 result=1
-- speech-recog.agi: Cleaning temp files.
-- <SIP/101-00000000>AGI Script speech-recog.agi completed, returning 0
-- Executing [1234@custom:4] Verbose("SIP/101-00000000", "1,The text you just said is: ") in new stack
The text you just said is:
-- Executing [1234@custom:5] Verbose("SIP/101-00000000", "1,The probability to be right is: ") in new stack
The probability to be right is:
-- Executing [1234@custom:6] Hangup("SIP/101-00000000", "") in new stack
== Spawn extension (custom, 1234, 6) exited non-zero on 'SIP/101-00000000'
Hi i have take a look to new way to use google API, and installed key of type server on script
Debug on
-- Executing [s@astricon-asr:3] AGI("SIP/201-00000013", "speech-recog-tiny.agi,en-US") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog-tiny.agi
<SIP/201-00000013>AGI Tx >> agi_request: speech-recog-tiny.agi
<SIP/201-00000013>AGI Tx >> agi_channel: SIP/201-00000013
<SIP/201-00000013>AGI Tx >> agi_language: en
<SIP/201-00000013>AGI Tx >> agi_type: SIP
<SIP/201-00000013>AGI Tx >> agi_uniqueid: 1443891594.50
<SIP/201-00000013>AGI Tx >> agi_version: 13.5.0
<SIP/201-00000013>AGI Tx >> agi_callerid: 201
<SIP/201-00000013>AGI Tx >> agi_calleridname: unknown
<SIP/201-00000013>AGI Tx >> agi_callingpres: 0
<SIP/201-00000013>AGI Tx >> agi_callingani2: 0
<SIP/201-00000013>AGI Tx >> agi_callington: 0
<SIP/201-00000013>AGI Tx >> agi_callingtns: 0
<SIP/201-00000013>AGI Tx >> agi_dnid: 667
<SIP/201-00000013>AGI Tx >> agi_rdnis: unknown
<SIP/201-00000013>AGI Tx >> agi_context: astricon-asr
<SIP/201-00000013>AGI Tx >> agi_extension: s
<SIP/201-00000013>AGI Tx >> agi_priority: 3
<SIP/201-00000013>AGI Tx >> agi_enhanced: 0.0
<SIP/201-00000013>AGI Tx >> agi_accountcode:
<SIP/201-00000013>AGI Tx >> agi_threadid: -1231666144
<SIP/201-00000013>AGI Tx >> agi_arg_1: en-US
<SIP/201-00000013>AGI Tx >>
-- <SIP/201-00000013>AGI Script speech-recog-tiny.agi completed, returning 0
But always getting this error?
Any idea?
thank you.
perl /var/lib/asterisk/agi-bin/cli/speech-recog-cli.pl -k <API_KEY> /tmp/some.flac it give me a error .Failed to get data for file: /tmp/some. flac
I tried to make a call and I got :
-- Launched AGI Script /var/lib/asterisk/agi-bin/speech-recog.agi
-- <SIP/ongo_123-000002ee> Playing 'beep.slin' (language 'en')
-- speech-recog.agi,en-US: Unable to get recognition data.
-- <SIP/ongo_123-000002ee>AGI Script speech-recog.agi completed, returning 0
and return the recognized voice as ( -1 )
Note: I'm a beginner in the field it would be better if explained in an easy way 😅
Hi all,
where does the file store?
kind regards
Hi
I am trying to use this but keep on getting error -1 no speech data. I have looked at debugging but can't pin point the issue. Your other plugin is working a treat (text to speech).
Any pointers would be great, all the recording files etc playback fine. Sample rate looks good too.
Thanks
Chris.
Hi.
I can not find where and how is using $silence.
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.