Skip to content

Commit

Permalink
Selectable audio input device (#3079)
Browse files Browse the repository at this point in the history
* Bump versions

* Select audo input device

* Clean up

* Detect Web Audio support

* Add sample

* Converge version of Carbon SDK

* Add entry

* Add and update entries

* Skip warning if AudioConfig is presented

* Add test

* Add tests

* Add authorization token from webchat-waterbottle

* Enable IE11

* Add notes

* Use daily build

* Use daily build

* Clean up

* Apply suggestions from code review

Co-Authored-By: Corina <14900841+corinagum@users.noreply.github.com>

* Support Direct Line Speech

* Add Direct Line Speech test

* Add Direct Line Speech test

* Fix Direct Line Speech tests

* Improve test reliability

* Save WAV files for failures

* Add message

* Use mockbot-streaming token

* Improve reliability

* Test reliability

* Remove buffer bar

* Remove commented out code

* Add Direct Line Speech

* Apply suggestions from code review

Co-Authored-By: Corina <14900841+corinagum@users.noreply.github.com>

* Apply PR suggestions

* Update entry

* Include @babel/plugin-proposal-class-properties

* Fix tests

Co-authored-by: Corina <14900841+corinagum@users.noreply.github.com>
  • Loading branch information
compulim and corinagum authored Apr 22, 2020
1 parent 23a0537 commit 7425004
Show file tree
Hide file tree
Showing 95 changed files with 2,770 additions and 782 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/__tests__/__image_snapshots__/**/__diff_output__
/.env
/coverage
/debug.log
/gh-pages
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Resolves [#2897](https://github.com/microsoft/BotFramework-WebChat/issues/2897). Moved from JUnit to VSTest reporter with file attachments, by [@compulim](https://github.com/compulim) in PR [#2990](https://github.com/microsoft/BotFramework-WebChat/pull/2990)
- Added `aria-label` attribute support for default Markdown engine, by [@patniko](https://github.com/patniko) in PR [#3022](https://github.com/microsoft/BotFramework-WebChat/pull/3022)
- Resolves [#2969](https://github.com/microsoft/BotFramework-WebChat/issues/2969). Support sovereign cloud for Cognitive Services Speech Services, by [@compulim](https://github.com/compulim) in PR [#3040](https://github.com/microsoft/BotFramework-WebChat/pull/3040)
- Resolves [#2481](https://github.com/microsoft/BotFramework-WebChat/issues/2481). Support selecting different audio input devices for Cognitive Services Speech Services, by [@compulim](https://github.com/compulim) in PR [#3079](https://github.com/microsoft/BotFramework-WebChat/pull/3079)

### Fixed

Expand All @@ -43,6 +44,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixes [#3074](https://github.com/microsoft/BotFramework-WebChat/issues/3074). Keep `props.locale` when sending to the bot, by [@compulim](https://github.com/compulim) in PR [#3095](https://github.com/microsoft/BotFramework-WebChat/issue/3095)
- Fixes [#3096](https://github.com/microsoft/BotFramework-WebChat/issues/3096). Use `<ScreenReaderText>` instead of `aria-label` for message bubbles, by [@compulim](https://github.com/compulim) in PR [#3097](https://github.com/microsoft/BotFramework-WebChat/issue/3097)
- Fixes [#2876](https://github.com/microsoft/BotFramework-WebChat/issues/2876). `messageBack` and `postBack` should send even if both `text` and `value` is falsy or `undefined`, by [@compulim](https://github.com/compulim) in PR [#3120](https://github.com/microsoft/BotFramework-WebChat/issues/3120)
- Fixes [#2668](https://github.com/microsoft/BotFramework-WebChat/issues/2668). Disable Web Audio on insecure connections, by [@compulim](https://github.com/compulim) in PR [#3079](https://github.com/microsoft/BotFramework-WebChat/issue/3079)

### Changed

Expand Down Expand Up @@ -102,11 +104,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [`core-js@3.6.4`](https://npmjs.com/package/core-js)
- Bumped Chrome Docker image to `3.141.59-zirconium` (Chrome 80.0.3987.106), by [@compulim](https://github.com/compulim) in PR [#2992](https://github.com/microsoft/BotFramework-WebChat/pull/2992)
- Added `4.8.0` to `embed/servicingPlan.json`, by [@compulim](https://github.com/compulim) in PR [#2986](https://github.com/microsoft/BotFramework-WebChat/pull/2986)
- Bumped `microsoft-cognitiveservices-speech-sdk@1.10.1` and `web-speech-cognitive-services@6.1.0`, by [@compulim](https://github.com/compulim) in PR [#3040](https://github.com/BotFramework-WebChat/pull/3040)
- Bumped `microsoft-cognitiveservices-speech-sdk@1.10.1` and `web-speech-cognitive-services@6.1.0`, by [@compulim](https://github.com/compulim) in PR [#3040](https://github.com/microsoft/BotFramework-WebChat/pull/3040)
- Resolved [#2886](https://github.com/microsoft/BotFramework-WebChat/issues/2886) and [#2987](https://github.com/microsoft/BotFramework-WebChat/issue/2987), converged all references of [`microsoft-cognitiveservices-speech-sdk`](https://npmjs.com/package/microsoft-cognitiveservices-speech-sdk) to reduce footprint, by [@compulim](https://github.com/compulim) in PR [#3079](https://github.com/microsoft/BotFramework-WebChat/pull/3079)

## Samples

- Resolves [#2806](https://github.com/microsoft/BotFramework-WebChat/issues/2806), added [Single sign-on with On Behalf Of Token Authentication](https://webchat-sample-obo.azurewebsites.net/) sample, by [@tdurnford](https://github.com/tdurnford) in [#2865](https://github.com/microsoft/BotFramework-WebChat/pull/2865)
- Resolves [#2481](https://github.com/microsoft/BotFramework-WebChat/issues/2481), added selectable audio input device sample, by [@compulim](https://github.com/compulim) in PR [#3079](https://github.com/microsoft/BotFramework-WebChat/pull/3079)

## [4.8.0] - 2020-03-05

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions __tests__/html/__jest__/fetchSpeechServicesAuthorizationToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fetch from 'node-fetch';

export default async function fetchSpeechServicesAuthorizationToken({ region, subscriptionKey, tokenURL }) {
if (!region && !tokenURL) {
throw new Error('Either "region" or "tokenURL" must be specified.');
} else if (region && tokenURL) {
throw new Error('Only either "region" or "tokenURL" can be specified.');
} else if (!subscriptionKey) {
throw new Error('"subscriptionKey" must be specified.');
}

const res = await fetch(tokenURL || `https://${region}.api.cognitive.microsoft.com/sts/v1.0/issueToken`, {
headers: {
'Ocp-Apim-Subscription-Key': subscriptionKey
},
method: 'POST'
});

if (!res.ok) {
throw new Error(`Failed to fetch authorization token, server returned ${res.status}`);
}

return await res.text();
}
26 changes: 19 additions & 7 deletions __tests__/html/__jest__/runPageProcessor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { join } from 'path';
import { promisify } from 'util';
import { tmpdir } from 'os';
import createDeferred from 'p-defer';
import fs from 'fs';

import { imageSnapshotOptions } from '../../constants.json';
import createJobObservable from './createJobObservable';
Expand All @@ -9,6 +12,8 @@ const customImageSnapshotOptions = {
customSnapshotsDir: join(__dirname, '../../__image_snapshots__/html')
};

const writeFile = promisify(fs.writeFile);

export default async function runPageProcessor(driver, { ignoreConsoleError = false, ignorePageError = false } = {}) {
const webChatLoaded = await driver.executeScript(() => !!window.WebChat);
const webChatTestLoaded = await driver.executeScript(() => !!window.WebChatTest);
Expand Down Expand Up @@ -51,18 +56,25 @@ export default async function runPageProcessor(driver, { ignoreConsoleError = fa
},
next: async ({ deferred, job }) => {
try {
let result;

if (job.type === 'snapshot') {
try {
expect(await driver.takeScreenshot()).toMatchImageSnapshot(customImageSnapshotOptions);
deferred.resolve();
} catch (err) {
pageResultDeferred.reject(err);
deferred.reject(err);
}
expect(await driver.takeScreenshot()).toMatchImageSnapshot(customImageSnapshotOptions);
} else if (job.type === 'save file') {
const filename = join(tmpdir(), `${Date.now()}-${job.payload.filename}`);

await writeFile(filename, Buffer.from(job.payload.base64, 'base64'));

console.log(`Saved to ${filename}`);

result = filename;
} else {
throw new Error(`Unknown job type "${job.type}".`);
}

deferred.resolve(result);
} catch (err) {
pageResultDeferred.reject(err);
deferred.reject(err);
}
}
Expand Down
28 changes: 13 additions & 15 deletions __tests__/html/__jest__/setupRunHTMLTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,22 @@ global.runHTMLTest = async (
const params = parseURLParams(new URL(url, 'http://webchat2/').hash);

try {
// For unknown reason, if we use ?wd=1, it will be removed.
// But when we use #wd=1, it kept.
// We are only parsing the "hash" from "url", the "http://localhost/" is actually ignored.
let { hash } = new URL(url, 'http://localhost/');

if (global.docker) {
params.wd = 1;
if (hash) {
hash += '&wd=1';
} else {
hash = '#wd=1';
}

const baseURL = global.docker
? new URL(url, 'http://webchat2/')
: new URL(url, `http://localhost:${global.webServerPort}/`);

const hash =
'#' +
Object.entries(params)
.map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`)
.join('&');

await driver.get(new URL(hash, baseURL));
// For unknown reason, if we use ?wd=1, it will be removed.
// But when we use #wd=1, it kept.
await driver.get(
global.docker
? new URL(hash, new URL(url, 'http://webchat2/'))
: new URL(url, `http://localhost:${global.webServerPort}/`)
);

await runPageProcessor(driver, { ignoreConsoleError, ignorePageError });

Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.fatalError.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<body>
<div id="webchat"></div>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, shareObservable, timeouts, token } = window.WebChatTest;

(async function() {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.firstConnect.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="webchat"></div>
<script crossorigin="anonymous" src="https://unpkg.com/lolex@4/lolex.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, shareObservable, timeouts, token } = window.WebChatTest;

(async function() {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.invalidCredentials.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<body>
<div id="webchat"></div>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, timeouts } = window.WebChatTest;

(async function() {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.networkInterrupt.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="webchat"></div>
<script crossorigin="anonymous" src="https://unpkg.com/lolex@4/lolex.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, shareObservable, timeouts, token } = window.WebChatTest;

(async function() {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.sendFailed.noAck.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="webchat"></div>
<script crossorigin="anonymous" src="https://unpkg.com/lolex@4/lolex.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, shareObservable, timeouts, token } = window.WebChatTest;

(async function() {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.sendFailed.notSend.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="webchat"></div>
<script crossorigin="anonymous" src="https://unpkg.com/lolex@4/lolex.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, timeouts, token } = window.WebChatTest;

(async function() {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.slowNetwork.firstConnect.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="webchat"></div>
<script crossorigin="anonymous" src="https://unpkg.com/lolex@4/lolex.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, updateIn, timeouts, token } = window.WebChatTest;

(async function() {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/offlineUI.slowNetwork.reconnect.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="webchat"></div>
<script crossorigin="anonymous" src="https://unpkg.com/lolex@4/lolex.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script type="text/babel" data-presets="es2015,stage-3">
<script type="text/babel" data-presets="env,stage-3">
const { conditions, createStore, host, pageObjects, shareObservable, timeouts, token } = window.WebChatTest;

(async function() {
Expand Down
Loading

0 comments on commit 7425004

Please sign in to comment.