About

Play while doing speech recognition. Result is stored in the [[Variable_detect_speech_result | detect_speech_result]] channel variable.

 

Usage

<file> detect:<engine>[:<mrcp_profile>] {param1=val1,param2=val2}<grammar>

Parameters

Channel Variables

Examples

TouchTone Digit Detection

If the caller presses '2' during the playback of a prompt file or a say TTS command, the result will be returned in detect_speech_result as "DIGIT: 2" and in playback_terminator_used as "2".

TTS in XML Dialplan

This example demonstrates using TTS and speech recognition with mod_unimrcp.

<extension name="play_and_detect_speech example">
  <condition field="destination_number" expression="^(1888)$">
    <action application="set" data="tts_engine=unimrcp"/>
    <action application="set" data="tts_voice=donna"/>
    <action application="play_and_detect_speech" data="say:please say yes or no. please say no or yes. please say something! detect:unimrcp {start-input-timers=false,no-input-timeout=5000,recognition-timeout=5000}builtin:grammar/boolean?language=en-US;y=1;n=2"/> 
    <action application="log" data="CRIT ${detect_speech_result}"/>
  </condition>
</extension>

 

UNIMRCP

This example demonstrates playing a wav file and speech recognition with mod_unimrcp.

Note: There is no space between wav and detect. As of 25 Apr 2012, any amount of whitespace is allowed between the wav file and "detect:".

<extension name="play_and_detect_speech example">
  <condition field="destination_number" expression="^(1888)$">
    <action application="set" data="tts_engine=unimrcp"/>
    <action application="set" data="tts_voice=donna"/>
    <action application="play_and_detect_speech" data="ivr/say_yes_or_no.wavdetect:unimrcp {start-input-timers=false,no-input-timeout=5000,recognition-timeout=5000}builtin:grammar/boolean?language=en-US;y=1;n=2"/> 
    <action application="log" data="CRIT ${detect_speech_result}"/>
  </condition>
</extension>

Lua

This example Lua script uses mod_unimrcp and Lumenvox

session:answer()
session:sleep(1000)

-- MRCP ASR and TTS - module picks grammar name
session:execute("play_and_detect_speech","say:unimrcp:Chris:What is your phone number? detect:unimrcp {start-input-timers=false,define-grammar=true,no-input-timeout=5000}builtin:grammar/phone")
local xml = session:getVariable('detect_speech_result')
if xml ~= nil then
        freeswitch.consoleLog("INFO", xml .."\n")
else
        freeswitch.consoleLog("INFO", "No result!\n")
end

-- MRCP ASR and TTS - define the grammar name
session:execute("play_and_detect_speech","say:unimrcp:Chris:What is your phone number? detect:unimrcp {name=12345,start-input-timers=false,define-grammar=true,no-input-timeout=5000}builtin:grammar/phone")
local xml = session:getVariable('detect_speech_result')
if xml ~= nil then
        freeswitch.consoleLog("INFO", xml .."\n")
else
        freeswitch.consoleLog("INFO", "No result!\n")
end

-- Repeat, using cached grammar on session (without DEFINE-GRAMMAR).  ASR sessions are re-used and
-- params are sticky so name must be cleared and define-grammar must be set back to false.
session:execute("play_and_detect_speech","say:unimrcp:Chris:What is your phone number? detect:unimrcp {name=,start-input-timers=false,no-input-timeout=5000,define-grammar=false}session:12345")
local xml = session:getVariable('detect_speech_result')
if xml ~= nil then
        freeswitch.consoleLog("INFO", xml .."\n")
else
        freeswitch.consoleLog("INFO", "No result!\n")
end

session:hangup()

See Also