Grammar example for Freeswitch

398 views
Skip to first unread message

Wilmar Pérez

unread,
Nov 11, 2019, 10:29:30 AM11/11/19
to uni...@googlegroups.com
Hi all,

I already asked this question on the FreeSwitch forums but I have not gotten an answer. I am trying to understand how grammar works on FreeSwitch. Would anybody have a pointer to a resource explaining:

- What the expected format is.
- Where the grammar files go
- An example!

This is somehow in reference to this thread:


Thank you!

--------------------------------------------------------
Wilmar Pérez 

Doug Rylaarsdam

unread,
Nov 11, 2019, 12:12:25 PM11/11/19
to UniMRCP
Hi Wilmar,

I don't have a FreeSwitch example to show, but in case you hadn't seen it, there is a guide for getting started with FS and the GSR/GSS plugins: FreeSWITCHGoogleUsageManual.

From experience on other platforms, the builtin:speech/transcribe would be sufficient for getting started with the GSR plugin; a grammar file would not be needed. The transcribe builtin is essentially a directive to the GSR plugin to perform speech-to-text using the Google speech service.  The transcription result would then be returned by the UniMRCP server to the FS client when recognition is complete. The application can then handle the transcription result, via some parsing or natural language processing. There are other recognition options (e.g. context hints) supported by the GSR (see GSR), but the builtin is the basic use case. 

Doug

Wilmar Pérez

unread,
Nov 12, 2019, 5:48:12 PM11/12/19
to uni...@googlegroups.com
Thank you very much Doug for your reply. I actually made my first tests following the manual and it has worked descently well. I was trying to figure out the grammar because I am expecting callers to use some nos standard words and phrases.  

Many thanks again.

Best,

Wilmar

--
You received this message because you are subscribed to the Google Groups "UniMRCP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unimrcp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unimrcp/7b94b621-63c8-48d4-a619-c1ca24bfdda3%40googlegroups.com.


--
--------------------------------------------------------
Wilmar Pérez 

Arsen Chaloyan

unread,
Nov 15, 2019, 6:08:21 PM11/15/19
to UniMRCP
Hi Wilmar,

- What the expected format is.

You may use a subset of SRGS XML with GSR. See this post for more info.

- Where the grammar files go

See this page for supported grammars by mod_unimrcp in FS.

- An example!

Let's say, there is an SRGS grammar in /usr/local/freeswitch/grammars/booking.xml with the following content.

<grammar mode="voice" root="booking" version="1.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/06/grammar">
    <meta name="scope" content="hint"/>
    <rule id="booking">
        <one-of>
            <item> I would like to book a flight from New York to Rome with a ticket eligible for free cancellation</item>
            <item> I would like to book a one-way flight from New York to Rome</item>
        </one-of>
    </rule>
</grammar>

Then you can reference the grammar as follows

<action application="play_and_detect_speech" data=" say: Please say something detect:unimrcp:uni2 {start-input-timers=false} /usr/local/freeswitch/grammars/booking.xml "/>




--
Arsen Chaloyan
Author of UniMRCP
http://www.unimrcp.org

Wilmar Pérez

unread,
Nov 16, 2019, 1:16:10 PM11/16/19
to uni...@googlegroups.com
Hi Arsen,

Fantastic! Thanks so much! This is the best piece of information I have found on the subject!



--
--------------------------------------------------------
Wilmar Pérez 

Wilmar Pérez

unread,
Dec 15, 2019, 3:16:42 PM12/15/19
to uni...@googlegroups.com
Hi Arsen (or anybody that may know)

I have a follow up question on this. I am just testing a grammar file.  I am calling it just as 

<action application="play_and_detect_speech" data=" say: Please say something detect:unimrcp:uni2 {start-input-timers=false} /opt/fsconfigs/grammars/confirm_selection.xml "/>  

However, I am getting this:

[ERR] mod_unimrcp.c:3234 (ASR-192) Could not read grammar file: /opt/fsconfigs/grammars/confirm_selection.xml.gram

So, freeswitch is expecting a gram file. I tried looking for what a gram file should look like but I couldn't really get something clear.  Do you know wha exactly I am missing or what I need to do?

Thanks!


Le ven. 15 nov. 2019 à 18:08, Arsen Chaloyan <acha...@gmail.com> a écrit :


--
--------------------------------------------------------
Wilmar Pérez 

Arsen Chaloyan

unread,
Dec 20, 2019, 8:25:04 PM12/20/19
to UniMRCP
Hi Wilmar,

Sorry, the provided example does not seem to be entirely correct. I think you may need to explicitly specify the prefix file://, otherwise FS would implicitly append an extension "gram" to the file path/name specified in the command.

Can you try the following

<action application="play_and_detect_speech" data=" say: Please say something detect:unimrcp:uni2 {start-input-timers=false} file:///opt/fsconfigs/grammars/confirm_selection.xml "/>

Alternatively, you may also use a path without an extension referenced by the command. In this case, the grammar file on the filesystem is supposed to have the extension "gram".

<action application="play_and_detect_speech" data=" say: Please say something detect:unimrcp:uni2 {start-input-timers=false} /opt/fsconfigs/grammars/confirm_selection"/>






Reply all
Reply to author
Forward
0 new messages