Adaptive Card speak property is not working
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.
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 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.
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?
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?
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. 😄
Is that upgrade available yet to pull from github, or should I wait until you are fully done?
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. 😉
Thanks, I'll see if I'll see if I can try it out this weekend.
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 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 I spoke to it but it didn't speak back.
@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.
Few questions, I am trying to repro:
- When you say something and expecting a text return (instead of AC), will Web Chat speak back the response?
- Are you using speech from browser (
BotChat.Speech.BrowserSpeechRecognizer) or Cognitive Services?
(Let me reopen the issue, closed issues are difficult to find)
@compulim To answer your questions:
- Yes (speech works with both text messages and suggested actions).
- Using Cognitive Services and also our own speech synthesizer.
Few prelims on my investigations:
- Cognitive Services did not understand SSML (or we send it incorrectly), it do speak the XML tag in AC card
speakproperty a. For example,speak = '<s>Hello</s>', Cognitive Services will say "S Hello slash-S". - Chrome do not understand SSML
a. It works when
speak = 'Hello'b. It won't speak anything ifspeak = '<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
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.
@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 I am not using Web Speech API, so I don't think the fix to PR #895 applies.
@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?