USAN / res_speech_gdfe

Asterisk speech driver for Google Dialogflow
GNU General Public License v2.0
16 stars 12 forks source link

Disconnects at SpeechBackground() #30

Open vishalknishad opened 5 years ago

vishalknishad commented 5 years ago

I'm not able use it as per documentation. A simple example would be highly appreciated.

Here is my extensions.conf

[globals]

[dialogflow]
exten => _[a-z0-9].,1,NoOp(Dialogflow)
 same =>   n,Answer
 same =>   n,SpeechCreate()
 same =>   n,Set(SPEECH_ENGINE(project_id)=test-rrklnk)
 same =>   n,Set(SPEECH_ENGINE(session_id)=${UNIQUEID})
 same =>   n,Set(SPEECH_ENGINE(language)=${CHANNEL(language)})
 same =>   n(clear_prompt),Set(PROMPT=) 
 same =>   n,Goto(dialogflow-loop,${EXTEN},start)

[dialogflow-loop]
exten => _[a-z0-9].,1(start),NoOp(Dialogflow Loop Start)
 same =>   n,SpeechBackground(hello-world)
 same =>   n,GoSub(dialogflow-process-results,${EXTEN},start)
 same =>   n,Hangup

[dialogflow-process-results]
exten => _[a-z0-9].,1(start),NoOp(Got ${SPEECH(results)} results)
 same =>   n,Set(PROMPT=)
 same =>   n,Set(i=0)
 same =>   n(process-results),Set(GRAMMAR=${SPEECH_GRAMMAR(${i})})
 same =>   n,Set(VALUE=${SPEECH_TEXT(${i})})
 same =>   n(checkfortransfer),GotoIf($["${GRAMMAR}"=~"transfer_call"=0]?checkforaudio)
 same =>   n,Set(TRANSFER=${VALUE})
 same =>   n(checkforaudio),GotoIf($["${GRAMMAR}"!="fulfillment_audio"]?increment)
 ; prompt is everything but .wav
 same =>   n,Set(PROMPT="${VALUE:0:-4}")
 same =>   n,Set(PROMPTFULLNAME="${VALUE}")
 same =>   n(increment),Set(i=$[${i}+1])
 same =>   n,GotoIf($[${SPEECH(results)}>${i}]?process-results)
 same =>   n,Return()

[dialogflow-transfer]
exten => _[a-z0-9].,1(start),NoOp(Transferring to ${EXTEN})
 same =>   n,GotoIf($[${LEN("${PROMPT}")}=0]?dotransfer)
 same =>   n,Playback(${PROMPT})
 same =>   n(dotransfer),Transfer(${TRANSFER})
 same =>   n,GotoIf($["${TRANSFERSTATUS}"="${FAILURE}"]?transferfailed)
 same =>   n,GotoIf($["${TRANSFERSTATUS}"="${UNSUPPORTED}"]?transferunsupported)
 same =>   n,Hangup ; success!
 same =>   n(transferfailed),Playback(all-circuits-busy-now)
 same =>   n,Hangup
 same =>   n(transferunsupported),Playback(ss-noservice)
 same =>   n,Hangup

asterisk console messages:

  == Using SIP RTP CoS mark 5
       > 0x7fccdc00cf40 -- Strict RTP learning after remote address set to: 192.168.43.1:14758
    -- Executing [888@dialogflow:1] NoOp("SIP/6002-00000074", "Dialogflow") in new stack
    -- Executing [888@dialogflow:2] Answer("SIP/6002-00000074", "") in new stack
[Sep  6 19:07:44] WARNING[30771][C-0000007b]: res_rtp_asterisk.c:7077 ast_rtp_read: RTP Read too short
[Sep  6 19:07:44] WARNING[30771][C-0000007b]: res_rtp_asterisk.c:7077 ast_rtp_read: RTP Read too short
[Sep  6 19:07:44] WARNING[30771][C-0000007b]: res_rtp_asterisk.c:7077 ast_rtp_read: RTP Read too short
[Sep  6 19:07:44] WARNING[30771][C-0000007b]: res_rtp_asterisk.c:7077 ast_rtp_read: RTP Read too short
    -- Executing [888@dialogflow:3] SpeechCreate("SIP/6002-00000074", "") in new stack
    -- Executing [888@dialogflow:4] Set("SIP/6002-00000074", "SPEECH_ENGINE(project_id)=test-rrklnk") in new stack
    -- Executing [888@dialogflow:5] Set("SIP/6002-00000074", "SPEECH_ENGINE(session_id)=1567777064.224") in new stack
    -- Executing [888@dialogflow:6] Set("SIP/6002-00000074", "SPEECH_ENGINE(language)=en") in new stack
    -- Executing [888@dialogflow:7] Set("SIP/6002-00000074", "PROMPT=") in new stack
    -- Executing [888@dialogflow:8] Goto("SIP/6002-00000074", "dialogflow-loop,888,start") in new stack
    -- Goto (dialogflow-loop,888,1)
    -- Executing [888@dialogflow-loop:1] NoOp("SIP/6002-00000074", "Dialogflow Loop Start") in new stack
    -- Executing [888@dialogflow-loop:2] SpeechBackground("SIP/6002-00000074", "hello-world") in new stack
  == Spawn extension (dialogflow-loop, 888, 2) exited non-zero on 'SIP/6002-00000074'
