Informizely customer feedback surveys
By using the Aculab site, you agree with our use of cookies.

phrase

  Available in REST API Version 2 and later.

Defines one or more alternative transcriptions from a single section of speech.

Used by actions get input, start transcription

language wrappers and examples

It contains the following properties:

PropertyAvailabilityDescription
alternativesalwaysAn array of 1 or more speech objects up to a maximum of max alternatives starting with the most confident.
directionnot available if the transcription is running in mixed mode.inbound or outbound. Whether this phrase was recognised from the inbound or outbound direction on the call. This will be inbound for a result generate by the get input action.
stabilityonly for interim results (final = false)An estimate of how stable this interim result is and therefore a representation of how likely the speech recognition will change this result. Valid range is from 0.0 (unstable) to 1.0 (completely stable).
finalalwaysIf true, the speech recognition has recognised this distinct phrase and finished analysing it. If false, this phrase object contains an interim result that may change in subsequent results.

  • Examples:


    •     {
      		"alternatives" :
      		[
      			{
      				"text" : "could you tell me my account balance please",
      				"confidence" : 0.91
      			}
      		],
      		"direction" : "inbound",
      		"final" : true
          }
      
    •     {
      		"alternatives" :
      		[
      			{
      				"text" : "could you tell me my account balance please"
      			}
      		],
      		"direction" : "inbound",
      		"stability" : 0.24,
      		"final" : false
          }
      
  • Phrase Class
    Namespace: Aculab.Cloud.RestAPIWrapper
    Assembly: Aculab.Cloud.RestAPIWrapper.dll

    The direction of transcribed audio on a call.

    public class Phrase 
    {
        // Members
        public List<Speech> Alternatives;
        public AudioDirection Direction;
        public double? Stability;
        public bool Final;
        public override string ToString();
    }
    

    Examples:

    • Extract the first final speech from a phrase:

      if (phrase.Final)
      {
          var direction = phrase.Direction;
          var firstAlternative = phrase.Alternatives[0];
          var text = firstAlternative.Text;
          var confidence = firstAlternative.Confidence;
      }
      
    • Extract the first interim speech from a phrase:

      if (!phrase.Final)
      {
          var direction = phrase.Direction;
          var stability = phrase.Stability;
          var firstAlternative = phrase.Alternatives[0];
          var text = firstAlternative.Text;
      }
      
  • Phrase Class
    Namespace: Aculab.Cloud.RestAPIWrapper
    Assembly: Aculab.Cloud.RestAPIWrapper.dll

    The direction of transcribed audio on a call.

    Public Class Phrase
        ' Members
        Public Property Alternatives As List(Of Speech)
        Public Property Direction As Audiodirection
        Public Property Stability As Double?
        Public Property Final As Bool
        Public Overrides Function ToString() As String
    End Class
    

    Examples:

    • Extract the first final speech from a phrase:

      If phrase.Final Then
          Dim direction = phrase.Direction
          Dim firstAlternative = phrase.Alternatives(0)
          Dim text = firstAlternative.Text
          Dim confidence = firstAlternative.Confidence
      End If
      
    • Extract the first interim speech from a phrase:

      If Not phrase.Final Then
          Dim direction = phrase.Direction
          Dim stability = phrase.Stability
          Dim firstAlternative = phrase.Alternatives(0)
          Dim text = firstAlternative.Text
      End If
      
  • class Phrase

    A class representing a single spoken phrase that is in the process of being transcribed from a call.

    Class synopsis:

    // Members:
    public List<Speech> getAlternatives()
    public String getDirection()
    public double getStability()
    public boolean getFinal()
    

    Examples:

    • Extract the first final speech from a phrase:

      TelephonyRequest myRequest = new TelephonyRequest(request);
      GetInputResult getInputResult = (GetInputResult)myRequest.getInstanceInfo().getActionResult();
      
      if (getInputResult.getInputType() == "speech")
      {
          List<Phrase> phrase_list = getInputResult.getSpeechInput();
      
          for (Phrase phrase : phrase_list)
          {
              if (phrase.getFinal() == true)
              {
                  List<Speech> speech_list = phrase.getAlternatives();
                  Speech speech = speech_list.get(0);
      
                  String text = speech.getText();
                  double Confidence = speech.getConfidence();
      
                  // Your code here...
              }
          }
      }
      
    • Extract the first interim speech from a phrase:

      TelephonyRequest myRequest = new TelephonyRequest(request);
      GetInputResult getInputResult = (GetInputResult)myRequest.getInstanceInfo().getActionResult();
      
      if (getInputResult.getInputType() == "speech")
      {
          List<Phrase> phrase_list = getInputResult.getSpeechInput();
      
          for (Phrase phrase : phrase_list)
          {
              if (phrase.getFinal() == false)
              {
                  List<Speech> speech_list = phrase.getAlternatives();
                  Speech speech = speech_list.get(0);
      
                  double stability = phrase.getStability();
                  String text = speech.getText();
                  double Confidence = speech.getConfidence();
      
                  // Your code here...
              }
          }
      }
      
  • TelephonyRequest.get_action_result()

    The Phrase support class is represented by a dictionary. These may be found within the Action Result.

    Examples:


    • my_request = TelephonyRequest(request)
      action_result = my_request.get_action_result()
      
      if action_result.get("action") == "get_input":
          result = action_result.get("result")
      
          if result.get("input_type") == "speech":
              phrases = result.get("speech_input")
      
              for phrase in phrases:
                  final = phrase.get("final")
      
                  if final:
                      alternatives = phrase.get("alternatives")
                      print("Final phrase alternatives:\n{}".format(alternatives))
      
    • my_request = TelephonyRequest(request)
      action_result = my_request.get_action_result()
      
      if action_result.get("action") == "get_input":
          result = action_result.get("result")
      
          if result.get("input_type") == "speech":
              phrases = result.get("speech_input")
      
              for phrase in phrases:
                  final = phrase.get("final")
      
                  if not final:
                      alternatives = phrase.get("alternatives")
                      stability = phrase.get("stability")
                      print("Interim phrase (Stability={}) alternatives:\n{}".format(stability, alternatives))
      
  • The Phrase class

    Introduction

    Represents a single spoken phrase.

    Class synopsis

    class Phrase extends PropertyHolder {
    
        /* methods */
        public array[Speech] getAlternatives()
        public string|null getDirection()
        public float|null getStability()
        public boolean getFinal()
    }
    

    Examples:

    • Extract the first final speech from a phrase:

      if ($phrase->getFinal()) {
          $dir = $phrase->getDirection();
          $alternatives = $phrase->getAlternatives();
          $speech = array_shift($alternatives);
          if ($speech) {
              $text = $speech->getText();
              $confidence = $speech->getConfidence();
          }
      }
      
    • Extract the first interim speech from a phrase:

      if (!$phrase->getFinal()) {
          $dir = $phrase->getDirection();
          $stability = $phrase->getStability();
          $alternatives = $phrase->getAlternatives();
          $speech = array_shift($alternatives);
          if ($speech) {
              $text = $speech->getText();
          }
      }