I've integrated my bot with cortana channel and can view the adaptive cards successfully. What I need is to speak out the content of the adaptive card. The speak property when using shows that it is deprecated. Is there a way to speak out the content of my card?
var contentCard = AdaptiveCard(qnaAnswer.title);
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = contentCard
};
reply.Attachments = new List<Attachment> { attachment };
await turnContext.SendActivityAsync(reply);
public static AdaptiveCard AdaptiveCard(string subtitle)
{
AdaptiveCard card = new AdaptiveCard();
card.Body.Add(new AdaptiveTextBlock()
{
Text = string.IsNullOrEmpty(subtitle) ? string.Empty : subtitle,
Speak =text ,
});
return card;
}
A few things with this code.
First, if you look at the schema for AdaptiveCards, you see speak property only is valid under a card element.
https://adaptivecards.io/explorer/AdaptiveCard.html
So this implies
card.Speak = 'Whatever'
AdaptiveCards is flexible in that you can add properties that should be ignored by the renderer... confusing because if you put in properties with the same names you won't get any errors and/or it appears something doesn't work when expected.
The next issue is that the speak property is in the context of the entire card, not just an element like textblock. If you want to create a mechanism that translates the card elements to speech based on hints attached to those elements, you need to write this yourself.
Finally, adding a Speak property to a card will only work in channels that support speaking AdaptiveCards. Believe it or not, Cortana does NOT do this. You would need to copy the Speak property from the card and then attach it to the activity's speak property for Cortana to say the result. Check out
https://learn.microsoft.com/en-us/cortana/skills/adding-speech