Skip to content

Commit

Permalink
Fix speech samples to use both 4.8 and pre-4.8 signature (#2916)
Browse files Browse the repository at this point in the history
* Update API signature

* Update format

* Update entry

* Formatting
  • Loading branch information
compulim authored Feb 19, 2020
1 parent cc5f275 commit 598c8cb
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 117 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixes [#2751](https://github.com/microsoft/BotFramework-WebChat/issues/2751). Move documentation to docs folder, by [@corinagum](https://github.com/corinagum) in PR [#2832](https://github.com/microsoft/BotFramework-WebChat/pull/2832)
- Fixes [#2838](https://github.com/microsoft/BotFramework-WebChat/issues/2838). Fixed `concatMiddleware` should allow any middleware to call its downstream middleware twice, by [@compulim](https://github.com/compulim) in PR [#2839](https://github.com/microsoft/BotFramework-WebChat/pull/2839)
- Fixes [#2864](https://github.com/microsoft/BotFramework-WebChat/issues/2864). Replaced `DownloadAttachment` and `UploadAttachment` with `FileAttachment`, which shows the download link and icon if the attachment contains the `contentUrl`, by [@compulim](https://github.com/compulim) in PR [#2868](https://github.com/microsoft/BotFramework-WebChat/pull/2868)
- Fixes [#2877](https://github.com/microsoft/BotFramework-WebChat/issues/2877). Updated Cognitive Services Speech Services samples to use both pre-4.8 and 4.8 API signature, by [@compulim](https://github.com/compulim) in PR [#2916](https://github.com/microsoft/BotFramework-WebChat/pull/2916)

### Changed

Expand Down
7 changes: 6 additions & 1 deletion samples/03.speech/b.cognitive-speech-services-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@
const webSpeechPonyfillFactory = await window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({
// We are passing the Promise function to the "credentials" field.
// This function will be called every time the token is being used.
credentials: fetchSpeechServicesCredentials
credentials: fetchSpeechServicesCredentials,

// The following code is needed only for Web Chat < 4.8.
// Starting from 4.8, we will support the newer "credentials" option, which is preferred over "authorizationToken" and "region".
authorizationToken: () => fetchSpeechServicesCredentials().then(({ authorizationToken }) => authorizationToken),
region: fetchSpeechServicesCredentials().then(({ region }) => region)
});

// Pass a Web Speech ponyfill factory to renderWebChat.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@
// We are passing the Promise function to the "credentials" field.
// This function will be called every time the token is being used.
credentials: fetchSpeechServicesCredentials,
textNormalization: 'lexical'
textNormalization: 'lexical',

// The following code is needed only for Web Chat < 4.8.
// Starting from 4.8, we will support the newer "credentials" option, which is preferred over "authorizationToken" and "region".
authorizationToken: () => fetchSpeechServicesCredentials().then(({ authorizationToken }) => authorizationToken),
region: fetchSpeechServicesCredentials().then(({ region }) => region)
});

// Pass a Web Speech ponyfill factory to renderWebChat.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@
{
// We are passing the Promise function to the "credentials" field.
// This function will be called every time the token is used.
credentials: fetchSpeechServicesCredentials
credentials: fetchSpeechServicesCredentials,

// The following code is needed only for Web Chat < 4.8.
// Starting from 4.8, we will support the newer "credentials" option, which is preferred over "authorizationToken" and "region".
authorizationToken: () => fetchSpeechServicesCredentials().then(({ authorizationToken }) => authorizationToken),
region: fetchSpeechServicesCredentials().then(({ region }) => region)
}
);

Expand Down
7 changes: 6 additions & 1 deletion samples/03.speech/e.select-voice/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@
const webSpeechPonyfillFactory = await window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({
// We are passing the Promise function to the "credentials" field.
// This function will be called every time the token is being used.
credentials: fetchSpeechServicesCredentials
credentials: fetchSpeechServicesCredentials,

// The following code is needed only for Web Chat < 4.8.
// Starting from 4.8, we will support the newer "credentials" option, which is preferred over "authorizationToken" and "region".
authorizationToken: () => fetchSpeechServicesCredentials().then(({ authorizationToken }) => authorizationToken),
region: fetchSpeechServicesCredentials().then(({ region }) => region)
});

window.WebChat.renderWebChat(
Expand Down
7 changes: 6 additions & 1 deletion samples/03.speech/g.hybrid-speech/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@
{
// We are passing the Promise function to the "credentials" field.
// This function will be called every time the token is being used.
credentials
credentials,

// The following code is needed only for Web Chat < 4.8.
// Starting from 4.8, we will support the newer "credentials" option, which is preferred over "authorizationToken" and "region".
authorizationToken: () => fetchSpeechServicesCredentials().then(({ authorizationToken }) => authorizationToken),
region: fetchSpeechServicesCredentials().then(({ region }) => region)
}
);

Expand Down
102 changes: 51 additions & 51 deletions samples/05.custom-components/i.notification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ First, implement a React component for the privacy policy toast without any logi

```js
const PrivacyPolicyToast = () => {
return (
<div aria-label="Privacy policy" role="dialog" className="app__privacyPolicyToast">
<i aria-hidden={true} className="ms-Icon ms-Icon--Compare app__privacyPolicyToast__icon" />
<span>
Do you consent to our{' '}
<a href="https://privacy.microsoft.com/" rel="noopener noreferrer" target="_blank">
privacy policy
</a>
?
</span>
<button className="app__privacyPolicyToast__button" type="button">
Yes
</button>{' '}
<button className="app__privacyPolicyToast__button" type="button">
No
</button>
</div>
);
return (
<div aria-label="Privacy policy" role="dialog" className="app__privacyPolicyToast">
<i aria-hidden={true} className="ms-Icon ms-Icon--Compare app__privacyPolicyToast__icon" />
<span>
Do you consent to our{' '}
<a href="https://privacy.microsoft.com/" rel="noopener noreferrer" target="_blank">
privacy policy
</a>
?
</span>
<button className="app__privacyPolicyToast__button" type="button">
Yes
</button>{' '}
<button className="app__privacyPolicyToast__button" type="button">
No
</button>
</div>
);
};
```
Expand All @@ -114,57 +114,57 @@ Then, style the toast using the following CSS:
```css
@font-face {
font-family: 'FabricMDL2Icons';
src: url('data:application/octet-stream;base64,d09GRgABAAAAAAjwAA4AAAAAENgAA6uFAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABRAAAAEgAAABgOp12JmNtYXAAAAGMAAAAMgAAAUIADf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M6FtfRueQ8fMpZ4Jcug4dY6abtYLlp94KzMbgK1KGqJP4DM1CgdMlZvkYZsUQnFevu4q/kfYsMDto5vpe4l5iTZrayf8E88RxQ+ghm+HT8ZOjvffssxZkh7tlLyX4seuhRumBvVO1sZ3TPOVvsiOY+ipUF9f4V1ySYiR7fLXMXmYiMDdokM1y1Qw2qQ8EU9wXrWe54zxLig+JY7ky0zZMXlfaSfVvuK9Uc+Iys5pzH0ImaKyKrIa9o4bkLbkuyWNUwvVZXLe8LtMlxP2W+4szHuNNVnPcr0DyJHfOU47qbsy5VSto5VtPy3BU7uSebmtER6t/FN03oPPGyy3vM4b9yu/ZesKcSZY7nOKQ7NczqrgqG6Nt5Pd6YAaok1hI43nALyH+stUBJx5UbvpUfmj15ZaoU98WkNVYVccs3q2VLynbo5uCHNGu+yf88o/HL2KTOrL0PN0Qnlml+KN85Mx17+z/c7b8Bhr44mnicY2BmAIP/fgzlDJiACQApLAHKeJzbwKDNsImRk0mbcRMXiNzO1ZobaqvKwKG9nTs12EFPBsTiifCw0JAEsXidzbXlhUEsPh0VGREeEItfTkKYjwPEEuDj4WRnAbEEwQDEEtowoSDAAMhi2M4IN5oJbjQz3GgWuNGscKPZ5CShRrPDjeaAG80JN3qTMCO79gYGBdfaTAkXAMQBKBoAAAA=')
format('truetype');
}

.ms-Icon {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
display: inline-block;
font-family: 'FabricMDL2Icons';
font-style: normal;
font-weight: normal;
speak: none;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
display: inline-block;
font-family: 'FabricMDL2Icons';
font-style: normal;
font-weight: normal;
speak: none;
}

.ms-Icon--Compare:before {
content: '\F057';
content: '\F057';
}

.app__privacyPolicyToast {
align-items: center;
color: #105e7d;
display: flex;
font-family: 'Calibri', 'Helvetica Neue', 'Arial', 'sans-serif';
font-size: 14px;
height: 100%;
align-items: center;
color: #105e7d;
display: flex;
font-family: 'Calibri', 'Helvetica Neue', 'Arial', 'sans-serif';
font-size: 14px;
height: 100%;
}

.app__privacyPolicyToast__icon {
text-align: center;
width: 36px;
text-align: center;
width: 36px;
}

.app__privacyPolicyToast__button {
appearance: none;
background-color: rgba(255, 255, 255, 0.8);
border: solid 1px rgba(0, 0, 0, 0.3);
border-radius: 3px;
color: initial;
font-family: inherit;
font-size: inherit;
margin: 0 0 0 4px;
outline: 0;
appearance: none;
background-color: rgba(255, 255, 255, 0.8);
border: solid 1px rgba(0, 0, 0, 0.3);
border-radius: 3px;
color: initial;
font-family: inherit;
font-size: inherit;
margin: 0 0 0 4px;
outline: 0;
}

.app__privacyPolicyToast__button:hover {
background-color: rgba(0, 0, 0, 0.12);
background-color: rgba(0, 0, 0, 0.12);
}

.app__privacyPolicyToast__button:focus {
border-color: rgba(0, 0, 0, 0.7);
border-color: rgba(0, 0, 0, 0.7);
}
```
Expand Down Expand Up @@ -337,9 +337,9 @@ Here is the finished `index.html`:
# Further reading
- [Web Chat notification system](https://github.com/microsoft/BotFramework-WebChat/tree/master/docs/NOTIFICATION.md)
- [React Hook for setting notification](https://github.com/microsoft/BotFramework-WebChat/tree/master/docs/HOOKS.md#usesetnotification)
- [React Hook for dismissing notification](https://github.com/microsoft/BotFramework-WebChat/tree/master/docs/HOOKS.md#usedismissnotification)
- [Web Chat notification system](https://github.com/microsoft/BotFramework-WebChat/tree/master/docs/NOTIFICATION.md)
- [React Hook for setting notification](https://github.com/microsoft/BotFramework-WebChat/tree/master/docs/HOOKS.md#usesetnotification)
- [React Hook for dismissing notification](https://github.com/microsoft/BotFramework-WebChat/tree/master/docs/HOOKS.md#usedismissnotification)
## Full list of Web Chat hosted samples
Expand Down
Loading

0 comments on commit 598c8cb

Please sign in to comment.