Forum Xamarin.Forms

Offline Speech recognition (Verification) in Xamarin (NOT speech to text)

sudhir.9350sudhir.9350 INUniversity ✭✭


I am in search of Offline Speech Recognition Api/SDK for Xamarin.forms (Xamarin.Android too will work). My app uses speech to authenticate user. I already implemented Speech to Text using IRecognitionListener in android and with the help of Dependency service of Xamarin.Forms.

Now i need to verify who is speaking. e.g The app is used by several users, and if they set their voice password "hello" on different devices. Now if another person some how get the user's device and speak that "hello" then it can be converted to "hello" and verify the Text with my back end and in that case it matches and thus user is authenticated and allow to access the app.

So, here i need a sdk/api to verify that who is speaking based on the tone of voice, so i can identify and decide whether the user is in system or not.

I have a register page from where user register them selves and provide their password by speaking and that will be save in my db along with the username.

In my initial research on Web, i found that there are Speech verification implementation but those are either in c++ or python, so i am not sure how to bring it to Xamarin.

Thanks in advance for any thoughts/Idea?



  • DorababuDorababu USMember ✭✭

    Hi @sudhir.9350 did you implemented offline Speech to Text ? can you please share the code snippet.

  • sudhir.9350sudhir.9350 INUniversity ✭✭
    edited June 10
    in your main activity
    public class MainActivity  
     private readonly int VOICE = 10;
    protected override void OnCreate(Bundle bundle)
               // on some button click or something you can call Start() method.
              // Or if you're using xam.forms you can write a dependency service and define method for start and stop
    private void Start(){
                           speechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(MainActivity.Instance);
                speechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                speechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
                speechIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 3);
                speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 500);
                speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 500);
                speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 500);
                speechIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
    protected override  void OnActivityResult(int requestCode, Result resultCode, Intent data)
                base.OnActivityResult(requestCode, resultCode, data);
                if (requestCode == VOICE)
                    if (resultCode == Result.Ok)
                        var matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults);
                        if (matches.Count != 0)
                            string textInput = matches[0];
                            Console.WriteLine("Spoken  Text:" + textInput);
Sign In or Register to comment.