I am currently creating a Chatbot that has to accept voice inputs from the user. However, using waterfall dialogs to prompt the user for input does not contain a prompt that accepts voice. I'm using Azure Speech services for speech recognition and was wondering is there a way to do it.
I tried converting the speech recognition result to string and send that as user text input but I'm new to coding and feel like I did it wrong. This is a part of the waterfall dialog step.
private async Task<DialogTurnResult> IntroStep(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
stepContext.Values[StudentInfo] = new BotData();
SpeechSynthesis.SubjectVoice();
var promptOptions = new PromptOptions { Prompt = MessageFactory.Text("Hello, how can i help you? \n" +
"Want to do a Quiz or ask me a Question") };
SpeechRecognition.HearUser(); // waits for user voice input
Model.Answer = (string)stepContext.Result;
return await stepContext.PromptAsync(nameof(TextPrompt), promptOptions, cancellationToken);
}
As you are using the Webchat channel (based on your comments), you should process all the speech part on the Webchat, and then your bot will process your messages without any chance on this side.
You have several samples on the official Github repository regarding Speech: see all the samples which number start by 06
here:
I would suggest to start with 06.d as it does not need many changes.
In a few words, you have to:
webSpeechPonyfillFactory: window.WebChat.createBrowserWebSpeechPonyfillFactory()
Speak
value of your outgoing activities is set in order to be able to "speak back" to the user. Please note that your bot will "speak" automatically if the previous message was spoken.