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

Configuring off speech synthesis #2408

Merged
merged 2 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix [#2298](https://github.com/microsoft/BotFramework-WebChat/issues/2298). Speech synthesize errors to be ignored, by [@compulim](https://github.com/compulim) in PR [#2300](https://github.com/microsoft/BotFramework-WebChat/issues/2300)
- Fix [#2243](https://github.com/microsoft/BotFramework-WebChat/issues/2243). Fixed sagas to correctly mark activities with speaking attachments, by [@tdurnford](https://github.com/tdurnford) in PR [#2320](https://github.com/microsoft/BotFramework-WebChat/issues/2320)
- Fix [#2365](https://github.com/microsoft/BotFramework-WebChat/issues/2365). Fix Adaptive Card `pushButton` appearance on Chrome, by [@corinagum](https://github.com/corinagum) in PR [#2382](https://github.com/microsoft/BotFramework-WebChat/pull/2382)
- Fix [#2379](https://github.com/microsoft/BotFramework-WebChat/issues/2379). Speech synthesis can be configured off by passing `null`, by [@compulim](https://github.com/compulim) in PR [#XXX](https://github.com/microsoft/BotFramework-WebChat/pull/XXX)
compulim marked this conversation as resolved.
Show resolved Hide resolved

### Added

Expand Down
3 changes: 3 additions & 0 deletions __tests__/setup/pageObjects/getConsoleLogs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async function getConsoleLogs(driver) {
return await driver.executeScript(() => window.__console__);
}
2 changes: 2 additions & 0 deletions __tests__/setup/pageObjects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dispatchAction from './dispatchAction';
import endSpeechSynthesize from './endSpeechSynthesize';
import errorSpeechSynthesize from './errorSpeechSynthesize';
import executePromiseScript from './executePromiseScript';
import getConsoleLogs from './getConsoleLogs';
import getNotificationText from './getNotificationText';
import getNumActivitiesShown from './getNumActivitiesShown';
import getSendBoxText from './getSendBoxText';
Expand Down Expand Up @@ -37,6 +38,7 @@ export default function pageObjects(driver) {
endSpeechSynthesize,
errorSpeechSynthesize,
executePromiseScript,
getConsoleLogs,
getNotificationText,
getNumActivitiesShown,
getSendBoxText,
Expand Down
24 changes: 24 additions & 0 deletions __tests__/speech.synthesis.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,28 @@ describe('speech synthesis', () => {

await expect(speechRecognitionStartCalled().fn(driver)).resolves.toBeTruthy();
});

test('should not synthesis if engine is explicitly configured off', async () => {
const { driver, pageObjects } = await setupWebDriver({
props: {
webSpeechPonyfillFactory: () => {
const { SpeechGrammarList, SpeechRecognition } = window.WebSpeechMock;

return {
SpeechGrammarList,
SpeechRecognition,
speechSynthesis: null,
SpeechSynthesisUtterance: null
};
}
}
});

await pageObjects.sendMessageViaMicrophone('Hello, World!');

await expect(speechRecognitionStartCalled().fn(driver)).resolves.toBeFalsy();
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);

expect((await pageObjects.getConsoleLogs()).filter(([type]) => type === 'error')).toEqual([]);
});
});
8 changes: 5 additions & 3 deletions packages/component/src/BasicTranscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ const BasicTranscript = ({
>
{element}
{// TODO: [P2] We should use core/definitions/speakingActivity for this predicate instead
activity.channelData && activity.channelData.speak && <SpeakActivity activity={activity} />}
speechSynthesis && activity.channelData && activity.channelData.speak && (
<SpeakActivity activity={activity} />
)}
</li>
))}
</ul>
Expand Down Expand Up @@ -141,8 +143,8 @@ BasicTranscript.propTypes = {
}).isRequired
}).isRequired,
webSpeechPonyfill: PropTypes.shape({
speechSynthesis: PropTypes.any.isRequired,
SpeechSynthesisUtterance: PropTypes.any.isRequired
speechSynthesis: PropTypes.any,
SpeechSynthesisUtterance: PropTypes.any
})
};

Expand Down