BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

Adaptive Card speak property is not working

Open puripuneet opened this issue 8 years ago • 37 comments

Adaptive cards are supposed to support the "speak" property to denote text to say to the user (see https://docs.microsoft.com/en-us/adaptive-cards/create/speech). However, this property does not have any effect in WebChat.

puripuneet avatar Mar 09 '18 04:03 puripuneet

Web Chat will only speak when the message is replied after the user used the microphone to ask the question. Since the message replied by the bot might be abbreviated and not make sense to speak out. Thus, we have a speak property to make the spoken text different than the message shown.

We have an ask on making TTS (text-to-speech) always on at #859. If you think it's relevant, please vote it.

The current behavior is by design and we need to think a better way to surface the TTS feature.

compulim avatar Mar 09 '18 05:03 compulim

@compulim this issue has to do with the speak property having no effect in WebChat, even when the microphone is used first by the user. In other words, WebChat never acts on the speak property, which seems to be a bug. One would expect that if the microphone is used first by the user to ask a question, then WebChat would speak out the text that is inside the speak tag of the adaptive card that is part of the answer, but this does not happen. Please let me know if I am missing something, otherwise I request that this issue be re-opened. Thank you.

puripuneet avatar Mar 09 '18 14:03 puripuneet

I have just tested our sample weather card. I use the speech button in Web Chat and my voice to send a request to my bot. Then my bot response with the card. I can clearly hear the following, i.e. the speak property.

S. Weather forecast for Monday is high of 62 and low of 42 degrees with a 20% chance of rain. Slash S. S. Winds will be 5 mph from the northeast. Slash S.

I am using the TTS and synthesizer from Cognitive Services, and testing from master branch, which is newer than the one on NPM.

What kind of TTS/Synthesizer are you using, browser or Cognitive Services? And can you share us the Adaptive Cards JSON file to investigate?

compulim avatar Mar 09 '18 23:03 compulim

Thanks, that's good to know. I will upgrade to the latest code and retry it. The code base I'm using is from 11/12/17, so maybe the issue was fixed some time after that date?

puripuneet avatar Mar 09 '18 23:03 puripuneet

We are upgrading Adaptive Cards to 1.0.0, which was released 2 days ago. That might be related.

Please do let us know you result. 😄

compulim avatar Mar 09 '18 23:03 compulim

Is that upgrade available yet to pull from github, or should I wait until you are fully done?

puripuneet avatar Mar 09 '18 23:03 puripuneet

We should have it out next week. If you wanna try out now, you will need to clone the repos, build it, and use NPM link to link to your project.

Steps:

cd <somewhere-not-your-project-dir>
git clone https://github.com/Microsoft/BotFramework-WebChat.git
cd BotFramework-WebChat
npm install
npm run build
npm link .
cd <your-project-dir>
npm link botframework-webchat

NPM link will build a symbolic link from your project directory to the cloned/built repos directory.

I recommend to testing it early because if it is still buggy, we can still fix it before the next publish cycle. 😉

compulim avatar Mar 09 '18 23:03 compulim

Thanks, I'll see if I'll see if I can try it out this weekend.

puripuneet avatar Mar 09 '18 23:03 puripuneet

I tested the sample weather card with the current code base on github. But it didn't work -- the speak property had no effect. It works in the Visualizer (when you click on the "Speak this card" button), but in WebChat the card gets displayed without any speech.

Attached is the JSON I used in WebChat (note that I had to modify the JSON a little bit for WebChat). weather.zip

puripuneet avatar Mar 11 '18 21:03 puripuneet

@puripuneet I will try your JSON.

Did your bot send the sample weather card because you spoke or you typed? The speak property will only be synthesized if the last action was your voice but not you typed or clicked.

The code that decide whether to synthesize or not is here and here. Internally, the Redux action that do synthesis is called Speak_SSML.

compulim avatar Mar 12 '18 01:03 compulim

@compulim I spoke to it but it didn't speak back.

puripuneet avatar Mar 12 '18 01:03 puripuneet

@compulim Note that I had to modify the sample weather card JSON in order to send it from my bot using the Bot Framework. To use the Bot Framework to send messages to WebChat, the JSON has to include the contentType and content properties as shown in this example.

puripuneet avatar Mar 12 '18 22:03 puripuneet

Few questions, I am trying to repro:

  1. When you say something and expecting a text return (instead of AC), will Web Chat speak back the response?
  2. Are you using speech from browser (BotChat.Speech.BrowserSpeechRecognizer) or Cognitive Services?

compulim avatar Mar 12 '18 23:03 compulim

(Let me reopen the issue, closed issues are difficult to find)

compulim avatar Mar 12 '18 23:03 compulim

@compulim To answer your questions:

  1. Yes (speech works with both text messages and suggested actions).
  2. Using Cognitive Services and also our own speech synthesizer.

puripuneet avatar Mar 12 '18 23:03 puripuneet

Few prelims on my investigations:

  1. Cognitive Services did not understand SSML (or we send it incorrectly), it do speak the XML tag in AC card speak property a. For example, speak = '<s>Hello</s>', Cognitive Services will say "S Hello slash-S".
  2. Chrome do not understand SSML a. It works when speak = 'Hello' b. It won't speak anything if speak = '<s>Hello</s>'

Adaptive Cards speak property support both plain text and SSML:

Specifies what should be spoken for this entire Item. This is simple text or SSML fragment

compulim avatar Mar 12 '18 23:03 compulim

For browser-based Web Speech, we assume Chrome does not support SSML, our code here will parse SSML and convert it to SpeechSynthesisUtterance.

Since <s> is a wrong tag, our fallback code use nodeValue which should be textContent instead.

compulim avatar Mar 13 '18 00:03 compulim

@puripuneet I have a fix in PR #895 that should fix the bug. The problem is that when we synthesize thru Web Speech API (browser-based), we have a bad XML parsing on the SSML malformed tag (<s> is not a valid SSML tag, should bypass but we missed.)

We don't have any problems on Cognitive Services synthesizer even with bad SSML.

compulim avatar Mar 13 '18 00:03 compulim

@compulim I am not using Web Speech API, so I don't think the fix to PR #895 applies.

puripuneet avatar Mar 13 '18 02:03 puripuneet

@puripuneet do you see anything weird on F12 console?

You mentioned you are using your own speech synthesizer. Can you tell me a little more on that?

compulim avatar Mar 13 '18 17:03 compulim