Powered by Universal Speech Solutions LLC

 MRCP

Asterisk

Google SR and SS

Usage Guide

 

Revision: 4

Created: June 22, 2017

Last updated: March 31, 2020

Author: Arsen Chaloyan


 

Table of Contents

 

1  Overview.. 4

1.1         Applicable Versions. 4

2  Generic Speech Recognition API 5

2.1         Overview.. 5

2.2         Configuration Steps. 5

2.3         Usage Examples. 5

3  Suite of UniMRCP Applications. 8

3.1         Overview.. 8

3.2         Configuration Steps. 8

3.3         Usage Examples. 9

MRCPRecog. 9

MRCPSynth. 10

SynthAndRecog. 11

 

 


1       Overview

This guide describes how to utilize the Google Cloud Speech services with Asterisk.

 

H

 

Note that the Asterisk and the UniMRCP server typically reside on different hosts in a LAN, although both might be installed on the same host.

 

Installation of the Asterisk and the UniMRCP server with the Google SR and SS plugins is not covered in this document. Visit the corresponding web pages for more information.

 

http://unimrcp.org/asterisk

http://unimrcp.org/gsr

http://unimrcp.org/gss

 

1.1      Applicable Versions

Instructions provided in this guide are applicable to the following versions.

 

UniMRCP Modules for Asterisk 1.5.0 and above

UniMRCP GSR Plugin 1.1.0 and above

UniMRCP GSS Plugin 1.0.0 and above

 

2       Generic Speech Recognition API

2.1      Overview

The module res_speech_unimrcp.so provides an implementation of the Generic Speech Recognition API of Asterisk, based on the UniMRCP client library.

2.2      Configuration Steps

This section outlines major configuration steps required for use of the module res_speech_unimrcp.so with the UniMRCP server.

 

Check the name of the profile, referenced in the configuration file res-speech-unimrcp.conf, which is located in the configuration directory of Asterisk. Use uni2 for MRCPv2, and uni1 for MRCPv1.

 

[general]

unimrcp-profile = uni2      ; UniMRCP MRCPv2 Server

; unimrcp-profile = uni1    ; UniMRCP MRCPv1 Server

 

Open the configuration file unimrcpclient.xml, located in the configuration directory of UniMRCP and specify IP addresses of the client and the server. In the following example, the Asterisk/UniMRCP client is located on 10.0.0.1 and the UniMRCP server is on 10.0.0.2.

 

<properties>

<!--  <ip type="auto"/> -->

 

<ip>10.0.0.1</ip>

<server-ip>10.0.0.2</server-ip>

</properties>

 

2.3      Usage Examples

Built-in Speech Context

Make use of a built-in speech grammar transcribe for recognition, having no speech contexts defined, by adding the following entries in the Asterisk configuration file extensions.conf.

 

[res-speech-unimrcp-1]

exten => s,1,Answer()

exten => s,2,SpeechCreate()

exten => s,3,SpeechActivateGrammar(builtin:speech/transcribe)

exten => s,4,SpeechBackground(beep, 20)

exten => s,5,Verbose(1, "Recognition result count: ${SPEECH(results)}")

exten => s,6,GotoIf($["${SPEECH(results)}" = "0"]?7:9)

exten => s,7,Playback(error)

exten => s,8,Goto(3)

exten => s,9,Verbose(1, "Recognition result: ${SPEECH_TEXT(0)}, confidence score: ${SPEECH_SCORE(0)}, grammar-uri: ${SPEECH_GRAMMAR(0)}")

exten => s,10,SpeechDestroy()

exten => s,11,Hangup()

 

In the Asterisk dialplan, associate the provided sample to an extension, for example, 701.

 

exten => 701,1,Goto(res-speech-unimrcp-1,s,1)

 

Place a test call and make sure recognition works as expected.

Dynamic Speech Context

Dynamically load a speech context for recognition, by adding the following entries in the Asterisk configuration file extensions.conf.

 

[res-speech-unimrcp-2]

exten => s,1,Answer()

exten => s,2,SpeechCreate()

exten => s,3,SpeechLoadGrammar(directory,application/xml:/usr/local/unimrcp/data/directory.xml)

exten => s,4,SpeechActivateGrammar(directory)

exten => s,5,SpeechBackground(beep, 20)

exten => s,6,Verbose(1, "Recognition result count: ${SPEECH(results)}")

exten => s,7,GotoIf($["${SPEECH(results)}" = "0"]?8:10)

exten => s,8,Playback(error)

exten => s,9,Goto(5)

exten => s,10,Verbose(1, "Recognition result: ${SPEECH_TEXT(0)}, confidence score: ${SPEECH_SCORE(0)}, grammar-uri: ${SPEECH_GRAMMAR(0)}")

exten => s,11,SpeechDestroy()

exten => s,12,Hangup()

 

In this example, the speech context is loaded from a file located at /usr/local/unimrcp/directory.xml and having the following sample content.

 

