unispeech / asterisk-unimrcp

UniMRCP modules for Asterisk
http://www.unimrcp.org/asterisk
GNU General Public License v2.0
48 stars 35 forks source link

MRCPRecog fails to parse grammar url because it contains a JSON payload. #59

Open sombat-net opened 1 year ago

sombat-net commented 1 year ago

Hi guys. It's possible that the grammar url contains a json payload; I'm trying, but MRCPRecog application sends the wrong grammar url (comma sepalator issue).

example grammar url. builtin:speech/transcribe?method=Execute;user-id=1234;model-uri=urn:nuance-mix:tag:model/xxxxxx/mix.dialog;selector-channel=IVRchannel;language=th-TH;start-request-payload-json={"selector":{"channel":"IVRchannel","language":"th-TH","library":"default"},"payload":{"data":{"userData":{"timezone":"America/Cancun","userGlobalID":"123123123","userChannelID":"163.128.3.254","userAuxiliaryID":"7319434000843499","systemID":"4561 9219 9923","location":{"latitude":"21.161908","longitude":"-86.8515279"}},"preferred_coffee":"espresso","user_name":"Miranda"}}}

Erro logs.

-- Executing [9999@nuance_dlg:1] Answer("SIP/1111-00000058", "") in new stack
-- Executing [9999@nuance_dlg:2] Set("SIP/1111-00000058", "grammar_file=builtin:speech/transcribe?method=Execute;user-id=126673;model-uri=urn:nuance-mix:tag:model/xxxx/mix.dialog;selector-channel=IVRchannel;language=th-TH;start-request-payload-json={"selector":{"channel":"IVRchannel","language":"th-TH","library":"default"},"payload":{"data":{"userData":{"timezone":"America/Cancun","userGlobalID":"123123123","userChannelID":"163.128.3.254","userAuxiliaryID":"7319434000843499","systemID":"4561 9219 9923","location":{"latitude":"21.161908","longitude":"-86.8515279"}},"preferred_coffee":"espresso","user_name":"Miranda"}}}") in new stack
-- Executing [9999@nuance_dlg:3] MRCPRecog("SIP/1111-00000058", "builtin:speech/transcribe?method=Execute;user-id=126673;model-uri=urn:nuance-mix:tag:model/xxxx/mix.dialog;selector-channel=IVRchannel;language=th-TH;start-request-payload-json={"selector":{"channel":"IVRchannel","language":"th-TH","library":"default"},"payload":{"data":{"userData":{"timezone":"America/Cancun","userGlobalID":"123123123","userChannelID":"163.128.3.254","userAuxiliaryID":"7319434000843499","systemID":"4561 9219 9923","location":{"latitude":"21.161908","longitude":"-86.8515279"}},"preferred_coffee":"espresso","user_name":"Miranda"}}},t=10000&b=0&nit=8000&sint=900&sl=0.8&rm=normal&spl=th-TH&sw=true&plt=1&vsp=") in new stack

[Jul 18 11:32:31] NOTICE[440][C-00000060]: app_mrcprecog.c:1092 app_recog_exec: MRCPRecog() grammar: builtin:speech/transcribe?method=Execute;user-id=126673;model-uri=urn:nuance-mix:tag:model/xxxx/mix.dialog;selector-channel=IVRchannel;language=th-TH;start-request-payload-json={selector:{channel:IVRchannel [Jul 18 11:32:31] NOTICE[440][C-00000060]: app_mrcprecog.c:1107 app_recog_exec: MRCPRecog() options: "language":"th-TH","library":"default"},"payload":{"data":{"userData":{"timezone":"America/Cancun","userGlobalID":"123123123","userChannelID":"163.128.3.254","userAuxiliaryID":"7319434000843499","systemID":"4561 9219 9923","location":{"latitude":"21.161908","longitude":"-86.8515279"}},"preferred_coffee":"espresso","user_name":"Miranda"}}},t=10000&b=0&nit=8000&sint=900&sl=0.8&rm=normal&spl=th-TH&sw=true&plt=1&vsp= [Jul 18 11:32:31] WARNING[440][C-00000060]: app_mrcprecog.c:955 mrcprecog_option_apply: Unknown option: "language":"th-TH","library":"default"},"payload":{"data":{"userData":{"timezone":"America/Cancun","userGlobalID":"123123123","userChannelID":"163.128.3.254","userAuxiliaryID":"7319434000843499","systemID":"4561 9219 9923","location":{"latitude":"21.161908","longitude":"-86.8515279"}},"preferred_coffee":"espresso","user_name":"Miranda"}}},t [Jul 18 11:32:31] NOTICE[440][C-00000060]: src/mrcp_application.c:117 Create MRCP Handle 0x7f3570015d08 [ums2] [Jul 18 11:32:31] NOTICE[440][C-00000060]: src/mrcp_client_session.c:131 Create Channel ASR-176 [Jul 18 11:32:31] NOTICE[53]: src/mrcp_client_session.c:385 Receive App Request ASR-176 [2] [Jul 18 11:32:31] NOTICE[53]: src/mrcp_client.c:697 Add MRCP Handle ASR-176 [Jul 18 11:32:31] NOTICE[53]: src/mrcp_client_session.c:717 Add Control Channel ASR-176 new@speechrecog [Jul 18 11:32:31] NOTICE[53]: src/mrcp_client_session.c:409 Send Offer ASR-176 [c:1 a:1 v:0] to 10.10.10.115:8060 [Jul 18 11:32:31] NOTICE[53]: src/mrcp_sofiasip_client_agent.c:357 Local SDP ASR-176

Thank you.

achaloyan commented 1 year ago

Hi @sombat-net

You would need to escape double quotes in the JSON data to allow MRCPRecog to properly parse the arguments. For example

{\"selector\":{\"channel\"