Skip to content

Instantly share code, notes, and snippets.

View dev-aritra's full-sized avatar
🤖
Working

Aritra Das dev-aritra

🤖
Working
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
private void StartRecordingAndRecognizing()
{
string rec = global::Android.Content.PM.PackageManager.FeatureMicrophone;
if (rec == "android.hardware.microphone")
{
var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Speak now");
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.OS;
using Android.Speech;
using Xamarin.Forms;
namespace XFSpeechDemo.Droid
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Speech;
<key>NSSpeechRecognitionUsageDescription</key>
<string>Allows you create tasks</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allows you to recognise your voice to create tasks</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>Allows you create tasks</string>
<key>NSMicrophoneUsageDescription</key>
<string>Allows you to recognise your voice to create tasks</string>
private void ConnectToWatson()
{
_conversation = new ConversationService("watson username", "watson assitant password", "2018-09-10");
_conversation.SetEndpoint("watson gateway");
}
#gateway = https://gateway.watsonplatform.net/conversation/api
#gateway = https://gateway.watsonplatform.net/assistant/api
MessageRequest mr = new MessageRequest()
{
Input = new InputData()
{
Text = temp
},
};
await Task.Run(() => {
var res = _conversation.Message("watson workspace id", mr);
MessageRequest mr = new MessageRequest()
{
Input = new InputData()
{
Text = temp
},
Context =_context
};
await Task.Run(() => {
var res = _conversation.Message("watson workspace id", mr);
_context = res.Context;
OnWatsonMessagerecieved(JsonConvert.SerializeObject(res, Formatting.Indented));
});
private void OnWatsonMessagerecieved(string data)
{