DanDanN00dle commented 4 years ago

A hangup at the SpeechBackground application is most likely caused by some failure to initialize the speech driver for dialogflow. Any warnings or errors should be in the full log.

Can you post the relevant portions of your full log?

vishalknishad commented 4 years ago

here are portions from full log

[Sep 12 18:55:01] VERBOSE[12499] loader.c: Loading res_speech_gdfe.so.
[Sep 12 18:55:01] DEBUG[12499] config.c: Parsing /etc/asterisk/res_speech_gdfe.conf
[Sep 12 18:55:01] DEBUG[12499] res_speech_gdfe.c: Loading service key data from /etc/asterisk/svc_key.json
[Sep 12 18:55:01] VERBOSE[12499] res_speech.c: Registered speech recognition engine 'GoogleDFE'
[Sep 12 18:55:01] VERBOSE[12499] res_speech.c: Made 'GoogleDFE' the default speech recognition engine
[Sep 12 18:55:01] VERBOSE[12499] loader.c: res_speech_gdfe.so => (Google DialogFlow for Enterprise (DFE) Speech Engine)
[Sep 12 18:55:01] VERBOSE[12499] loader.c: Loading app_speech_utils.so.
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechCreate'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechLoadGrammar'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechUnloadGrammar'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechActivateGrammar'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechDeactivateGrammar'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechStart'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechBackground'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechDestroy'
[Sep 12 18:55:01] VERBOSE[12499] pbx_app.c: Registered application 'SpeechProcessingSound'
[Sep 12 18:55:01] VERBOSE[12499] pbx_functions.c: Registered custom function 'SPEECH'
[Sep 12 18:55:01] VERBOSE[12499] pbx_functions.c: Registered custom function 'SPEECH_SCORE'
[Sep 12 18:55:01] VERBOSE[12499] pbx_functions.c: Registered custom function 'SPEECH_TEXT'
[Sep 12 18:55:01] VERBOSE[12499] pbx_functions.c: Registered custom function 'SPEECH_GRAMMAR'
[Sep 12 18:55:01] VERBOSE[12499] pbx_functions.c: Registered custom function 'SPEECH_ENGINE'
[Sep 12 18:55:01] VERBOSE[12499] pbx_functions.c: Registered custom function 'SPEECH_RESULTS_TYPE'
[Sep 12 18:55:01] VERBOSE[12499] loader.c: app_speech_utils.so => (Dialplan Speech Applications)
[Sep 12 18:55:01] VERBOSE[12499] loader.c: Loading res_metering.so.
[Sep 12 18:55:01] WARNING[12499] res_metering.c: Configuration not found, using defaults
[Sep 12 18:55:01] DEBUG[12499] res_metering.c: Scheduled first metric event 298277ms from now
[Sep 12 18:55:01] VERBOSE[12499] loader.c: res_metering.so => (Usage metric tracking)
[Sep 12 18:55:01] VERBOSE[12499] loader.c: Loading func_pjsip_endpoint.so.
[Sep 12 18:55:01] VERBOSE[12499] pbx_functions.c: Registered custom function 'PJSIP_ENDPOINT'
[Sep 12 18:55:01] VERBOSE[12499] loader.c: func_pjsip_endpoint.so => (Get information about a PJSIP endpoint)
[Sep 12 18:55:01] VERBOSE[12499] loader.c: Loading res_pjsip_endpoint_identifier_anonymous.so.
[Sep 12 18:55:01] DEBUG[12499] res_pjsip.c: Register endpoint identifier anonymous(0x7ff9906e7180)
[Sep 12 18:55:01] VERBOSE[12499] loader.c: res_pjsip_endpoint_identifier_anonymous.so => (PJSIP Anonymous endpoint identifier)
[Sep 12 18:55:01] VERBOSE[12499] loader.c: Loading app_queue.so.
[Sep 12 18:55:01] DEBUG[12499] config.c: Parsing /etc/asterisk/queuerules.conf
DanDanN00dle commented 4 years ago

The interesting things probably happened around the time of your call and the hangup. Can you share that part of the full log?

vishalknishad commented 4 years ago

Hi, I've attached complete log.

full: https://gist.github.com/vishalknishad/d52d2bd3a8be6793857e3c0cea466c08 extensions.conf: https://gist.github.com/vishalknishad/eb475d759666335363be43401c4b6c6a

Thanks for the help.

DanDanN00dle commented 4 years ago

Looking at the SpeechBackground application there are several scenarios where it will silently fail to start. The most likely based on your logs is that the channel's input audio is not the requested codec (I don't see that it will attempt to transcode). Can you try setting the codec for your call to ulaw only?