<speech-context>

  <phrase>call Steve</phrase>

  <phrase>call John</phrase>

  <phrase>dial 5</phrase>

  <phrase>dial 6</phrase>

</speech-context>

 

In the Asterisk dialplan, associate the provided sample to an extension, for example, 702.

 

exten => 702,1,Goto(res-speech-unimrcp-2,s,1)

 

Place a test call and make sure recognition works as expected.

3       Suite of UniMRCP Applications

3.1      Overview

The module app_unimrcp.so provides a suite of speech recognition and synthesis applications for Asterisk.

3.2      Configuration Steps

This section outlines major configuration steps required for use of the module app_unimrcp.so with the UniMRCP server.

 

Open the configuration file mrcp.conf, located in the configuration directory of Asterisk, and add two profiles for MRCPv2 and MRCPv1 respectively. In the following example, the Asterisk/UniMRCP client is located on 10.0.0.1 and the UniMRCP server is on 10.0.0.2.

 

[uni2]

; MRCP settings

version = 2

;

; SIP settings

server-ip = 10.0.0.2

server-port = 8060

; SIP user agent

client-ip = 10.0.0.1

client-port = 25097

sip-transport = udp

;

; RTP factory

rtp-ip = 10.0.0.1

rtp-port-min = 28000

rtp-port-max = 29000

;

; Jitter buffer settings

playout-delay = 50

max-playout-delay = 200

; RTP settings

ptime = 20

codecs = PCMU PCMA L16/96/8000 telephone-event/101/8000

; RTCP settings

rtcp = 0

 

 

[uni1]

; MRCP settings

version = 1

;

; RTSP settings

server-ip = 10.0.0.2

server-port = 1554

resource-location = media

speechsynth = speechsynthesizer

speechrecog = speechrecognizer

;

; RTP factory

rtp-ip = 10.0.0.1

rtp-port-min = 27000

rtp-port-max = 28000

;

; Jitter buffer settings

playout-delay = 50

max-playout-delay = 200

; RTP settings

ptime = 20

codecs = PCMU PCMA L16/96/8000 telephone-event/101/8000

; RTCP settings

rtcp = 0

 

3.3      Usage Examples

MRCPRecog

Built-in Speech Context

Make use of a built-in speech grammar transcribe for recognition, having no speech contexts defined, by adding the following entries in the Asterisk configuration file extensions.conf.

 

[app-unimrcp-1]

exten => s,1,Answer

exten => s,2,MRCPRecog("builtin:speech/transcribe", spl=en-US&f=beep&p=uni2)

exten => s,3,Goto(mrcprecog-output,s,1)

 

Note the macro mrcprecog-output, used in the example above, is defined in the file mrcp_sample_apps.conf.

 

In the Asterisk dialplan, associate the provided sample to an extension, for example, 801.

 

exten => 801,1,Goto(app-unimrcp-1,s,1)

 

Place a test call and make sure recognition works as expected.

Dynamic Speech Context

Dynamically load a speech context for recognition, by adding the following entries in the Asterisk configuration file extensions.conf.

 

[app-unimrcp-2]

exten => s,1,Answer

exten => s,2,MRCPRecog("/usr/local/unimrcp/data/directory.xml", spl=en-US&f=beep&p=uni2)

exten => s,3,Goto(mrcprecog-output,s,1)

 

In this example, the speech context is loaded from a file located at /usr/local/unimrcp/directory.xml and having the following sample content.

 

<speech-context>

  <phrase>call Steve</phrase>

  <phrase>call John</phrase>

  <phrase>dial 5</phrase>

  <phrase>dial 6</phrase>

</speech-context>

 

In the Asterisk dialplan, associate the provided sample to an extension, for example, 802.

 

exten => 802,1,Goto(app-unimrcp-2,s,1)

 

Place a test call and make sure recognition works as expected.

MRCPSynth

Use the application MRCPSynth for speech synthesis.

 

[app-unimrcp-2]

exten => s,1,Answer

exten => s,2,MRCPSynth(Welcome to Asterisk,l=en-US&p=uni2)

 

In the Asterisk dialplan, associate the provided sample to an extension, for example, 802.

 

exten => 802,1,Goto(app-unimrcp-2,s,1)

 

Place a test call and listen to the synthesized message.

SynthAndRecog

Use the application SynthAndRecog for speech synthesis and recognition.

 

[app-unimrcp-3]

exten => s,1,Answer

exten => s,2, SynthAndRecog(Please say something,builtin:speech/transcribe, spl=en-US&p=uni2)

exten => s,3,Goto(mrcprecog-output,s,1)

 

In the Asterisk dialplan, associate the provided sample to an extension, for example, 803.

 

exten => 803,1,Goto(app-unimrcp-3,s,1)

 

Place a test call and listen to the synthesized prompt and say something. Make sure recognition works as expected.