Accessing Multiple Transcriptions

Follow these instructions to access multiple transcriptions from the Google ASR.

Prerequisites

  • Set Maximum Alternative Transcriptions to greater than 1 on the Cloud STT node, Speech Recognizer tab.

    Note:

    The Google ASR determines the actual number of transcriptions available, which may be fewer than the number you set.

  • Follow the Cloud STT node with a node that assigns a variable to an expression.

    Any node in the call flow following the Cloud STT node can access the transcription information by evaluating the returned JSON object.

    Example:

    Follow the Cloud STT node with a variable node.

    Assign a variable in the variable node to an expression that evaluates the JSON object.

Example Returned JSON Object

Example:
{
"raw_transcribe" : "best",
"confidence_score": "0.75",
"additional_information": {
"alternate_transcriptions": [
{
"transcription": "best",
"confidence": "0.75"
},
{
"transcription": "beast",
"confidence": "0.55"
},
{
"transcription": "beat",
"confidence": "0.4"
},
]
}
}

Expression to Get the Transcribed Responses and Confidence Scores

Any node in the call flow following the Cloud STT node that assigns a variable to an expression can access the transcribed responses and confidence scores. For example, you could follow the Cloud STT node with a variable node.

Use the Expression Builder as follows:

This table details the components of the expression.

Expression

Description

Function

Select Get Element from JSON.

JSON

Select the Cloud STT node name.

Path

Click the pencil to the right of the path field.

This opens a new dialog.

The dialog shows the structure of the JSON object to the left and blank fields to the right. Click the JSON structure to fill in the fields. Refer to the following table for more information.

Evaluate transcribed responses and confidence scores as follows:

Scenario

Path

Assigned Value

Get the first transcribed response

Click the raw_transcribe row:

The value is a string.

Get the confidence score of the first transcribed response

Click the confidence_score row:

The value is a number between 0 and 1 to two decimal places.

Get all transcribed responses and confidence scores

Click the alternate_transcriptions row:

The value is an array. Here is an example.

[
{
"transcription": "best",
"confidence": "0.75"
},
{
"transcription": "beast",
"confidence": "0.55"
},
{
"transcription": "beat",
"confidence": "0.4"
},
]

Get a specific transcribed response and confidence score

Click the alternate_transcriptions row. In the third field, enter the array number to evaluate.

The value is an array. Here is an example.

[
{
"transcription": "beat",
"confidence": "0.4"
},
]

Get only transcribed responses

Click the transcription row:

The third field shows the array number to evaluate. Edit the third field to suit your requirements.

  • The default value is 0 for the first element of the array.

  • To extract all responses, use *.

  • The last element of the array is the number of responses minus one. If you provide a number greater than this, the variable is assigned a null value.

The value is an array. Here is an example.

["best","beast","beat"]

Get only confidence scores

Click the confidence row:

The third field shows the array number to evaluate. Edit the third field to suit your requirements.

  • The default value is 0 for the first element of the array.

  • To extract all responses, use *.

  • The last element of the array is the number of responses minus one. If you provide a number greater than this, the variable is assigned a null value.

The value is an array. Here is an example.

["0.75","0.55","0.40"]

Get Array Length

The array length is equal to the number of transcriptions returned.

Expression

Description

Function

Select Get Array Length from the list of JSON objects.

JSON

Select the Cloud STT node name.

Path

  1. Click the pencil to the right of the path field.

    This opens a new dialog.

    The dialog shows the structure of the JSON object to the left, and blank fields to the right.

  2. Click the alternate_transcriptions row of the JSON object.

    The fields to the right are filled in as follows.

    This returns the length of the alternate_transcriptions array.