共用方式為


Class SPXConversationTranslator

Declaration

@class SPXConversationTranslator : NSObject;

Description

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.

Methods

init

- (instancetype _Nullable)init

init:

Initializes a new instance of a conversation translator using the default configuration.

- (instancetype _Nullable)init:(NSError * _Nullable * _Nullable)outError

Parameters

  • outError - error information.

Returns

a conversation translator instance.

initWithAudioConfiguration:

Initializes a new instance of a conversation translator using the specified audio configuration.

- (instancetype _Nullable)initWithAudioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration

Parameters

  • audioConfiguration - audio configuration.

Returns

a conversation translator instance.

initWithAudioConfiguration:error:

Initializes a new instance of a conversation translator using the specified audio configuration.

- (instancetype _Nullable)initWithAudioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • audioConfiguration - audio configuration.

Returns

a conversation translator instance.

joinConversationAsync:conversation:nickname:

Joins an existing conversation. You should use this method if you have created a conversation using createConversationAsync.

- (void)joinConversationAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    conversation:(SPXConversation * _Nonnull)conversation nickname:(NSString * _Nonnull)nickname

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • conversation - conversation instance.
  • nickname - The display name to use for the current participant.

joinConversationAsync:conversation:nickname:error:

Joins an existing conversation. You should use this method if you have created a conversation using createConversationAsync.

- (BOOL)joinConversationAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    conversation:(SPXConversation * _Nonnull)conversation nickname:(NSString * _Nonnull)nickname
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • conversation - conversation instance.
  • nickname - The display name to use for the current participant.
  • outError - error information.

joinConversationAsync:conversationId:nickname:language:

Joins an existing conversation. You should use this method if you have created a conversation using createConversationAsync.

- (void)joinConversationAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    conversationId:(NSString * _Nonnull)conversationId nickname:(NSString * _Nonnull)nickname
    language:(NSString * _Nonnull)language

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • conversationId - conversation id.
  • nickname - The display name to use for the current participant.
  • language - The speech language to use for the current participant.

joinConversationAsync:conversationId:nickname:language:error:

Joins an existing conversation. You should use this method if you have created a conversation using createConversationAsync.

- (BOOL)joinConversationAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    conversationId:(NSString * _Nonnull)conversationId nickname:(NSString * _Nonnull)nickname
    language:(NSString * _Nonnull)language error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • conversationId - conversation id.
  • nickname - The display name to use for the current participant.
  • language - The speech language to use for the current participant.
  • outError - error information.

leaveConversationAsync:

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

- (void)leaveConversationAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler

Parameters

  • completedHandler - the block function to be called when async operation has been completed.

leaveConversationAsync:error:

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

- (BOOL)leaveConversationAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • outError - error information.

sendTextMessageAsync:message:

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

- (void)sendTextMessageAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    message:(NSString * _Nonnull)message

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • message - The message to send.

sendTextMessageAsync:message:error:

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

- (BOOL)sendTextMessageAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    message:(NSString * _Nonnull)message error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • message - The message to send.
  • outError - error information.

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.

- (void)startTranscribingAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler

Parameters

  • completedHandler - the block function to be called when async operation has been completed.

startTranscribingAsync:error:

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.

- (BOOL)startTranscribingAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • outError - error information.

stopTranscribingAsync:

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

- (void)stopTranscribingAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler

Parameters

  • completedHandler - the block function to be called when async operation has been completed.

stopTranscribingAsync:error:

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

- (BOOL)stopTranscribingAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • outError - error information.

setAuthorizationToken:region:

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

- (void)setAuthorizationToken:(NSString * _Nonnull)authToken region:(NSString * _Nonnull)region

Parameters

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

setAuthorizationToken:region:error:

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

- (BOOL)setAuthorizationToken:(NSString * _Nonnull)authToken region:(NSString * _Nonnull)region
    error:(NSError * _Nullable * _Nullable)outError

Parameters

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

addTranscribedEventHandler:

Subscribes to the Transcribed event which indicates that a final result has been transcribed.

- (void)addTranscribedEventHandler:(SPXConversationTranslationEventHandler _Nonnull)eventHandler

addTranscribingEventHandler:

Subscribes to the Transcribing event which indicates an that intermediate result has been transcribed.

- (void)addTranscribingEventHandler:(SPXConversationTranslationEventHandler _Nonnull)eventHandler

addTextMessageReceivedEventHandler:

Subscribes to the TextMessageReceived event that signals a translated text message from a conversation participant.

- (void)addTextMessageReceivedEventHandler:(SPXConversationTranslationEventHandler _Nonnull)eventHandler

addCanceledEventHandler:

Subscribes to the Canceled event which indicates that an error occurred during transcription.

- (void)addCanceledEventHandler:(SPXConversationTranslationCanceledEventHandler _Nonnull)eventHandler

addConversationParticipantsChangedEventHandler:

Subscribes to the ConversationParticipantsChanged event that signals participants in the room have changed (e.g. a new participant joined).

- (void)addConversationParticipantsChangedEventHandler:(SPXConversationParticipantsChangedEventHandler _Nonnull)eventHandler

addConversationExpirationEventHandler:

Subscribes to the ConversationExpiration event that signals how many more minutes are left before the conversation expires.

- (void)addConversationExpirationEventHandler:(SPXConversationExpirationEventHandler _Nonnull)eventHandler

addSessionStartedEventHandler:

Subscribes to the SessionStarted event using the specified handler.

- (void)addSessionStartedEventHandler:(SPXConversationSessionEventHandler _Nonnull)eventHandler

addSessionStoppedEventHandler:

Subscribes to the SessionStopped event using the specified handler.

- (void)addSessionStoppedEventHandler:(SPXConversationSessionEventHandler _Nonnull)eventHandler

Properties

authorizationToken

@property (readonly, copy, nonatomic) NSString * _Nullable authorizationToken;

Authorization token used to communicate with the conversation translation 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.

participantId

@property (readonly, copy, nonatomic) NSString * _Nullable participantId;

Participant identifier used for conversation translation.