Class ConversationTranslator
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.transcription.ConversationTranslator
-
- All Implemented Interfaces:
AutoCloseable
public class ConversationTranslator extends Object implements 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
Fields Modifier and Type Field Description EventHandlerImpl<ConversationTranslationCanceledEventArgs>canceledEvent that signals an error with the conversation translation, or the end of the audio stream has been reached.EventHandlerImpl<ConversationExpirationEventArgs>conversationExpirationEvent that signals how many more minutes are left before the conversation expires.EventHandlerImpl<ConversationParticipantsChangedEventArgs>participantsChangedEvent that signals participants in the room have changed (e.g.EventHandlerImpl<SessionEventArgs>sessionStartedEvent that signals the start of a conversation translation session.EventHandlerImpl<SessionEventArgs>sessionStoppedEvent that signals the end of a conversation translation session.EventHandlerImpl<ConversationTranslationEventArgs>textMessageReceivedEvent that signals a translated text message from a conversation participant.EventHandlerImpl<ConversationTranslationEventArgs>transcribedEvent that signals a final conversation translation result is available for a conversation participant.EventHandlerImpl<ConversationTranslationEventArgs>transcribingEvent that signals an intermediate conversation translation result is available for a conversation participant.
-
Constructor Summary
Constructors 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Dispose of associated resources.StringgetAuthorizationToken()Gets the Cognitive Speech authorization token.SafeHandlegetImpl()Returns the internal conversation translator instancePropertyCollectiongetProperties()The collection or properties and their values defined for this ConversationTranslator.StringgetSpeechRecognitionLanguage()Gets the language name that is used for recognition.Future<Void>joinConversationAsync(Conversation conversation, String nickname)Joins an existing conversation.Future<Void>joinConversationAsync(String conversationId, String nickname, String language)Joins an existing conversation.Future<Void>leaveConversationAsync()Leave the current conversation.Future<Void>sendTextMessageAsync(String message)Sends an instant message to all participants in the conversation.voidsetAuthorizationToken(String authToken, String region)Sets the Cognitive Speech authorization token that will be used for connecting to the server.Future<Void>startTranscribingAsync()Starts sending audio to the conversation service for speech recognition and translation.Future<Void>stopTranscribingAsync()Stops sending audio to the conversation service.
-
-
-
Field Detail
-
canceled
public final EventHandlerImpl<ConversationTranslationCanceledEventArgs> canceled
Event that signals an error with the conversation translation, or the end of the audio stream has been reached.
-
conversationExpiration
public final EventHandlerImpl<ConversationExpirationEventArgs> conversationExpiration
Event that signals how many more minutes are left before the conversation expires.
-
participantsChanged
public final EventHandlerImpl<ConversationParticipantsChangedEventArgs> participantsChanged
Event that signals participants in the room have changed (e.g. a new participant joined).
-
sessionStarted
public final EventHandlerImpl<SessionEventArgs> sessionStarted
Event that signals the start of a conversation translation session.
-
sessionStopped
public final EventHandlerImpl<SessionEventArgs> sessionStopped
Event that signals the end of a conversation translation session.
-
textMessageReceived
public final EventHandlerImpl<ConversationTranslationEventArgs> textMessageReceived
Event that signals a translated text message from a conversation participant.
-
transcribed
public final EventHandlerImpl<ConversationTranslationEventArgs> transcribed
Event that signals a final conversation translation result is available for a conversation participant.
-
transcribing
public final EventHandlerImpl<ConversationTranslationEventArgs> transcribing
Event that signals an intermediate conversation translation result is available for a conversation participant.
-
-
Constructor Detail
-
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 Detail
-
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<Void> 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<Void> 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<Void> 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<Void> 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
-
startTranscribingAsync
public Future<Void> 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<Void> 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
-
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.
-
getAuthorizationToken
public String getAuthorizationToken()
Gets the Cognitive Speech authorization token.- Returns:
- The authorization token
-
close
public void close()
Dispose of associated resources. Note: close() must be called in order to relinquish underlying resources held by the object.- Specified by:
closein interfaceAutoCloseable
-
getImpl
public SafeHandle getImpl()
Returns the internal conversation translator instance- Returns:
- The internal conversation translator instance
-
-