set language property on TranslationRecognitionEventArgs (#736)
This commit is contained in:
Родитель
8cb9e719f9
Коммит
6848253d1d
|
@ -2,13 +2,14 @@
|
|||
// Licensed under the MIT license.
|
||||
|
||||
import { Contracts } from "../../sdk/Contracts";
|
||||
import { ITranslations } from "../Exports";
|
||||
import { IPrimaryLanguage, ITranslations } from "../Exports";
|
||||
import { TranslationStatus } from "../TranslationStatus";
|
||||
|
||||
// translation.hypothesis
|
||||
export interface ITranslationHypothesis {
|
||||
Duration: number;
|
||||
Offset: number;
|
||||
PrimaryLanguage?: IPrimaryLanguage;
|
||||
Text: string;
|
||||
Translation: ITranslations;
|
||||
}
|
||||
|
@ -48,4 +49,8 @@ export class TranslationHypothesis implements ITranslationHypothesis {
|
|||
public get Translation(): ITranslations {
|
||||
return this.privTranslationHypothesis.Translation;
|
||||
}
|
||||
|
||||
public get Language(): string {
|
||||
return this.privTranslationHypothesis.PrimaryLanguage?.Language;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -336,7 +336,6 @@ export class TranslationServiceRecognizer extends ConversationServiceRecognizer
|
|||
}
|
||||
|
||||
let resultReason: ResultReason;
|
||||
let language: string;
|
||||
let confidence: string;
|
||||
if (serviceResult instanceof TranslationPhrase) {
|
||||
if (!!serviceResult.Translation && serviceResult.Translation.TranslationStatus === TranslationStatus.Success) {
|
||||
|
@ -344,11 +343,11 @@ export class TranslationServiceRecognizer extends ConversationServiceRecognizer
|
|||
} else {
|
||||
resultReason = ResultReason.RecognizedSpeech;
|
||||
}
|
||||
language = serviceResult.Language;
|
||||
confidence = serviceResult.Confidence;
|
||||
} else {
|
||||
resultReason = ResultReason.TranslatingSpeech;
|
||||
}
|
||||
const language = serviceResult.Language;
|
||||
|
||||
const offset: number = serviceResult.Offset + this.privRequestSession.currentTurnAudioOffset;
|
||||
|
||||
|
|
|
@ -492,6 +492,8 @@ describe.each([true, false])("Service based tests", (forceNodeWebSocket: boolean
|
|||
expect(e.result.translations).not.toBeUndefined();
|
||||
expect(e.result.translations.languages[0]).toEqual(defaultTargetLanguage);
|
||||
expect(e.result.translations.get(defaultTargetLanguage)).toContain("Wie ist das");
|
||||
expect(e.result.language).not.toBeUndefined();
|
||||
expect(e.result.language).toEqual("en-US");
|
||||
}
|
||||
|
||||
r.recognized = (o: sdk.Recognizer, e: sdk.TranslationRecognitionEventArgs) => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче