Botframework-webchat: The adaptive cards are not getting spoken. The article that I am following is: https://github.com/microsoft/BotFramework-WebChat/blob/master/docs/SPEECH.md

Created on 24 Nov 2020  路  8Comments  路  Source: microsoft/BotFramework-WebChat

馃毃 The issue tracker is not for implementation questions 馃毃

[Question]

I have below code snippet added in my DirectLine HTML:

    window.WebChat.renderWebChat(
        {
            directLine: directLine,
            userID: user_unique_id, //random guid is acceptable     
            locale: input_lang,
            store: store,
            styleOptions: styleOptions,
            selectVoice: (voices, activity) => {
                if (input_lang === 'en-GB') {
                    return voices.find(({ name }) => /RyanNeural/iu.test(name));
                } else {
                    return voices.find(({ name }) => /Jessa24kRUS/iu.test(name));
                }
            },
            webSpeechPonyfillFactory
        },
        document.getElementById("webchat")
    );

    document.querySelector("#webchat > *").focus();
}

It should ideally also have text-to-speech enabled on BOT and should read out the adaptive cards. This is actually not working. Any help will be appreciated.

Bot Services Question Support customer-replied-to customer-reported

Most helpful comment

@corinagum @v-kydela Thank you for the input. Indeed there was some formatting issue. I have updated my JSON, and the adaptive cards are now getting spoken. Thanks for all the input. Closing the ticket.

All 8 comments

Hey @corinagum could you take a look at this and clarify the correct behavior for webchat? Thanks.

Do you have speech text applied to the Adaptive Card? Please share the Adaptive Card code and I will test it out.

Sure my Adaptive Card looks like:

```c#
Attachment outputAttachment = (Attachment)output;
var reply = MessageFactory.Attachment(outputAttachment);

if (outputAttachment?.ContentType != "application/vnd.microsoft.card.hero")
{
AdaptiveCard adaptiveCard = (AdaptiveCard)reply.Attachments[0].Content;
string speakText = null;
for (int i = 0; i < adaptiveCard?.Body.Count; i++)
{
var bodyText = ((AdaptiveTextBlock)adaptiveCard?.Body[i]).Text;
var convertedBody = await languageHelper.FetchConvertedString(bodyText, userSession.Id).ConfigureAwait(false);
((AdaptiveTextBlock)adaptiveCard.Body[i]).Text = convertedBody;
speakText = speakText + convertedBody + " ";
}
if (adaptiveCard.Actions != null)
{
foreach (var action in adaptiveCard.Actions)
{
speakText = speakText + action.Title + " ";
}

}
string body = @"<speak version='1.0' xmlns='https://www.w3.org/2001/10/synthesis' xmlns:mstts='https://www.w3.org/2001/mstts'><voice>" + $"{speakText}" + "</voice></speak>";
adaptiveCard.Speak = body;
reply.Attachments[0].Content = adaptiveCard;

```

Could you share the Adaptive Card json? Thank you!

AdaptiveCardJSON.txt
Please find attached the JSON
Also, is it possible to have a quick sync up anytime suitable to you for troubleshooting?

Hi @alishajain7, it looks like there are formatting errors in your card. I was able to get the following to work with speech:

{
  $schema: 'https://microsoft.github.io/AdaptiveCards/schemas/adaptive-card.json',
  type: 'AdaptiveCard',
  version: '1.2',
  speak: 'Would you like **to** reset',

  body: [
    {
      type: 'TextBlock',
      text: 'Would you like to',
      wrap: true
    }
  ],
  actions: [
    {
      type: 'Action.Submit',
      id: '0button',
      data: 'Button 1',
      title: 'Button 1'
    },
    {
      type: 'Action.Submit',
      id: '1button',
      data: 'Button 2',
      title: 'Button 2'
    },
    {
      type: 'Action.Submit',
      id: '2button',
      data: 'Button 3',
      title: 'Button 3'
    },
    {
      type: 'Action.Submit',
      id: '3button',
      data: 'Button 4',
      title: 'Button 4'
    }
  ]
}

@v-kydela, could you provide support on this issue?

Sure, @corinagum

@alishajain7 - Go ahead and try Corina's JSON to see if it works for you

@corinagum @v-kydela Thank you for the input. Indeed there was some formatting issue. I have updated my JSON, and the adaptive cards are now getting spoken. Thanks for all the input. Closing the ticket.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kellym-Kainos picture Kellym-Kainos  路  4Comments

compulim picture compulim  路  3Comments

joshm998 picture joshm998  路  3Comments

corinagum picture corinagum  路  3Comments

electrobabe picture electrobabe  路  4Comments