ConversationTranslator Class

  • java.lang.Object
    • com.microsoft.cognitiveservices.speech.transcription.ConversationTranslator

Implements

java.lang.AutoCloseable

public class ConversationTranslator
implements java.lang.AutoCloseable

A conversation translator that enables a connected experience where participants can use their own devices to see everyone else's recognitions and IMs in their own languages. Participants can also speak and send IMs to others. Note: close() must be called in order to release underlying resources held by the object. Added in version 1.12.0

Field Summary

Modifier and Type Field and Description
final EventHandlerImpl<ConversationTranslationCanceledEventArgs> canceled

Event that signals an error with the conversation translation, or the end of the audio stream has been reached.

final EventHandlerImpl<ConversationExpirationEventArgs> conversationExpiration

Event that signals how many more minutes are left before the conversation expires.

final EventHandlerImpl<ConversationParticipantsChangedEventArgs> participantsChanged

Event that signals participants in the room have changed (e.g.

final EventHandlerImpl<SessionEventArgs> sessionStarted

Event that signals the start of a conversation translation session.

final EventHandlerImpl<SessionEventArgs> sessionStopped

Event that signals the end of a conversation translation session.

final EventHandlerImpl<ConversationTranslationEventArgs> textMessageReceived

Event that signals a translated text message from a conversation participant.

final EventHandlerImpl<ConversationTranslationEventArgs> transcribed

Event that signals a final conversation translation result is available for a conversation participant.

final EventHandlerImpl<ConversationTranslationEventArgs> transcribing

Event that signals an intermediate conversation translation result is available for a conversation participant.

Constructor Summary

Constructor Description
ConversationTranslator()

Creates a new instance of the Conversation Translator using the default microphone input.

ConversationTranslator(AudioConfig audioConfig)

Creates a new instance of the Conversation Translator.

Method Summary

Modifier and Type Method and Description
void close()

Dispose of associated resources.

java.lang.String getAuthorizationToken()

Gets the Cognitive Speech authorization token.

SafeHandle getImpl()

Returns the internal conversation translator instance

PropertyCollection getProperties()

The collection or properties and their values defined for this ConversationTranslator.

java.lang.String getSpeechRecognitionLanguage()

Gets the language name that is used for recognition.

java.util.concurrent.Future<java.lang.Void> joinConversationAsync(Conversation conversation, String nickname)

Joins an existing conversation.

java.util.concurrent.Future<java.lang.Void> joinConversationAsync(String conversationId, String nickname, String language)

Joins an existing conversation.

java.util.concurrent.Future<java.lang.Void> leaveConversationAsync()

Leave the current conversation.

java.util.concurrent.Future<java.lang.Void> sendTextMessageAsync(String message)

Sends an instant message to all participants in the conversation.

void setAuthorizationToken(String authToken, String region)

Sets the Cognitive Speech authorization token that will be used for connecting to the server.

java.util.concurrent.Future<java.lang.Void> startTranscribingAsync()

Starts sending audio to the conversation service for speech recognition and translation.

java.util.concurrent.Future<java.lang.Void> stopTranscribingAsync()

Stops sending audio to the conversation service.

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

canceled

public final EventHandlerImpl canceled

Event that signals an error with the conversation translation, or the end of the audio stream has been reached.

conversationExpiration

public final EventHandlerImpl conversationExpiration

Event that signals how many more minutes are left before the conversation expires.

participantsChanged

public final EventHandlerImpl participantsChanged

Event that signals participants in the room have changed (e.g. a new participant joined).

sessionStarted

public final EventHandlerImpl sessionStarted

Event that signals the start of a conversation translation session.

sessionStopped

public final EventHandlerImpl sessionStopped

Event that signals the end of a conversation translation session.

textMessageReceived

public final EventHandlerImpl textMessageReceived

Event that signals a translated text message from a conversation participant.

transcribed

public final EventHandlerImpl transcribed

Event that signals a final conversation translation result is available for a conversation participant.

transcribing

public final EventHandlerImpl transcribing

Event that signals an intermediate conversation translation result is available for a conversation participant.

Constructor Details

ConversationTranslator

public ConversationTranslator()

Creates a new instance of the Conversation Translator using the default microphone input.

ConversationTranslator

public ConversationTranslator(AudioConfig audioConfig)

Creates a new instance of the Conversation Translator.

Parameters:

audioConfig - Audio configuration.

Method Details

close

public void close()

Dispose of associated resources. Note: close() must be called in order to relinquish underlying resources held by the object.

getAuthorizationToken

public String getAuthorizationToken()

Gets the Cognitive Speech authorization token.

Returns:

The authorization token

getImpl

public SafeHandle getImpl()

Returns the internal conversation translator instance

Returns:

The internal conversation translator instance

getProperties

public PropertyCollection getProperties()

The collection or properties and their values defined for this ConversationTranslator.

Returns:

The collection or properties and their values defined for this ConversationTranslator.

getSpeechRecognitionLanguage

public String getSpeechRecognitionLanguage()

Gets the language name that is used for recognition.

Returns:

The language name that is used for recognition.

joinConversationAsync

public Future joinConversationAsync(Conversation conversation, String nickname)

Joins an existing conversation. You should use this method if you have created a conversation using CreateConversationAsync(SpeechConfig, String).

Parameters:

conversation - The Conversation to join.
nickname - The display name to use for the current participant.

Returns:

A task representing the join operation

joinConversationAsync

public Future joinConversationAsync(String conversationId, String nickname, String language)

Joins an existing conversation. You should use this method if you have created a conversation using CreateConversationAsync(SpeechConfig, String).

Parameters:

conversationId - The unique identifier for the conversation to join.
nickname - The display name to use for the current participant.
language - The speech language to use for the current participant.

Returns:

A task representing the join operation

leaveConversationAsync

public Future leaveConversationAsync()

Leave the current conversation. After this is called, you will no longer receive any events.

Returns:

A task representing the leave operation

sendTextMessageAsync

public Future sendTextMessageAsync(String message)

Sends an instant message to all participants in the conversation. This instant message will be translated into each participant's text language.

Parameters:

message - The message to send.

Returns:

A task representing the send message operation

setAuthorizationToken

public void setAuthorizationToken(String authToken, String region)

Sets the Cognitive Speech authorization token that will be used for connecting to the server.

Parameters:

authToken - The authorization token.
region - The Azure region for this token.

startTranscribingAsync

public Future startTranscribingAsync()

Starts sending audio to the conversation service for speech recognition and translation. You should subscribe to the Transcribing, and Transcribed events to receive conversation translation results for yourself, and other participants in the conversation.

Returns:

A task representing the transcribe operation

stopTranscribingAsync

public Future stopTranscribingAsync()

Stops sending audio to the conversation service. You will still receive Transcribing, and Transcribed events for other participants in the conversation.

Returns:

A task representing the transcribe operation

Applies to