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

speech

  Available in REST API Version 2 and later.

Defines a textual representation of a section of speech obtained during transcription.

Used by actions get input, run speech menu, start transcription

language wrappers and examples

It has the following properties:

PropertyAvailabilityDescription
textalwaysA string of text representing a section of speech that was recognised.
confidencenot guaranteed to be present A floating point value indicating the confidence that this text matches what was spoken. In the range 0.0 – 1.0 where 1.0 is greatest confidence.
For results from start transcription this may be present only for final results and for the first alternative speech result object.

  • Examples:


    • 	{
      		"text" : "could you tell me my account balance please",
      		"confidence" : 0.91
      	}
      
    • 	{
      		"text" : "could you tell me my account balance please"
      	}
      
  • Speech Class
    Namespace: Aculab.Cloud.RestAPIWrapper
    Assembly: Aculab.Cloud.RestAPIWrapper.dll

    A class representing a single section of transcribed speech.

    public class Speech 
    {
        // Members
        public string Text;
        public double? Confidence;
        public override string ToString();
    }
    

    Examples:

    • Extract the details from a speech object with confidence set (final result):

      var text = speech.Text;
      // confidence is double
      var confidence = speech.Confidence;
      
    • Extract the details from a speech object with confidence null (interim result):

      var text = speech.Text;
      // confidence is null
      var confidence = speech.Confidence;
      
  • Speech Class
    Namespace: Aculab.Cloud.RestAPIWrapper
    Assembly: Aculab.Cloud.RestAPIWrapper.dll

    A class representing a single section of transcribed speech.

    Public Class Speech
        ' Members
        Public Property Text As String
        Public Property Confidence As Double?
        Public Overrides Function ToString() As String
    End Class
    

    Examples:

    • Extract the details from a speech object with confidence set (final result):

      Dim text = speech.Text
      ' confidence Is double
      Dim confidence = speech.Confidence
      
    • Extract the details from a speech object with confidence null (interim result):

      Dim text = speech.Text
      ' confidence Is null
      Dim confidence = speech.Confidence
      
  • class Speech

    Represents a section of transcribed speech.

    Class synopsis:

    // Members:
    public String getText()
    public double getConfidence()
    

    Examples:

    • Extract the details from a speech object with confidence set:

      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();
      
                  for (Speech speech : speech_list)
                  {
                      double confidence = speech.getConfidence();
      
                      if (confidence >= 0)
                      {
                          String text = speech.getText();
      
                          // Your code here...
                      }
                  }
              }
          }
      }
      
    • Extract the details from an speech object without confidence:

      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();
      
                  for (Speech speech : speech_list)
                  {
                      double confidence = speech.getConfidence();
      
                      if (confidence < 0)
                      {
                          String text = speech.getText();
      
                          // Your code here...
                      }
                  }
              }
          }
      }
      
  • TelephonyRequest.get_action_result()

    The Speech 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:
                  alternatives = phrase.get("alternatives")
      
                  for alternative in alternatives:
      
                      if 'confidence' in alternative:
                          text = alternative.get("text")
                          confidence = alternative.get("confidence")
                          print("text={} confidence={}".format(text, confidence))
      
    • 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:
                  alternatives = phrase.get("alternatives")
      
                  for alternative in alternatives:
      
                      if 'confidence' not in alternative:
                          text = alternative.get("text")
                          print("text={} confidence is null".format(text))
      
  • The Speech class

    Introduction

    Represents a section of transcribed speech.

    Class synopsis

    class Speech extends PropertyHolder {
    
        /* methods */
        public float|null getConfidence()
        public string getText()
    }
    

    Examples:

    • Extract the details from a speech object with confidence set:

      $text = $speech->getText();
      $confidence = $speech->getConfidence();
      /* $confidence is float */
      
    • Extract the details from an speech object without confidence:

      $text = $speech->getText();
      $confidence = $speech->getConfidence();
      /* $confidence is null */