Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ces-speech-sdk-js into release/1.33
  • Loading branch information
BrianMouncer committed Nov 8, 2023
2 parents 99a0f86 + a8ecf1a commit 4d74a98
Show file tree
Hide file tree
Showing 34 changed files with 59 additions and 13 deletions.
4 changes: 2 additions & 2 deletions bundleApp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

window.SpeechSDK = require('./distrib/lib/microsoft.cognitiveservices.speech.sdk.js');

import * as SpeechSDK from './distrib/lib/microsoft.cognitiveservices.speech.sdk.js';
window.SpeechSDK = SpeechSDK;
6 changes: 5 additions & 1 deletion gulpfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
gulp.task('build', gulp.series(function build() {
return gulp.src([
'src/**/*.ts',
'!src/common.browser/__mocks__/',
'!src/common.browser/__mocks__/**',
'microsoft.cognitiveservices.speech.sdk.ts'],
{ base: '.' })
.pipe(eslint({
Expand All @@ -37,7 +39,9 @@
entry: {
'microsoft.cognitiveservices.speech.sdk.bundle': './bundleApp.js',
},
output: { filename: '[name].js' },
output: {
filename: '[name].js',
},
devtool: 'source-map',
module: {
rules: [{
Expand Down
6 changes: 0 additions & 6 deletions src/common.browser/AudioWorkerUrl.ts

This file was deleted.

4 changes: 1 addition & 3 deletions src/common.browser/PCMRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ export class PcmRecorder implements IRecorder {

if (!!context.audioWorklet && !skipAudioWorklet) {
/* eslint-disable-next-line */
const audioUrl = require("./AudioWorkerUrl");
/* eslint-disable-next-line */
this.privSpeechProcessorScript = audioUrl.getAudioWorkerUrl();
this.privSpeechProcessorScript = new URL( /* webpackChunkName: 'script_processor_audioWorklet' */ "speech-processor.js", import.meta.url).toString();

context.audioWorklet
.addModule(this.privSpeechProcessorScript)
Expand Down
22 changes: 22 additions & 0 deletions src/common.browser/__mocks__/PCMRecorder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import { Stream } from "../../common/Exports.js";
import { IRecorder } from "../IRecorder.js";

export class PcmRecorder implements IRecorder {
public constructor(stopInputOnRelease: boolean) {
void stopInputOnRelease;
}
public record(context: AudioContext, mediaStream: MediaStream, outputStream: Stream<ArrayBuffer>): void {
void context;
void mediaStream;
void outputStream;
}
public releaseMediaResources(context: AudioContext): void {
void context;
}
public setWorkletUrl(url: string): void {
void url;
}
}
1 change: 1 addition & 0 deletions tests/AudioOutputStreamTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Settings } from "./Settings";
import { closeAsyncObjects } from "./Utilities";

let objsToClose: any[];
jest.mock("../src/common.browser/PCMRecorder");

beforeAll(() => {
// Override inputs, if necessary
Expand Down
1 change: 1 addition & 0 deletions tests/AutoSourceLangDetectionTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Settings } from "./Settings";
import { closeAsyncObjects, WaitForCondition } from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];
const defaultTargetLanguage: string = "de-DE";

Expand Down
1 change: 1 addition & 0 deletions tests/ConnectionTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {

import * as fs from "fs";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/ConversationTranscriberTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Settings } from "./Settings";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";
import { closeAsyncObjects, RepeatingPullStream, WaitForCondition } from "./Utilities";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/ConversationTranslatorTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
// eslint-disable-next-line no-console
const consoleInfo = console.info;

Expand Down
2 changes: 1 addition & 1 deletion tests/DiagnosticsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as sdk from "../microsoft.cognitiveservices.speech.sdk";
import { Settings } from "./Settings";
import { closeAsyncObjects, WaitForCondition } from "./Utilities";


jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll((): void => {
Expand Down
1 change: 1 addition & 0 deletions tests/DialogServiceConnectorTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
} from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
type Callback = (result?: any) => void;
// eslint-disable-next-line no-console
const consoleInfo = console.info;
Expand Down
1 change: 1 addition & 0 deletions tests/DynamicGrammarTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "../src/common.speech/Exports";
import { Settings } from "./Settings";

jest.mock("../src/common.browser/PCMRecorder");
beforeAll(() => {
// Override inputs, if necessary
Settings.LoadSettings();
Expand Down
1 change: 1 addition & 0 deletions tests/GeneralRecognizerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as sdk from "../microsoft.cognitiveservices.speech.sdk";
import { Settings } from "./Settings";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let bufferSize: number;
beforeEach(() => {
// eslint-disable-next-line no-console
Expand Down
1 change: 1 addition & 0 deletions tests/IntentRecognizerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

import { AudioStreamFormatImpl } from "../src/sdk/Audio/AudioStreamFormat";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];
let bufferSize: number;

Expand Down
1 change: 1 addition & 0 deletions tests/LanguageModelTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as sdk from "../microsoft.cognitiveservices.speech.sdk";
import { LanguageUnderstandingModelImpl } from "../src/sdk/LanguageUnderstandingModel";
import { Settings } from "./Settings";
jest.mock("../src/common.browser/PCMRecorder");

beforeAll(() => {
// Override inputs, if necessary
Expand Down
1 change: 1 addition & 0 deletions tests/LongRunning/SpeechRecoAuthTokenErrorMessageTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Events } from "../../src/common/Exports";
import { Settings } from "../Settings";
import { CreateRepeatingPullStream, WaitForCondition } from "../Utilities";

jest.mock("../../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/LongRunning/SpeechRecoAuthTokenRefreshTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Events } from "../../src/common/Exports";
import { Settings } from "../Settings";
import { CreateRepeatingPullStream, WaitForCondition } from "../Utilities";

jest.mock("../../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/LongRunning/SpeechRecoReconnectTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { WaveFileAudioInput } from "../WaveFileAudioInputStream";

import { WaitForCondition } from "../Utilities";

jest.mock("../../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll((): void => {
Expand Down
1 change: 1 addition & 0 deletions tests/LongRunning/TranslationRecoReconnectTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { WaveFileAudioInput } from "../WaveFileAudioInputStream";

import { WaitForCondition } from "../Utilities";

jest.mock("../../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll((): void => {
Expand Down
1 change: 1 addition & 0 deletions tests/MeetingTranscriberTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Settings } from "./Settings";
import { closeAsyncObjects } from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

function sleep(milliseconds: number): Promise<any> {
Expand Down
1 change: 1 addition & 0 deletions tests/PronunciationAssessmentTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Settings } from "./Settings";
import { closeAsyncObjects, WaitForCondition } from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll((): void => {
Expand Down
1 change: 1 addition & 0 deletions tests/PullInputStreamTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from "../src/sdk/Audio/AudioStreamFormat";
import { Settings } from "./Settings";

jest.mock("../src/common.browser/PCMRecorder");
let bufferSize: number;

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/PushInputStreamTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "../src/sdk/Audio/AudioStreamFormat";
import { Settings } from "./Settings";

jest.mock("../src/common.browser/PCMRecorder");
let bufferSize: number;
beforeAll(() => {
// Override inputs, if necessary
Expand Down
1 change: 1 addition & 0 deletions tests/ReplayableAudioNodeTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "../src/common/Exports";
import { AudioStreamFormatImpl } from "../src/sdk/Audio/AudioStreamFormat";

jest.mock("../src/common.browser/PCMRecorder");
let readCount: number;
const targetBytes: number = 4096;
const defaultAudioFormat: AudioStreamFormatImpl = sdk.AudioStreamFormat.getDefaultInputFormat() as AudioStreamFormatImpl;
Expand Down
1 change: 1 addition & 0 deletions tests/SpeechConfigTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Settings } from "./Settings";
import { closeAsyncObjects } from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];
beforeAll((): void => {
// Override inputs, if necessary
Expand Down
1 change: 1 addition & 0 deletions tests/SpeechContextTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SpeechContext,
} from "../src/common.speech/Exports";
import { Settings } from "./Settings";
jest.mock("../src/common.browser/PCMRecorder");

beforeAll(() => {
// Override inputs, if necessary
Expand Down
1 change: 1 addition & 0 deletions tests/SpeechRecognizerSilenceTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { closeAsyncObjects, WaitForCondition } from "./Utilities";

import { AudioStreamFormatImpl } from "../src/sdk/Audio/AudioStreamFormat";

jest.mock("../src/common.browser/PCMRecorder");
const FIRST_EVENT_ID: number = 1;
const Recognizing: string = "Recognizing";
const Recognized: string = "Recognized";
Expand Down
1 change: 1 addition & 0 deletions tests/SpeechRecognizerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const Recognized: string = "Recognized";
const Canceled: string = "Canceled";

let objsToClose: any[];
jest.mock("../src/common.browser/PCMRecorder");

beforeAll(() => {
// override inputs, if necessary
Expand Down
1 change: 1 addition & 0 deletions tests/SpeechSynthesisTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
WaitForCondition
} from "./Utilities";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/TranslationRecognizerBasicsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

import { AudioStreamFormatImpl } from "../src/sdk/Audio/AudioStreamFormat";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/TranslationRecognizerTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/TranslationSynthTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll(() => {
Expand Down
1 change: 1 addition & 0 deletions tests/VoiceProfileClientTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Settings } from "./Settings";
import { closeAsyncObjects } from "./Utilities";
import { WaveFileAudioInput } from "./WaveFileAudioInputStream";

jest.mock("../src/common.browser/PCMRecorder");
let objsToClose: any[];

beforeAll((): void => {
Expand Down

0 comments on commit 4d74a98

Please sign in to comment.