[UniMRCP] Asterisk 1.6 UniMRCP and PocketSphinx

169 views
Skip to first unread message

Seann

unread,
May 12, 2010, 1:42:21 AM5/12/10
to UniMRCP
All,

I have successfully built and configured my uniMRCP build, but I
am having grammar load failures with PocketSphinx, that I am not sure
what I am doing wrong as there isn't really much in the way online
that I have found during hours of searching that says the 'right' way
to set up PocketSphinx, and the grammars for it. I got Cepstral and
Flite working no problem though. My error output looks like this:

2010-05-12 00:31:29:364416 [DEBUG] Process MRCPv2 Message
2010-05-12 00:31:29:364482 [INFO] Receive MRCPv2 Stream
192.168.10.9:1544 <-> 192.168.10.9:38662 [227 bytes]
MRCP/2.0 227 DEFINE-GRAMMAR 2
Channel-Identifier: a291f23018aa478a@speechrecog
Content-Type: application/x-jsgf
Content-Id: digit
Content-Length: 71

#JSGF V1.0;
grammar digits;
public <numbers> = (one | two | three);

2010-05-12 00:31:29:364541 [DEBUG] Parsed MRCP Message [227]
2010-05-12 00:31:29:364568 [DEBUG] Signal Connection Task Message
2010-05-12 00:31:29:364650 [DEBUG] Receive Connection Task Message
[3]
2010-05-12 00:31:29:364703 [DEBUG] Dispatch Signaling Message [1]
2010-05-12 00:31:29:364724 [INFO] Process DEFINE-GRAMMAR Request [2]
2010-05-12 00:31:29:364751 [DEBUG] Wait for Task Messages [MRCP
Server]
2010-05-12 00:31:29:364778 [INFO] Dispatch Request DEFINE-GRAMMAR
<a291f23018aa478a@pocketsphinx>
2010-05-12 00:31:29:364806 [INFO] Create Grammar File [/usr/local/
unimrcp/data/a291f23018aa478a-digit.gram]
<a291f23018aa478a@pocketsphinx>
2010-05-12 00:31:29:386435 [DEBUG] Init Config rate [8000] dictionary
[/usr/local/unimrcp/data/default.dic] <a291f23018aa478a@pocketsphinx>
2010-05-12 00:31:29:402147 [INFO] Init Decoder
<a291f23018aa478a@pocketsphinx>

==> /var/log/asterisk/messages <==
[May 12 00:31:29] NOTICE[18817] res_speech_unimrcp.c: Created speech
instance 'a291f23018aa478a'
[May 12 00:31:29] NOTICE[18817] res_speech_unimrcp.c: Load grammar
name:digit type:application/x-jsgf path:/usr/local/unimrcp/data/
grammar.jsgf 'a291f23018aa478a'

==> /usr/local/unimrcp/log/unimrcpserver-0.log <==
2010-05-12 00:31:32:095068 [WARN] Failed to Init Decoder
<a291f23018aa478a@pocketsphinx>
2010-05-12 00:31:32:095216 [DEBUG] Signal Engine Task Message
2010-05-12 00:31:32:095248 [DEBUG] Wait for incoming messages
<a291f23018aa478a@pocketsphinx>
2010-05-12 00:31:32:095259 [DEBUG] Receive Engine Task Message [2]
2010-05-12 00:31:32:095290 [INFO] Process DEFINE-GRAMMAR Response
[2]
2010-05-12 00:31:32:095320 [DEBUG] Wait for Task Messages [MRCP
Server]
2010-05-12 00:31:32:095333 [DEBUG] Process Control Message
2010-05-12 00:31:32:095381 [INFO] Send MRCPv2 Stream
192.168.10.9:1544 <-> 192.168.10.9:38662 [125 bytes]
MRCP/2.0 125 2 407 COMPLETE
Channel-Identifier: a291f23018aa478a@speechrecog
Completion-Cause: 004 grammar-load-failure

Config Files reference:

exten => 1234,1,Answer()
exten => 1234,2,SpeechCreate()
exten => 1234,3,SpeechLoadGrammar(digit,/usr/local/unimrcp/data/
grammar.jsgf)
exten => 1234,4,SpeechActivateGrammar(digit)
exten => 1234,5,SpeechBackground(hello-world,20)
exten => 1234,6,GotoIf($["${SPEECH(results)}" = "0"]?7:9)
exten => 1234,7,Playback(vm-nonumber)
exten => 1234,8,Goto(5)
exten => 1234,9,Verbose(1,The recognized input is ${SPEECH_TEXT(0)})
exten => 1234,10,Verbose(1,The score is ${SPEECH_SCORE(0)})
exten => 1234,11,Verbose(1,The matched grammar is $
{SPEECH_GRAMMAR(0)})
exten => 1234,12,SpeechDeactivateGrammar(digit)
exten => 1234,13,SpeechUnloadGrammar(digit)
exten => 1234,14,SpeechDestroy()
exten => 1234,15,Hangup()

mrcp.conf: http://asterisk.pastey.net/136362

Grammar file is default from the initial build.




--
You received this message because you are subscribed to the Google Groups "UniMRCP" group.
To post to this group, send email to uni...@googlegroups.com.
To unsubscribe from this group, send email to unimrcp+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/unimrcp?hl=en.

Arsen Chaloyan

unread,
May 12, 2010, 8:21:03 AM5/12/10
to uni...@googlegroups.com
Seann,

You seem to be doing everything right. The issue you have encountered is probably in the line ending. PocketSphinx's JSGF parser unfortunately behaves differently on Windows and Linux. If I'm not mistaken, It accepts both CRLF and LF on Windows, but CRLF fails on Linux.
Assuming you run UniMRCP server on Linux too, "dos2unix grammar.jsgf" should help.
--
Arsen Chaloyan
The author of UniMRCP
http://www.unimrcp.org

