Class 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
    • 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:
        close in interface AutoCloseable
      • getImpl

        public SafeHandle getImpl()
        Returns the internal conversation translator instance
        Returns:
        The internal conversation translator instance