Start Transcription
Starts transcribing the current call, sending the results to a specified results page. You can specify the language spoken on the call and you can request interim results for each phrase.
A start transcription
action uses two speech recognition streams when the transcription mode
is separate
, and one speech recognition stream for the other modes. The service must be configured so that the application will have a suitable number of streams available when the action runs. The streams will continue to be in use until the transcription ends, such as when a stop transcription action runs.
Note that speech recognition/transcription is a chargeable feature.
language wrappers and examples
The start transcription properties are:
Property | Required/Optional | Default | Description |
---|---|---|---|
results page | required | A web page request object that defines the web page that is going to receive the transcription results and any interim results if they are enabled. The request to this page happens asynchronously and its response is not considered part of the application flow. | |
transcription mode | optional | separate | One of separate , mixed , inbound , outbound . How the inbound and outbound audio is transcribed. For modes other than mixed the inbound and/or outbound transcription results contain a property indicating direction. For inbound and outbound, only the specified direction of audio is transcribed. |
id | optional | "" | A user-defined string that can be used to uniquely identify each particular transcription. |
speech recognition options | optional | - | A speech recognition options object that sets the language for the call and other options related to speech recognition. |
enable interim results | optional | false | Whether the transcription will send interim results before it has finalised recognition of each phrase. |
Remarks
Only one transcription can be running at any one time in an application. If a transcription is running already a start transcription action will stop that transcription and start a new one.
Returns
The start transcription action has no return. The next action in the list will be run when start transcription completes.
Results
Each transcription result is sent to the results page
in an action result as it becomes available.
Final transcription results (final = true
) are sent to the results page
when the speech recognition has finalised each phrase spoken. If interim results are enabled then additional results (final = false
) are sent to the same page while the speech recognition is analysing each phrase.
Property | Availability | Description |
---|---|---|
transcription | always | An array of phrase objects representing sequential parts of the recognised speech. If transcription mode is in anything other than mixed then each phrase is labelled as either inbound or outbound. If enable interim results has been enabled then interim results (final = false) will be returned, concluding with a final result (final = true). |
completed | always | true or false . true indicates that this is the last result of the transcription. |
id | always | The string identifying the transcription, as specified in the start transcription action. |
Note that results are not returned to the application directly, but to the results page. A page that receives a transcription result should respond with a 204 response code indicating no content.
See also:
Examples:
"start_transcription":
{
"results_page":
{
"url" : "my_transcription_results_page"
}
}
The following is an example of the first three of a series of results that may be sent to the results page
:
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "hello which department would you like",
"confidence" : 0.91
}
],
"final" : true,
"direction" : "outbound"
}
],
"completed" : false,
"id" : ""
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "sales please",
"confidence" : 0.93
}
],
"final" : true,
"direction" : "inbound"
}
],
"completed" : false,
"id" : ""
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "I'm putting you through now",
"confidence" : 0.94
}
],
"final" : true,
"direction" : "outbound"
}
],
"completed" : false,
"id" : ""
}
}
"start_transcription" :
{
"results_page" :
{
"url" : "my_transcription_results_page"
},
"id" : "conv123",
"speech_recognition_options" :
{
"language" : "en-GB"
},
"enable_interim_results" : true
}
The following is an example of a series of results that may be sent to the results page
:
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "hello"
}
],
"final" : false,
"stability" : 0.28,
"direction" : "outbound"
}
],
"id" : "conv123",
"completed" : false
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "hello",
"confidence" : 0.94
}
],
"final" : true,
"direction" : "outbound"
}
],
"id" : "conv123",
"completed" : false
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "which department"
}
],
"final" : false,
"stability" : 0.15,
"direction": "outbound"
}
],
"id" : "conv123",
"completed" : false
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "which department would you like"
}
],
"final" : false,
"stability" : 0.18,
"direction" : "outbound"
}
],
"id" : "conv123",
"completed" : false
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "which department would you like",
"confidence" : 0.92
}
],
"final" : true,
"direction" : "outbound"
}
],
"id" : "conv123",
"completed" : false
}
}
"start_transcription" :
{
"results_page" :
{
"url" : "my_transcription_results_page"
},
"id" : "conv5",
"transcription_mode" : "inbound",
"speech_recognition_options" :
{
"max_alternatives" : 2
},
"enable_interim_results" : true
}
The following is an example of a series of results that may be sent to the results page
:
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "my"
}
],
"final" : false,
"stability" : 0.18,
"direction" : "inbound"
}
],
"id" : "conv5",
"completed" : false
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "my account"
},
{
"text" : "my count"
}
],
"final" : false,
"stability" : 0.13,
"direction" : "inbound"
}
],
"id" : "conv5",
"completed" : false
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "my account please"
},
{
"text" : "my account police"
}
],
"final" : false,
"stability" : 0.19,
"direction" : "inbound"
}
],
"id" : "conv5",
"completed" : false
}
}
"action_result" :
{
"action" : "start_transcription",
"result" :
{
"transcription" :
[
{
"alternatives" :
[
{
"text" : "my account please",
"confidence" : 0.92
},
{
"text" : "my account police"
}
],
"final" : true,
"direction": "inbound"
}
],
"id" : "conv5",
"completed" : false
}
}
StartTranscription Class
Namespace: Aculab.Cloud.RestAPIWrapper
Assembly: Aculab.Cloud.RestAPIWrapper.dll
An action to start transcribing the current call and send results to the specified results page.
public class StartTranscription : TelephonyAction
{
// Constructors
public StartTranscription(WebPageRequest resultsPage, SpeechRecognitionOptions options = null, string id = "");
// Members
public WebPageRequest ResultsPage;
public string Id;
public TranscriptionMode? TranscriptionMode;
public SpeechRecognitionOptions SpeechRecognitionOptions;
public bool? EnableInterimResults;
}
Examples:
List<TelephonyAction> actions = new List<TelephonyAction>();
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"));
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = new TelephonyRequest(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
List<TelephonyAction> actions = new List<TelephonyAction>();
var speechOptions = new SpeechRecognitionOptions("en-GB");
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions, id: "conv123");
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = new TelephonyRequest(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var id = transcriptionResult.Id;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
List<TelephonyAction> actions = new List<TelephonyAction>();
var speechOptions = new SpeechRecognitionOptions
{
MaxAlternatives = 2
};
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions);
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = new TelephonyRequest(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
public class StartTranscription : TelephonyAction
{
// Constructors
public StartTranscription(WebPageRequest resultsPage, SpeechRecognitionOptions options = null, string id = "");
// Members
public WebPageRequest ResultsPage;
public string Id;
public TranscriptionMode? TranscriptionMode;
public SpeechRecognitionOptions SpeechRecognitionOptions;
public bool? EnableInterimResults;
}
Examples:
List<TelephonyAction> actions = new List<TelephonyAction>();
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"));
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = new TelephonyRequest(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
List<TelephonyAction> actions = new List<TelephonyAction>();
var speechOptions = new SpeechRecognitionOptions("en-GB");
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions, id: "conv123");
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = new TelephonyRequest(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var id = transcriptionResult.Id;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
List<TelephonyAction> actions = new List<TelephonyAction>();
var speechOptions = new SpeechRecognitionOptions
{
MaxAlternatives = 2
};
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions);
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = new TelephonyRequest(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
public class StartTranscription : TelephonyAction
{
// Constructors
public StartTranscription(WebPageRequest resultsPage, SpeechRecognitionOptions options = null, string id = "");
// Members
public WebPageRequest ResultsPage;
public string Id;
public TranscriptionMode? TranscriptionMode;
public SpeechRecognitionOptions SpeechRecognitionOptions;
public bool? EnableInterimResults;
}
Examples:
List<TelephonyAction> actions = new List<TelephonyAction>();
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"));
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
List<TelephonyAction> actions = new List<TelephonyAction>();
var speechOptions = new SpeechRecognitionOptions("en-GB");
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions, id: "conv123");
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var id = transcriptionResult.Id;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
List<TelephonyAction> actions = new List<TelephonyAction>();
var speechOptions = new SpeechRecognitionOptions
{
MaxAlternatives = 2
};
var startTranscription = new StartTranscription(new WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions);
actions.Add(startTranscription);
// Unpack the request
var telephonyRequest = await TelephonyRequest.UnpackRequestAsync(Request);
var transcriptionResult = (StartTranscriptionResult)telephonyRequest.InstanceInfo.ActionResult;
var completed = transcriptionResult.Completed;
var phrases = transcriptionResult.Transcription;
foreach (var phrase in phrases)
{
var direction = phrase.Direction;
var alternatives = phrase.Alternatives;
foreach (var alternative in alternatives)
{
if (phrase.Final)
{
var text = alternative.Text;
var confidence = alternative.Confidence;
// process final speech result...
}
else
{
var stability = phrase.Stability;
var text = alternative.Text;
// process interim speech result...
}
}
}
StartTranscription Class
Namespace: Aculab.Cloud.RestAPIWrapper
Assembly: Aculab.Cloud.RestAPIWrapper.dll
An action to start transcribing the current call and send results to the specified results page.
Public Class StartTranscription
Inherits TelephonyAction
' Constructors
Public Sub New (resultsPage As Webpagerequest, Optional options As Speechrecognitionoptions = Nothing, Optional id As String = "")
' Members
Public Property ResultsPage As Webpagerequest
Public Property Id As String
Public Property TranscriptionMode As Transcriptionmode?
Public Property SpeechRecognitionOptions As Speechrecognitionoptions
Public Property EnableInterimResults As Bool?
End Class
Examples:
Dim actions = New List(Of TelephonyAction)
Dim startTranscription = New StartTranscription(New WebPageRequest("MyTranscriptionResultsPage.aspx"))
actions.Add(startTranscription)
' Unpack the request
Dim telephonyRequest = New TelephonyRequest(Request)
Dim transcriptionResult As StartTranscriptionResult = telephonyRequest.InstanceInfo.ActionResult
Dim completed = transcriptionResult.Completed
Dim phrases = transcriptionResult.Transcription
For Each phrase In phrases
Dim direction = Phrase.Direction
Dim alternatives = Phrase.Alternatives
For Each alternative In alternatives
If phrase.Final Then
Dim text = alternative.Text
Dim confidence = alternative.Confidence
' process final speech result...
Else
Dim stability = phrase.Stability
Dim text = alternative.Text
' process interim speech result...
End If
Next
Next
Dim actions = New List(Of TelephonyAction)
Dim speechOptions = New SpeechRecognitionOptions("en-GB")
Dim startTranscription = New StartTranscription(New WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions, id:="conv123")
actions.Add(startTranscription)
' Unpack the request
Dim TelephonyRequest = New TelephonyRequest(Request)
Dim transcriptionResult As StartTranscriptionResult = TelephonyRequest.InstanceInfo.ActionResult
Dim completed = transcriptionResult.Completed
Dim ID = transcriptionResult.Id
Dim phrases = transcriptionResult.Transcription
For Each phrase In phrases
Dim direction = Phrase.Direction
Dim alternatives = phrase.Alternatives
For Each alternative In alternatives
If phrase.Final Then
Dim text = alternative.Text
Dim confidence = alternative.Confidence
' process final speech result...
Else
Dim stability = phrase.Stability
Dim text = alternative.Text
' process interim speech result...
End If
Next
Next
Dim actions = New List(Of TelephonyAction)
Dim speechOptions = New SpeechRecognitionOptions
speechOptions.MaxAlternatives = 2
Dim startTranscription = New StartTranscription(New WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions)
actions.Add(startTranscription)
' Unpack the request
Dim telephonyRequest = New TelephonyRequest(Request)
Dim transcriptionResult As StartTranscriptionResult = telephonyRequest.InstanceInfo.ActionResult
Dim completed = transcriptionResult.Completed
Dim phrases = transcriptionResult.Transcription
For Each phrase In phrases
Dim direction = phrase.Direction
Dim alternatives = phrase.Alternatives
For Each alternative In alternatives
If phrase.Final Then
Dim text = alternative.Text
Dim confidence = alternative.Confidence
' process final speech result...
Else
Dim stability = phrase.Stability
Dim text = alternative.Text
' process interim speech result...
End If
Next
Next
Public Class StartTranscription
Inherits TelephonyAction
' Constructors
Public Sub New (resultsPage As Webpagerequest, Optional options As Speechrecognitionoptions = Nothing, Optional id As String = "")
' Members
Public Property ResultsPage As Webpagerequest
Public Property Id As String
Public Property TranscriptionMode As Transcriptionmode?
Public Property SpeechRecognitionOptions As Speechrecognitionoptions
Public Property EnableInterimResults As Bool?
End Class
Examples:
Dim actions = New List(Of TelephonyAction)
Dim startTranscription = New StartTranscription(New WebPageRequest("MyTranscriptionResultsPage.aspx"))
actions.Add(startTranscription)
' Unpack the request
Dim telephonyRequest = New TelephonyRequest(Request)
Dim transcriptionResult As StartTranscriptionResult = telephonyRequest.InstanceInfo.ActionResult
Dim completed = transcriptionResult.Completed
Dim phrases = transcriptionResult.Transcription
For Each phrase In phrases
Dim direction = Phrase.Direction
Dim alternatives = Phrase.Alternatives
For Each alternative In alternatives
If phrase.Final Then
Dim text = alternative.Text
Dim confidence = alternative.Confidence
' process final speech result...
Else
Dim stability = phrase.Stability
Dim text = alternative.Text
' process interim speech result...
End If
Next
Next
Dim actions = New List(Of TelephonyAction)
Dim speechOptions = New SpeechRecognitionOptions("en-GB")
Dim startTranscription = New StartTranscription(New WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions, id:="conv123")
actions.Add(startTranscription)
' Unpack the request
Dim TelephonyRequest = New TelephonyRequest(Request)
Dim transcriptionResult As StartTranscriptionResult = TelephonyRequest.InstanceInfo.ActionResult
Dim completed = transcriptionResult.Completed
Dim ID = transcriptionResult.Id
Dim phrases = transcriptionResult.Transcription
For Each phrase In phrases
Dim direction = Phrase.Direction
Dim alternatives = phrase.Alternatives
For Each alternative In alternatives
If phrase.Final Then
Dim text = alternative.Text
Dim confidence = alternative.Confidence
' process final speech result...
Else
Dim stability = phrase.Stability
Dim text = alternative.Text
' process interim speech result...
End If
Next
Next
Dim actions = New List(Of TelephonyAction)
Dim speechOptions = New SpeechRecognitionOptions
speechOptions.MaxAlternatives = 2
Dim startTranscription = New StartTranscription(New WebPageRequest("MyTranscriptionResultsPage.aspx"), speechOptions)
actions.Add(startTranscription)
' Unpack the request
Dim telephonyRequest = New TelephonyRequest(Request)
Dim transcriptionResult As StartTranscriptionResult = telephonyRequest.InstanceInfo.ActionResult
Dim completed = transcriptionResult.Completed
Dim phrases = transcriptionResult.Transcription
For Each phrase In phrases
Dim direction = phrase.Direction
Dim alternatives = phrase.Alternatives
For Each alternative In alternatives
If phrase.Final Then
Dim text = alternative.Text
Dim confidence = alternative.Confidence
' process final speech result...
Else
Dim stability = phrase.Stability
Dim text = alternative.Text
' process interim speech result...
End If
Next
Next
class StartTranscription extends TelephonyAction
Represents a start transcription action.
Class synopsis:
// Constructors:
public StartTranscription(WebPageRequest resultsPage)
// Members:
public void setTranscriptionMode(TranscriptionMode mode)
public void setId(String id)
public void setSpeechRecognitionOptions(SpeechRecognitionOptions options)
public void setEnableInterimResults(boolean enabled)
class StartTranscriptionResult extends TranscriptionResult
Represents a start transcription result.
Class synopsis:
Examples:
List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
WebPageRequest resultsPage = new WebPageRequest("my_transcription_results_page");
actions.add(new StartTranscription(resultsPage));
StartTranscriptionResult transcriptionResult = (StartTranscriptionResult)ourRequest.getInstanceInfo().getActionResult();
boolean completed = transcriptionResult.getCompleted();
String id = transcriptionResult.getId();
List<Phrase> phrases = transcriptionResult.getTranscription();
for (Phrase phrase : phrases)
{
String dir = phrase.getDirection();
List<Speech> alternatives = phrase.getAlternatives();
for (Speech alternative : alternatives)
{
if (phrase.getFinal())
{
String text = alternative.getText();
double confidence = alternative.getConfidence();
/* process final speech */
}
else
{
String text = alternative.getText();
double stability = phrase.getStability();
/* process interim speech */
}
}
}
List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
WebPageRequest resultsPage = new WebPageRequest("my_transcription_results_page");
SpeechRecognitionOptions options = new SpeechRecognitionOptions();
options.setLanguage("en-GB");
StartTranscription transcriptionAction = new StartTranscription(resultsPage);
transcriptionAction.setId("conv123");
transcriptionAction.setSpeechRecognitionOptions(options);
transcriptionAction.setEnableInterimResults(true);
actions.add(transcriptionAction);
StartTranscriptionResult transcriptionResult = (StartTranscriptionResult)ourRequest.getInstanceInfo().getActionResult();
boolean completed = transcriptionResult.getCompleted();
String id = transcriptionResult.getId();
List<Phrase> phrases = transcriptionResult.getTranscription();
for (Phrase phrase : phrases)
{
String dir = phrase.getDirection();
List<Speech> alternatives = phrase.getAlternatives();
for (Speech alternative : alternatives)
{
if (phrase.getFinal())
{
String text = alternative.getText();
double confidence = alternative.getConfidence();
/* process final speech */
}
else
{
String text = alternative.getText();
double stability = phrase.getStability();
/* process interim speech */
}
}
}
List<TelephonyAction> actions = new ArrayList<TelephonyAction>();
WebPageRequest resultsPage = new WebPageRequest("my_transcription_results_page");
SpeechRecognitionOptions options = new SpeechRecognitionOptions();
options.setMaxAlternatives(2);
StartTranscription transcriptionAction = new StartTranscription(resultsPage);
transcriptionAction.setId("conv5");
transcriptionAction.setTranscriptionMode(TranscriptionMode.INBOUND);
transcriptionAction.setSpeechRecognitionOptions(options);
transcriptionAction.setEnableInterimResults(true);
actions.add(transcriptionAction);
StartTranscriptionResult transcriptionResult = (StartTranscriptionResult)ourRequest.getInstanceInfo().getActionResult();
boolean completed = transcriptionResult.getCompleted();
String id = transcriptionResult.getId();
List<Phrase> phrases = transcriptionResult.getTranscription();
for (Phrase phrase : phrases)
{
String dir = phrase.getDirection();
List<Speech> alternatives = phrase.getAlternatives();
for (Speech alternative : alternatives)
{
if (phrase.getFinal())
{
String text = alternative.getText();
double confidence = alternative.getConfidence();
/* process final speech */
}
else
{
String text = alternative.getText();
double stability = phrase.getStability();
/* process interim speech */
}
}
}
class StartTranscription
Represents a start transcription action.
Class synopsis:
# StartTranscription object:
StartTranscription(results_page)
# Instance methods:
StartTranscription.set_transcription_mode(mode)
StartTranscription.set_id(id)
StartTranscription.set_speech_recognition_options(speech_recognition_options)
StartTranscription.set_enable_interim_results(enabled)
Start Transcription Result
The Start Transcription Result is represented by a dictionary. It is found within the action result
for the results page
.
Obtaining the Start Transcription Result dictionary:
my_request = TelephonyRequest(request)
action_result = my_request.get_action_result()
if action_result.get("action") == "start_transcription":
start_transcription_result = action_result.get("result")
Examples:
# Create a list of actions that will be passed to the TelephonyResponse constructor
list_of_actions = []
list_of_actions.append(StartTranscription(WebPage(url="my_transcription_results_page")))
my_request = TelephonyRequest(request)
action_result = my_request.get_action_result()
if action_result.get("action") == "start_transcription":
transcription_result = action_result.get("result")
completed = transcription_result.get("completed")
id = transcription_result.get("id")
phrases = transcription_result.get("transcription")
for phrase in phrases:
alternatives = phrase.get("alternatives")
direction = phrase.get("direction")
final = phrase.get("final")
for alternative in alternatives:
if final:
text = alternative.get("text")
confidence = alternative.get("confidence")
# Process final speech
else:
text = alternative.get("text")
stability = phrase.get("stability")
# Process interim speech
# Create a list of actions that will be passed to the TelephonyResponse constructor
list_of_actions = []
speech_recognition_opts = SpeechRecognitionOptions()
speech_recognition_opts.set_language("en-GB")
start_trans_action = StartTranscription(WebPage(url="my_transcription_results_page"))
start_trans_action.set_id("conv123")
start_trans_action.set_enable_interim_results(True)
start_trans_action.set_speech_recognition_options(speech_recognition_opts)
list_of_actions.append(start_trans_action)
my_request = TelephonyRequest(request)
action_result = my_request.get_action_result()
if action_result.get("action") == "start_transcription":
transcription_result = action_result.get("result")
completed = transcription_result.get("completed")
id = transcription_result.get("id")
phrases = transcription_result.get("transcription")
for phrase in phrases:
alternatives = phrase.get("alternatives")
direction = phrase.get("direction")
final = phrase.get("final")
for alternative in alternatives:
if final:
text = alternative.get("text")
confidence = alternative.get("confidence")
# Process final speech
else:
text = alternative.get("text")
stability = phrase.get("stability")
# Process interim speech
# Create a list of actions that will be passed to the TelephonyResponse constructor
list_of_actions = []
speech_recognition_opts = SpeechRecognitionOptions()
speech_recognition_opts.set_max_alternatives(2)
start_trans_action = StartTranscription(WebPage(url="my_transcription_results_page"))
start_trans_action.set_id("conv5")
start_trans_action.set_transcription_mode("inbound")
start_trans_action.set_enable_interim_results(True)
start_trans_action.set_speech_recognition_options(speech_recognition_opts)
list_of_actions.append(start_trans_action)
my_request = TelephonyRequest(request)
action_result = my_request.get_action_result()
if action_result.get("action") == "start_transcription":
transcription_result = action_result.get("result")
completed = transcription_result.get("completed")
id = transcription_result.get("id")
phrases = transcription_result.get("transcription")
for phrase in phrases:
alternatives = phrase.get("alternatives")
direction = phrase.get("direction")
final = phrase.get("final")
for alternative in alternatives:
if final:
text = alternative.get("text")
confidence = alternative.get("confidence")
# Process final speech
else:
text = alternative.get("text")
stability = phrase.get("stability")
# Process interim speech
The StartTranscription class
Introduction
Represents a start transcription action.
Class synopsis
class StartTranscription extends ActionBase {
/* methods */
public __construct(WebPageRequest|string $results_page, array $opts = null)
public self setTranscriptionMode(string $mode)
public self setID(string $id)
public self setSpeechRecognitionOptions(SpeechRecognitionOptions $opts)
public self setEnableInterimResults(boolean $enabled)
}
The StartTranscriptionResult class
Introduction
Represents a transcription result from a start transcription action.
Class synopsis
class StartTranscriptionResult extends TranscriptionResult {
/* inherited methods */
public array[Phrase] getTranscription()
public string getID()
public boolean getCompleted()
public string getAction()
public boolean getInterrupted()
}
Examples:
$response->addAction(new \Aculab\TelephonyRestAPI\StartTranscription("my_transcription_results_page.php"));
$info = \Aculab\TelephonyRestAPI\InstanceInfo::getInstanceInfo();
$transcriptionResult = $info->getActionResult();
$completed = $transcriptionResult->getCompleted();
$id = $transcriptionResult->getID();
$phrases = $transcriptionResult->getTranscription();
foreach($phrases as $phrase) {
$dir = $phrase->getDirection();
$alternatives = $phrase->getAlternatives();
foreach($alternatives as $speech) {
if ($phrase->getFinal()) {
if ($speech) {
$text = $speech->getText();
$confidence = $speech->getConfidence();
/* process final speech */
}
} else {
$stability = $phrase->getStability();
if ($speech) {
$text = $speech->getText();
/* process interim speech */
}
}
}
}
$start_transcription = new \Aculab\TelephonyRestAPI\StartTranscription("my_transcription_results_page.php");
$start_transcription->setID("conv123")
->setEnableInterimResults(true);
$speech_recognition_options = new \Aculab\TelephonyRestAPI\SpeechRecognitionOptions();
$speech_recognition_options->setLanguage("en-GB");
$start_transcription->setSpeechRecognitionOptions($speech_recognition_options);
$response->addAction($start_transcription);
$info = \Aculab\TelephonyRestAPI\InstanceInfo::getInstanceInfo();
$transcriptionResult = $info->getActionResult();
$completed = $transcriptionResult->getCompleted();
$id = $transcriptionResult->getID();
$phrases = $transcriptionResult->getTranscription();
foreach($phrases as $phrase) {
$dir = $phrase->getDirection();
$alternatives = $phrase->getAlternatives();
foreach($alternatives as $speech) {
if ($phrase->getFinal()) {
if ($speech) {
$text = $speech->getText();
$confidence = $speech->getConfidence();
/* process final speech */
}
} else {
$stability = $phrase->getStability();
if ($speech) {
$text = $speech->getText();
/* process interim speech */
}
}
}
}
$start_transcription = new \Aculab\TelephonyRestAPI\StartTranscription("my_transcription_results_page.php");
$start_transcription->setID("conv5")
->setTranscriptionMode("inbound")
->setEnableInterimResults(true);
$speech_recognition_options = new \Aculab\TelephonyRestAPI\SpeechRecognitionOptions();
$speech_recognition_options->setMaxAlternatives(2);
$start_transcription->setSpeechRecognitionOptions($speech_recognition_options);
$response->addAction($start_transcription);
$info = \Aculab\TelephonyRestAPI\InstanceInfo::getInstanceInfo();
$transcriptionResult = $info->getActionResult();
$completed = $transcriptionResult->getCompleted();
$id = $transcriptionResult->getID();
$phrases = $transcriptionResult->getTranscription();
foreach($phrases as $phrase) {
$dir = $phrase->getDirection();
$alternatives = $phrase->getAlternatives();
foreach($alternatives as $speech) {
if ($phrase->getFinal()) {
if ($speech) {
$text = $speech->getText();
$confidence = $speech->getConfidence();
/* process final speech */
}
} else {
$stability = $phrase->getStability();
if ($speech) {
$text = $speech->getText();
/* process interim speech */
}
}
}
}