Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add result id #683

Merged
merged 5 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/common.speech/Transcription/ConversationServiceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ConversationExpirationEventArgs,
ConversationTranslationCanceledEventArgs,
ConversationTranslationResult,
ResultReason,
Translations
} from "../../sdk/Exports";
import {
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
30 changes: 30 additions & 0 deletions src/sdk/ResultReason.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

/**
* <summary>
* 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,
}