Seann

unread,
May 12, 2010, 2:42:54 PM5/12/10
to UniMRCP
That seems to have fixed it. I never even thought of Dos to unix
issues. The only other thing I have issues with is the experimental
MRCP application in Asterisk, the ASR portion, and how to define the
string for PocketSphinx. I just haven't figured out how to define that
correctly.


My dialplan section on that is:

exten => 8290,n,MRCPSynth(welcome to the world of
telecom,p=default&i=any&l=en-US&f=/tmp/synth.raw&v=Robin)
exten => 8290,n,Wait(2)
exten => 8290,n,MRCPRecog(/usr/local/unimrcp/data/
grammar.jsgf,p=default&i=any&t=5000&f=demo-ct&b=1)
exten => 8290,n,Verbose(${RECOG_RESULT})
exten => 8290,n,Wait(2)
exten => 8290,n,MRCPSynth(Going to Generic Speech Recognition
program,p=default&i=any&l=en-US&f=/tmp/synth.raw&v=Allison)
exten => 8290,n,Goto(mrcp,8289,1)
exten => 8290,n,Hangup
> > unimrcp+u...@googlegroups.com<unimrcp%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/unimrcp?hl=en.
>
> --
> Arsen Chaloyan
> The author of UniMRCPhttp://www.unimrcp.org
>
> --
> You received this message because you are subscribed to the Google Groups "UniMRCP" group.
> To post to this group, send email to uni...@googlegroups.com.
> To unsubscribe from this group, send email to unimrcp+u...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/unimrcp?hl=en.

Arsen Chaloyan

unread,
May 13, 2010, 6:18:40 AM5/13/10
to uni...@googlegroups.com
On Wed, May 12, 2010 at 11:42 PM, Seann <nombr...@gmail.com> wrote:
That seems to have fixed it. I never even thought of Dos to unix
issues. The only other thing I have issues with is the experimental
MRCP application in Asterisk, the ASR portion, and how to define the
string for PocketSphinx. I just haven't figured out how to define that
correctly.


My dialplan section on that is:

exten => 8290,n,MRCPSynth(welcome to the world of
telecom,p=default&i=any&l=en-US&f=/tmp/synth.raw&v=Robin)
exten => 8290,n,Wait(2)
exten => 8290,n,MRCPRecog(/usr/local/unimrcp/data/
grammar.jsgf,p=default&i=any&t=5000&f=demo-ct&b=1)

I assume you meant the MRCPRecog command. Anyway, it's not going to work the way you specified.
You should specify JSGF grammar inline as follows
exten => 8290,n,MRCPRecog(#JSGF \;grammar digits\;public <numbers> = (one | two | three)\;,p=default&i=any&t=5000&f=demo-ct&b=1)

However, I've just tried the same myself and surprisingly, this doesn't work the way it should. I'm not sure I fully understand the code fragment below (app_unimrcp.c : 5054), but hopefully Derik can comment on this.


    grammar_type_t tmp_grammar = GRAMMAR_TYPE_UNKNOWN;
    const char *grammar_data = args.grammar;
    if ((text_starts_with(args.grammar, HTTP_ID)) || (text_starts_with(args.grammar, HTTPS_ID)) || (text_starts_with(args.grammar, BUILTIN_ID)) || (text_starts_with(args.grammar, FILE_ID)) || (text_starts_with(args.grammar, SESSION_ID))) {
        tmp_grammar = GRAMMAR_TYPE_URI;
    } else if (text_starts_with(args.grammar, INLINE_ID)) {
        grammar_data = args.grammar + strlen(INLINE_ID);
    } else if (text_starts_with(args.grammar, ABNF_ID)) {
        tmp_grammar = GRAMMAR_TYPE_SRGS;
    } else {
        /* TO DO : Instead of assuming SRGS+XML, assume it is a file and MRCP server can't get to file, so read it and let the content decide the grammar type. */
        tmp_grammar = GRAMMAR_TYPE_SRGS_XML;
    }

The condition below cannot be true to me, considering the code above.

    if (tmp_grammar == GRAMMAR_TYPE_UNKNOWN) {
        if ((text_starts_with(grammar_data, HTTP_ID)) || (text_starts_with(grammar_data, HTTPS_ID)) || (text_starts_with(grammar_data, BUILTIN_ID)) || (text_starts_with(grammar_data, FILE_ID)) || (text_starts_with(grammar_data, SESSION_ID))) {
            tmp_grammar = GRAMMAR_TYPE_URI;
        } else if ((text_starts_with(grammar_data, XML_ID) || (text_starts_with(grammar_data, SRGS_ID)))) {
            tmp_grammar = GRAMMAR_TYPE_SRGS_XML;
        } else if (text_starts_with(grammar_data, GSL_ID)) {
            tmp_grammar = GRAMMAR_TYPE_NUANCE_GSL;
        } else if (text_starts_with(grammar_data, ABNF_ID)) {
            tmp_grammar = GRAMMAR_TYPE_SRGS;
        } else if (text_starts_with(grammar_data, JSGF_ID)) {
            tmp_grammar = GRAMMAR_TYPE_JSGF;
        } else {
            ast_log(LOG_ERROR, "(%s) Unable to determine grammar type: %s\n", schannel->name, grammar_data);
            res = -1;
            speech_channel_stop(schannel);
            speech_channel_destroy(schannel);
            goto done;
        }
    }

    ast_log(LOG_DEBUG, "Grammar type is: %i\n", tmp_grammar);


In other words, MRCPRecog doesn't support JSGF right now. Perhaps it should be straightforward to fix the code.
 
Reply all
Reply to author
Forward
0 new messages