DialogServiceConnector Class
- java.
lang. Object - com.
microsoft. cognitiveservices. speech. dialog. DialogServiceConnector
- com.
Implements
public class DialogServiceConnector
implements java.lang.AutoCloseable
Class that defines a DialogServiceConnector. Note: close() must be called in order to release underlying resources held by the object.
Field Summary
Modifier and Type | Field and Description |
---|---|
Event |
activityReceived
Defines event handler for the activity received event. |
Event |
canceled
Defines event handler for the canceled event. |
Event |
recognized
Defines event handler for the recognized event. |
Event |
recognizing
Defines event handler for the recognizing event. |
Event |
sessionStarted
Defines event handler for the session start event. |
Event |
sessionStopped
Defines event handler for the session stop event. |
Event |
speechEndDetected
Defines event handler for the speech end detection event. |
Event |
speechStartDetected
Defines event handler for the speech start detection event. |
Event |
turnStatusReceived
Defines event handler for the turn status received event. |
Constructor Summary
Constructor | Description |
---|---|
DialogServiceConnector(DialogServiceConfig config) |
Builds a Dialog |
DialogServiceConnector(DialogServiceConfig config, AudioConfig audioConfig) |
Builds a Dialog |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
close()
Dispose of associated resources. |
java.util.concurrent.Future<java.lang.Void> |
connectAsync()
Connects with the service. |
java.util.concurrent.Future<java.lang.Void> |
disconnectAsync()
Disconnects from the service. |
java.lang.String |
getAuthorizationToken()
Gets the authorization token used to communicate with the service. |
Safe |
getImpl()
Returns the internal dialog service connector instance. |
Property |
getProperties()
The collection of properties and their values defined for this Dialog |
java.util.concurrent.Future<Speech |
listenOnceAsync()
Starts a listening session that will terminate after the first utterance. |
java.util.concurrent.Future<java.lang.String> |
sendActivityAsync(String activity)
Sends an activity to the backing dialog. |
void |
setAuthorizationToken(String token)
Sets the authorization token used to communicate with the service. |
void |
setSpeechActivityTemplate(String activityTemplate)
Sets the JSON template that will be provided to the speech service for the next conversation. |
java.util.concurrent.Future<java.lang.Void> |
startKeywordRecognitionAsync(KeywordRecognitionModel model)
Initiates keyword recognition. |
java.util.concurrent.Future<java.lang.Void> |
stopKeywordRecognitionAsync()
Stop keyword recognition. |
java.util.concurrent.Future<java.lang.Void> |
stopListeningAsync()
Requests that an active listening operation immediately finish, interrupting any ongoing speaking, and provide a result reflecting whatever audio data has been captured so far. |
Methods inherited from java.lang.Object
Field Details
activityReceived
public EventHandlerImpl
Defines event handler for the activity received event.
canceled
public EventHandlerImpl
Defines event handler for the canceled event.
recognized
public EventHandlerImpl
Defines event handler for the recognized event.
recognizing
public EventHandlerImpl
Defines event handler for the recognizing event.
sessionStarted
public EventHandlerImpl
Defines event handler for the session start event.
sessionStopped
public EventHandlerImpl
Defines event handler for the session stop event.
speechEndDetected
public EventHandlerImpl
Defines event handler for the speech end detection event.
speechStartDetected
public EventHandlerImpl
Defines event handler for the speech start detection event.
turnStatusReceived
public EventHandlerImpl
Defines event handler for the turn status received event.
Constructor Details
DialogServiceConnector
public DialogServiceConnector(DialogServiceConfig config)
Builds a DialogServiceConnector with audio from default microphone input
Parameters:
DialogServiceConnector
public DialogServiceConnector(DialogServiceConfig config, AudioConfig audioConfig)
Builds a DialogServiceConnector
Parameters:
Method Details
close
public void close()
Dispose of associated resources. Note: close() must be called in order to release underlying resources held by the object.
connectAsync
public Future
Connects with the service.
Returns:
disconnectAsync
public Future
Disconnects from the service.
Returns:
getAuthorizationToken
public String getAuthorizationToken()
Gets the authorization token used to communicate with the service.
Returns:
getImpl
public SafeHandle getImpl()
Returns the internal dialog service connector instance.
Returns:
getProperties
public PropertyCollection getProperties()
The collection of properties and their values defined for this DialogServiceConnector.
Returns:
listenOnceAsync
public Future
Starts a listening session that will terminate after the first utterance.
Returns:
sendActivityAsync
public Future
Sends an activity to the backing dialog.
Parameters:
Returns:
setAuthorizationToken
public void setAuthorizationToken(String token)
Sets the authorization token used to communicate with the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the recognizer will encounter errors during recognition.
Parameters:
setSpeechActivityTemplate
public void setSpeechActivityTemplate(String activityTemplate)
Sets the JSON template that will be provided to the speech service for the next conversation. The service will attempt to merge this template into all activities sent to the dialog backend, whether originated by the client with SendActivityAsync or generated by the service, as is the case with speech-to-text results.
Parameters:
startKeywordRecognitionAsync
public Future
Initiates keyword recognition.
Parameters:
Returns:
stopKeywordRecognitionAsync
public Future
Stop keyword recognition.
Returns:
stopListeningAsync
public Future
Requests that an active listening operation immediately finish, interrupting any ongoing speaking, and provide a result reflecting whatever audio data has been captured so far.
Returns:
Applies to
Azure SDK for Java