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

Fix for regression, and test #410

Merged
merged 2 commits into from
Aug 3, 2021
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
51 changes: 14 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "microsoft-cognitiveservices-speech-sdk",
"author": "Microsoft Corporation",
"homepage": "https://docs.microsoft.com/azure/cognitive-services/speech-service/",
"version": "1.15.0-alpha.0.1",
"version": "1.18.1-alpha.0.1",
"license": "MIT",
"description": "Microsoft Cognitive Services Speech SDK for JavaScript",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/common.speech/ServiceMessages/DetailedSpeechPhrase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class DetailedSpeechPhrase implements IDetailedSpeechPhrase {
}

public getJsonWithCorrectedOffsets(baseOffset: number): string {
if (!!this.privDetailedSpeechPhrase.NBest[0].Words) {
if (!!this.privDetailedSpeechPhrase.NBest && !!this.privDetailedSpeechPhrase.NBest[0].Words) {
const firstWordOffset: number = this.privDetailedSpeechPhrase.NBest[0].Words[0].Offset;
if (firstWordOffset && firstWordOffset < baseOffset) {
const offset: number = baseOffset - firstWordOffset;
Expand Down
28 changes: 27 additions & 1 deletion tests/SpeechRecognizerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,32 @@ describe.each([true])("Service based tests", (forceNodeWebSocket: boolean) => {
});
});

test("Detailed output continuous recognition stops correctly", (done: jest.DoneCallback) => {
// tslint:disable-next-line:no-console
console.info("Detailed output continuous recognition stops correctly");
const s: sdk.SpeechConfig = BuildSpeechConfig();
objsToClose.push(s);
s.speechRecognitionLanguage = "en-US";
s.outputFormat = sdk.OutputFormat.Detailed;

const config: sdk.AudioConfig = WaveFileAudioInput.getAudioConfigFromFile(Settings.LongerWaveFile);

const r: sdk.SpeechRecognizer = new sdk.SpeechRecognizer(s, config);
objsToClose.push(r);
expect(r).not.toBeUndefined();
expect(r instanceof sdk.Recognizer);

r.sessionStopped = (s: sdk.Recognizer, e: sdk.SessionEventArgs): void => {
done();
};

r.recognizing = (s: sdk.Recognizer, e: sdk.SpeechRecognitionEventArgs): void => {
r.stopContinuousRecognitionAsync();
};

r.startContinuousRecognitionAsync();
}, 15000);

test("PushStream start-stop-start continuous recognition on PushStream", (done: jest.DoneCallback) => {
// tslint:disable-next-line:no-console
console.info("Name: PushStream start-stop-start continuous recognition on PushStream");
Expand Down Expand Up @@ -1498,7 +1524,7 @@ describe.each([true])("Service based tests", (forceNodeWebSocket: boolean) => {

test("RecognizeOnceAsync is async", (done: jest.DoneCallback) => {
// tslint:disable-next-line:no-console
console.info("Name: ecognizeOnceAsync is async");
console.info("Name: RecognizeOnceAsync is async");
const s: sdk.SpeechConfig = BuildSpeechConfig();
objsToClose.push(s);

Expand Down