<GetSpeech> element collects caller voice and try to translate to text using a speech recognition engine. When the interpretation is done, Plivo submits that data to the provided ‘action’ URL in an HTTP GET or POST request.
If no voice input is received before timeout,
<GetSpeech> falls through to the next element.
You may optionally nest
<Wait>elements within a
<GetSpeech> element while waiting for voice input. This allows you to read menu options to the caller while letting them say speech at any time.
<GetSpeech> element supports the following attributes that modify its behavior:
|Attribute Name||Allowed Values||Default Value|
||Speech engine to use||pocketsphinx|
||Grammar file to use||none|
||positive integer||5 seconds|
Plivo will pass the following parameters to the ‘action’ URL once the voice input has been captured:
||Grammar used for speech recognition.|
||The interpreted text.|
||Score of interpretation.
If “-1″, intepretation failed.
If 99, it’s really good.
About speech engine and grammar file
Currently, only pocketsphinx is supported.
You must create your own grammar files (JSGF v1.04 format) and put them in your freeswitch install directory (eg. /usr/local/freeswitch/grammar/).
For example :
- Download pizza_yesno grammar file : pizza_yesno.gram
- Copy pizza_yesno.gram to /usr/local/freeswitch/grammar/
Example 1: Action/method and nested
After the caller say something, Plivo sends him in a request to the ‘action’ URL. We also add a nested
<Speak> element. This means that voice input can be gathered at any time during
1 2 3 4 5 6 7 8 9
<?xml version="1.0" encoding="UTF-8"?> <Response> <GetSpeech action="http://www.foo.com/process_gather.php" method="GET" engine="pocketsphinx" grammar="pizza_yesno" timeout="20"> <Speak> Do you want a pizza ? </Speak> </GetSpeech> <Speak>Input not received. Bye bye!</Speak> </Response>
<GetSpeech>engine recognized voice input (yes or no, …), it will submit the result to action URL.
<GetSpeech>tag times out without voice input, the
<GetSpeech>element will exit without submitting. Plivo will then process the next element in the document, which in this case is a
<Speak>element which informs the caller that no input was received.