Reputation: 109
How can I add capabilities like session.say(.....) which works for voice channel like Cortana for bot built using v4 sdk.
where can I find similar one for v4 bot ?
Upvotes: 1
Views: 561
Reputation: 903
Cortana documentation on the topic for adding speech for V3 or V4 bots: https://learn.microsoft.com/en-us/cortana/skills/adding-speech
Upvotes: 0
Reputation: 7241
The link you included was for DirectLine v3, which is the latest version of DirectLine.
However, I believe you got the session.say
command from this V3 Doc. Unfortunately, it doesn't have a V4 equivalent.
However, most of the Message types have a speak
or ssml
property (JS / C#) you can use to send the text that will be spoken.
It works the same way. Instead of using (from the V3 doc):
JS v3
var msg = new builder.Message(session)
.text('This is the text that will be displayed')
.speak('This is the text that will be spoken.');
session.send(msg).endDialog();
C# v3
Activity msg = activity.CreateReply("This is the text that will be displayed.");
reply.Speak = "This is the text that will be spoken.";
reply.InputHint = InputHints.AcceptingInput;
await connector.Conversations.ReplyToActivityAsync(reply);
You'd use:
JS v4
var msg = MessageFactory.text({ text: "This is the text that will be displayed", ssml: "This is the text that will be spoken" });
await context.SendActivity(msg);
C# v4
var msg = MessageFactory.Text(text: "This is the text that will be displayed", ssml: "This is the text that will be spoken");
await context.SendActivity(msg);
The await
line might vary, depending on where/how you use it in your bot.
Note that to test speech, there's a few additional steps to set up. You can find references for that here:
And finally, here's a sample bot that uses Cortana and speech. Specifically, you can see how it uses MessageFactory.text
here.
Upvotes: 3