The <GetInput/> Element

This element permit to collect input from the user. Input can be either speech (using Google Speech Services) or DTMF digits.

If no input is received, <GetInput/> falls through to the next element.

You may optionally nest <Play/>, <Speak/> and <Wait/> elements within a <GetInput/> element while waiting for input. This allows you to read menu options to the caller while letting them enter a menu selection at any time. After the first digit or start of talking is detected the audio will stop playing.

Nested elements with purpose="prompt" (default) are used to compose the GetInput prompt.

Nested elements with purpose="alert" are used to compose the "invalid input" prompt.

Element Attributes

Attribute Name Description Allowed values Default Value
action URL to be called when digits/speech is detected. It can be a list of URLs separated by commas to permit fallback. See XML Fetch Fallback This attribute is optional: if absent the processing will proceed to the next XML element.
language language to be detected. Any language supported by Google STT like 'en-US', 'ja-JP' etc none
timeout Timeout for reception of the first digit or start of speech positive integer 5 seconds
speechTimeout Maximum speech duration to collect positive integer 5 seconds
interdigitTimeout Timeout for reception of a subsequent digit when one is received positive integer 5 seconds
finishOnKey Collection terminator 1234567890*# #
numDigits Maximum number of digits to collect integer >= 1 99
validDigits Set of digits the user is allowed to enter 1234567890*# 1234567890*#
maxTries Maximum number of attempts in case no digit/speech is detected integer >= 1 1
playBeep Play beep after all nested audio elements complete true, false false
profanityFilter Instructs GetInput to filter profanities out of your speech transcription. If set to true, GetInput will replace all but the first character in each filtered profane word with asterisks. E.g.: 'f***' true, false false
context Permits to specify a grammar file or list of hints for speech recognition. This will boost accuracy of speech recognition file:// or hints:// url. Ex: "file://some_context.xml.gram" (it must be a XML file ending with ".xml.gram". "hints://support;sales;human resources;the boss" (it must be a list of hints separated by semicolons) none

Speech/Digit Collection Notification Parameters

After speech/digit collection completes, the following parameters will be available.

Parameter Description
SRInput The detected speech or digits
SRMode what kind of input was received: 'speech' or 'dtmf'
SRConfidence A value indicating how confident the speech recognizer engine considered the recognition to be
SRError if an error prevents the Speech Recognition from starting, this will be set with its details
SRCompletionCause Speech Recognition Completion Cause-code as specified in https://tools.ietf.org/html/rfc6787#page-81 (ex: SRCompletionCause=0 means success)

If GetInput@action URL is set, Basix will call it with them. They are also available for inspection using expressions inside the XML document itself.

Obs: these several parameters are just for completeness. For most cases when developing an IVR, it is enough to check if Speech Recognition was successful by using an element If with expr="SRInput" (see examples below).

If action is not set, processing will continue with the next element.

Examples

Example 1: simple

1
2
3
4
5
<IVR>
  <GetInput language="en-US" action="http://www.foo.com/process_detected_speech" timeout="8">
    <Speak voice="en-US-Standard-C">Please say the department you want to be transferred to.</Speak>
  </GetInput>
</IVR>

Example 2: echo test (talks back anything that is detected)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<IVR>
  <GetInput language="ja-JP" timeout="4">
    <Speak voice="ja-JP-Wavenet-B">日本語で何か言ってください</Speak>
  </GetInput>
  <Section name="loop">
    <If expr="SRInput">
      <Then>
        <GetInput language="ja-JP">
          <Speak voice="ja-JP-Wavenet-B">: {{SRInput}}</Speak>
        </GetInput>
      </Then>
      <Else>
        <GetInput language="ja-JP"/>
      </Else>
    </If>
    <GoTo>loop</GoTo>
  </Section>
</IVR>

Example 3: specifying 'input error' prompt (nested elements with purpose="alert")

1
2
3
4
5
6
7
8
9
<IVR>
  <GetInput action="http://www.foo.com/process_gather.php" maxTries="5">
    <Speak voice="en-US-Standard-C">Hi, which is the department you want to talk to?</Speak>
    <Play purpose="alert">wrong_input_buzzer.wav</Play>
    <Wait purpose="alert" length="1"/>
    <Speak purpose="alert" voice="en-US-Standard-C">Sorry. I could not understand what you said.</Speak>
  </GetInput>
  <Speak voice="en-US-Standard-C">Input not received. Bye bye!</Speak>
</IVR>

Example 4: using attribute context with file:// schema pointing to a grammar file

1
2
3
4
5
6
7
8
9
<IVR>
  <GetInput action="http://www.foo.com/process_gather.php" maxTries="5" context="file://some_context.xml.gram">
    <Speak voice="en-US-Standard-C">Hi, which is the department you want to talk to?</Speak>
    <Play purpose="alert">wrong_input_buzzer.wav</Play>
    <Wait purpose="alert" length="1"/>
    <Speak purpose="alert" voice="en-US-Standard-C">Sorry. I could not understand what you said.</Speak>
  </GetInput>
  <Speak voice="en-US-Standard-C">Input not received. Bye bye!</Speak>
</IVR>

Notice the context references a file some_context.xml.gram. This file should have content like this:

1
2
3
4
5
6
<speech-context>
  <phrase>support</phrase>
  <phrase>sales</phrase>
  <phrase>human resources</phrase>
  <phrase>the boss</phrase>
</speech-context>

Example 5: using attribute context with hints:// schema listing hints

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<IVR>
  <Wait length="1"/>
  <GetInput language="ja-JP" timeout="30" context="hints://オレンジ;バナナ;すいか;いちご;レモン;もも;なし;マンゴー;ドリアン;パイナップル;みかん;ぶどう;ほしぶどう;うめ;あんず;アプリコット;サクランボ;チェリー;カキ;イチジク;クリ;ゆず;ざくろ;メロン;グアバ;キウイ;パパイヤ;ココナッツ;りんご;グレープフルーツ;ジャックフルーツ;ブルーベリー;ブラックベリー;きいちご;ラズベリー;アボカド;ライム">
    <Speak voice="ja-JP-Wavenet-B">あなたが一番好きな果物はどれですか?</Speak>
  </GetInput>
  <If expr="SRInput">
    <Then>
      <Speak voice="ja-JP-Wavenet-B">{{SRInput}}も大好きです</Speak>
    </Then>
    <Else>
      <Speak voice="ja-JP-Wavenet-B">分かりませんでした</Speak>
    </Else>
  </If>
</IVR>