diff --git a/src/common.speech/Transcription/ConversationServiceAdapter.ts b/src/common.speech/Transcription/ConversationServiceAdapter.ts index 455aaaea..5a4df8d1 100644 --- a/src/common.speech/Transcription/ConversationServiceAdapter.ts +++ b/src/common.speech/Transcription/ConversationServiceAdapter.ts @@ -15,6 +15,7 @@ import { ConversationExpirationEventArgs, ConversationTranslationCanceledEventArgs, ConversationTranslationResult, + ResultReason, Translations } from "../../sdk/Exports"; import { @@ -191,10 +192,11 @@ export class ConversationServiceAdapter extends ServiceRecognizerBase { } const sessionId: string = this.privConversationRequestSession.sessionId; + const conversationMessageType: string = message.conversationMessageType.toLowerCase(); let sendFinal: boolean = false; try { - switch (message.conversationMessageType.toLowerCase()) { + switch (conversationMessageType) { case "info": case "participant_command": case "command": @@ -432,12 +434,13 @@ export class ConversationServiceAdapter extends ServiceRecognizerBase { case "final": const speechPayload: SpeechResponsePayload = SpeechResponsePayload.fromJSON(message.textBody); + const conversationResultReason: ResultReason = (conversationMessageType === "final") ? ResultReason.TranslatedParticipantSpeech : ResultReason.TranslatingParticipantSpeech; const speechResult: ConversationTranslationResult = new ConversationTranslationResult(speechPayload.participantId, this.getTranslations(speechPayload.translations), speechPayload.language, - undefined, - undefined, + speechPayload.id, + conversationResultReason, speechPayload.recognition, undefined, undefined, @@ -478,6 +481,7 @@ export class ConversationServiceAdapter extends ServiceRecognizerBase { case "translated_message": const textPayload: TextResponsePayload = TextResponsePayload.fromJSON(message.textBody); + // TODO: (Native parity) a result reason should be set based whether the participantId is ours or not const textResult: ConversationTranslationResult = new ConversationTranslationResult(textPayload.participantId, this.getTranslations(textPayload.translations), diff --git a/src/sdk/ResultReason.ts b/src/sdk/ResultReason.ts index 8b345c0b..73a6cbe3 100644 --- a/src/sdk/ResultReason.ts +++ b/src/sdk/ResultReason.ts @@ -125,4 +125,34 @@ export enum ResultReason { * @member ResultReason.VoicesListRetrieved */ VoicesListRetrieved, + + /** + * Indicates the transcription result contains hypothesis text and its translation(s) for + * other participants in the conversation. + * @member ResultReason.TranslatingParticipantSpeech + */ + TranslatingParticipantSpeech, + + /** + * Indicates the transcription result contains final text and corresponding translation(s) + * for other participants in the conversation. Speech Recognition and Translation are now + * complete for this phrase. + * @member ResultReason.TranslatedParticipantSpeech + */ + TranslatedParticipantSpeech, + + /** + * + * Indicates the transcription result contains the instant message and corresponding + * translation(s). + * @member ResultReason.TranslatedInstantMessage + */ + TranslatedInstantMessage, + + /** + * Indicates the transcription result contains the instant message for other participants + * in the conversation and corresponding translation(s). + * @member ResultReason.TranslatedParticipantInstantMessage + */ + TranslatedParticipantInstantMessage, }