다음을 통해 공유


DialogServiceConnector Class

  • java.lang.Object
    • com.microsoft.cognitiveservices.speech.dialog.DialogServiceConnector

Implements

java.lang.AutoCloseable

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
EventHandlerImpl<ActivityReceivedEventArgs> activityReceived

Defines event handler for the activity received event.

EventHandlerImpl<SpeechRecognitionCanceledEventArgs> canceled

Defines event handler for the canceled event.

EventHandlerImpl<SpeechRecognitionEventArgs> recognized

Defines event handler for the recognized event.

EventHandlerImpl<SpeechRecognitionEventArgs> recognizing

Defines event handler for the recognizing event.

EventHandlerImpl<SessionEventArgs> sessionStarted

Defines event handler for the session start event.

EventHandlerImpl<SessionEventArgs> sessionStopped

Defines event handler for the session stop event.

EventHandlerImpl<RecognitionEventArgs> speechEndDetected

Defines event handler for the speech end detection event.

EventHandlerImpl<RecognitionEventArgs> speechStartDetected

Defines event handler for the speech start detection event.

EventHandlerImpl<TurnStatusReceivedEventArgs> turnStatusReceived

Defines event handler for the turn status received event.

Constructor Summary

Constructor Description
DialogServiceConnector(DialogServiceConfig config)

Builds a DialogServiceConnector with audio from default microphone input

DialogServiceConnector(DialogServiceConfig config, AudioConfig audioConfig)

Builds a DialogServiceConnector

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.

SafeHandle getImpl()

Returns the internal dialog service connector instance.

PropertyCollection getProperties()

The collection of properties and their values defined for this DialogServiceConnector.

java.util.concurrent.Future<SpeechRecognitionResult> 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

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

activityReceived

public EventHandlerImpl activityReceived

Defines event handler for the activity received event.

canceled

public EventHandlerImpl canceled

Defines event handler for the canceled event.

recognized

public EventHandlerImpl recognized

Defines event handler for the recognized event.

recognizing

public EventHandlerImpl recognizing

Defines event handler for the recognizing event.

sessionStarted

public EventHandlerImpl sessionStarted

Defines event handler for the session start event.

sessionStopped

public EventHandlerImpl sessionStopped

Defines event handler for the session stop event.

speechEndDetected

public EventHandlerImpl speechEndDetected

Defines event handler for the speech end detection event.

speechStartDetected

public EventHandlerImpl speechStartDetected

Defines event handler for the speech start detection event.

turnStatusReceived

public EventHandlerImpl turnStatusReceived

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:

config - Dialog service connector configuration.

DialogServiceConnector

public DialogServiceConnector(DialogServiceConfig config, AudioConfig audioConfig)

Builds a DialogServiceConnector

Parameters:

config - Dialog service connector configuration.
audioConfig - An optional audio input configuration associated with the recognizer

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 connectAsync()

Connects with the service.

Returns:

A task representing the asynchronous operation that connects to the service.

disconnectAsync

public Future disconnectAsync()

Disconnects from the service.

Returns:

A task representing the asynchronous operation that disconnects from the service.

getAuthorizationToken

public String getAuthorizationToken()

Gets the authorization token used to communicate with the service.

Returns:

Authorization token.

getImpl

public SafeHandle getImpl()

Returns the internal dialog service connector instance.

Returns:

The internal dialog service connector instance

getProperties

public PropertyCollection getProperties()

The collection of properties and their values defined for this DialogServiceConnector.

Returns:

The collection of properties and their values defined for this DialogServiceConnector.

listenOnceAsync

public Future listenOnceAsync()

Starts a listening session that will terminate after the first utterance.

Returns:

A task representing the asynchronous operation that starts a one shot listening session.

sendActivityAsync

public Future sendActivityAsync(String activity)

Sends an activity to the backing dialog.

Parameters:

activity - Activity to be sent.

Returns:

A task representing the asynchronous operation that sends an activity to the backing dialog.

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:

token - Authorization token.

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:

activityTemplate - The JSON payload to be merged into generated activity messages.

startKeywordRecognitionAsync

public Future startKeywordRecognitionAsync(KeywordRecognitionModel model)

Initiates keyword recognition.

Parameters:

model - The keyword recognition model that specifies the keyword to be recognized.

Returns:

A task representing the asynchronous operation that starts keyword recognition.

stopKeywordRecognitionAsync

public Future stopKeywordRecognitionAsync()

Stop keyword recognition.

Returns:

A task representing the asynchronous operation that stops keyword recognition.

stopListeningAsync

public Future 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.

Returns:

A task representing the asynchronous operation that stops an active listening session.

Applies to