我创建了一个带有自适应卡片的机器人,并设置了说话属性。
AdaptiveCard card = new AdaptiveCard()
{
Body = new List<CardElement>()
{
new Container()
{
Speak = "<s>Hello!</s><s>Are you looking for a flight or a hotel?</s>",
Items = new List<CardElement>()
{
new ColumnSet()
{
Columns = new List<Column>()
{
new Column()
{
Size = ColumnSize.Auto,
Items = new List<CardElement>()
{
new Image()
{
Url = "https://placeholdit.imgix.net/~text?txtsize=65&txt=Adaptive+Cards&w=300&h=300",
Size = ImageSize.Medium,
Style = ImageStyle.Person
}
}
},
new Column()
{
Size = ColumnSize.Stretch,
Items = new List<CardElement>()
{
new TextBlock()
{
Text = "Hello!",
Weight = TextWeight.Bolder,
IsSubtle = true
},
new TextBlock()
{
Text = "Are you looking for a flight or a hotel?",
Wrap = true
}
}
}
}
}
}
}
},
// Buttons
Actions = new List<ActionBase>() {
new ShowCardAction()
{
Title = "Hotels",
Speak = "<s>Hotels</s>",
Card = GetHotelSearchCard()
},
new ShowCardAction()
{
Title = "Flights",
Speak = "<s>Flights</s>",
Card = new AdaptiveCard()
{
Body = new List<CardElement>()
{
new TextBlock()
{
Text = "Flights is not implemented =(",
Speak = "<s>Flights is not implemented</s>",
Weight = TextWeight.Bolder
}
}
}
}
}
};
然后我从网络聊天控件和使用Microsoft Cognitive服务中使用此bot。这是集成代码: -
const speechOptions = {
speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY' }),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
gender: CognitiveServices.SynthesisGender.Female,
subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY',
voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
})
};
我在这里使用我的认知服务API密钥。
Q.1)我通过语音调用自适应卡。我的期望是,当卡片交付时,它应该读出SSML标签内的内容。但这并没有发生。自适应卡只是在没有语音的情况下交付。
Q.2)对于通过context.PostAsync()传递的任何文本内容,通过网络聊天大声朗读。但我希望只有在我们使用context.SayAsync()时才能大声朗读。
请帮助我了解这种行为以及如何通过语音提供自适应卡。谢谢!