fix pronunciation assessment continuous tests failure (#761)

This commit is contained in:
Yulin Li 2023-11-15 23:14:24 +08:00 коммит произвёл GitHub
Родитель 25819dfd2b
Коммит 8af94521f9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -9,16 +9,20 @@ import {
import { RecognitionStatus } from "./Exports.js";
export class EnumTranslation {
public static implTranslateRecognitionResult(recognitionStatus: RecognitionStatus): ResultReason {
public static implTranslateRecognitionResult(recognitionStatus: RecognitionStatus, expectEndOfDictation: boolean = false): ResultReason {
let reason = ResultReason.Canceled;
switch (recognitionStatus) {
case RecognitionStatus.Success:
reason = ResultReason.RecognizedSpeech;
break;
case RecognitionStatus.EndOfDictation:
// If we need the result in EndOfDictation (typically some session level result),
// translate into RecognizedSpeech, otherwise NoMatch
reason = expectEndOfDictation ? ResultReason.RecognizedSpeech : ResultReason.NoMatch;
break;
case RecognitionStatus.NoMatch:
case RecognitionStatus.InitialSilenceTimeout:
case RecognitionStatus.BabbleTimeout:
case RecognitionStatus.EndOfDictation:
reason = ResultReason.NoMatch;
break;
case RecognitionStatus.Error:

Просмотреть файл

@ -115,6 +115,7 @@ export abstract class ServiceRecognizerBase implements IDisposable {
protected privSuccessCallback: (e: SpeechRecognitionResult) => void;
protected privErrorCallback: (e: string) => void;
protected privEnableSpeakerId: boolean = false;
protected privExpectContentAssessmentResponse: boolean = false;
public constructor(
authentication: IAuthentication,
@ -511,6 +512,10 @@ export abstract class ServiceRecognizerBase implements IDisposable {
return this.privActivityTemplate;
}
public set expectContentAssessmentResponse(value: boolean) {
this.privExpectContentAssessmentResponse = value;
}
protected abstract processTypeSpecificMessages(
connectionMessage: SpeechConnectionMessage,
successCallback?: (e: SpeechRecognitionResult) => void,

Просмотреть файл

@ -88,7 +88,7 @@ export class SpeechServiceRecognizer extends ServiceRecognizerBase {
break;
case "speech.phrase":
const simple: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(connectionMessage.textBody);
const resultReason: ResultReason = EnumTranslation.implTranslateRecognitionResult(simple.RecognitionStatus);
const resultReason: ResultReason = EnumTranslation.implTranslateRecognitionResult(simple.RecognitionStatus, this.privExpectContentAssessmentResponse);
this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + simple.Offset + simple.Duration);

Просмотреть файл

@ -80,6 +80,7 @@ export class PronunciationAssessmentConfig {
public applyTo(recognizer: Recognizer): void {
this.updateJson();
const recoBase = recognizer.internalData as ServiceRecognizerBase;
recoBase.expectContentAssessmentResponse = !!this.privContentAssessmentTopic;
recoBase.speechContext.setPronunciationAssessmentParams(
this.properties.getProperty(PropertyId.PronunciationAssessment_Params),
this.privContentAssessmentTopic,