1

How can I add capabilities like session.say(.....) which works for voice channel like Cortana for bot built using v4 sdk.

Here is good doc for v3 bot

where can I find similar one for v4 bot ?

vijay
  • 109
  • 11
  • find a book, tool, software library, tutorial ? It is none of the above. I am asking about the documentation link :) Plz read carefully. – vijay Feb 01 '19 at 15:58
  • documentation link is an off-site resource, please read carefully – Andreas Feb 02 '19 at 03:01

2 Answers2

3

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.

mdrichardson
  • 7,141
  • 1
  • 7
  • 21
  • Oh yes I copied wrong link. I fond something related on sendActivities() look like this is an option too if we use speak property. https://learn.microsoft.com/en-us/javascript/api/botbuilder-core/turncontext?view=botbuilder-ts-latest#sendactivity – vijay Feb 01 '19 at 21:35
  • 1
    Correct. You can create the message through MessageFactory or use sendActivities with the `speak` parameter. If you consider your question answered, do you mind marking it so I can close it off of my tracker? Thanks! – mdrichardson Feb 01 '19 at 21:52
  • Just did. Thanks – vijay Feb 01 '19 at 21:56
  • Did anyone enable speak functionality in v4 and tested in 4.* version of Bot emulator?? if yes, can you tell me how you enabled speak service in Bot framework emulator? – pj2494 Mar 15 '20 at 10:18
  • @PuneetJoshi [DirectLine Speech](https://learn.microsoft.com/en-us/azure/bot-service/directline-speech-bot?view=azure-bot-service-4.0) – mdrichardson Mar 17 '20 at 16:24
0

Cortana documentation on the topic for adding speech for V3 or V4 bots: https://learn.microsoft.com/en-us/cortana/skills/adding-speech

Micromuncher
  • 903
  • 7
  • 19