Xamarin Forms SpeechToText Example

How is speech recognition done in xamarin forms?

`public class SpeechToText : ISpeechToText
{
public SpeechToText()
{

    }

    public void speech()
    {
        var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);

        // put a message on the modal dialog
        voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt,Android.App.Application.Context.GetString(Resource.String.messageSpeakNow));

        // if there is more then 1.5s of silence, consider the speech over
        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
        voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

        // you can specify other languages recognised here, for example
        // voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German);
        // if you wish it to recognise the default Locale language and German
        // if you do use another locale, regional dialects may not be recognised very well

        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);


    }`

Answers

Sign In or Register to comment.