voice to text

Eduardo Gomez 2,326 Reputation points
2021-04-28T14:50:22.257+00:00

Hello

I was just wondering if somebody has implemented voice to text in Xamarin forms, and if you could share an example

I search everywhere, and the only solution I can fin is AzureSpeech, but this is not a great solution become I need to upload a recording

I also tried to implement this (https://github.com/dev-aritra/XFSpeech), but no luck

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
4,811 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CherryBu-MSFT 326 Reputation points
    2021-04-29T04:43:06.217+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    I also tried to implement this (https://github.com/dev-aritra/XFSpeech), but no luck

    I download this sample to test, and I have no problem, please take a look the following step:

    Firstly, you need to connect network successfully.

    Then run this sample, click Start Button , you will see this screnshot, you can speak something now.

    92492-image-10.png

    If you want to stop speak, don't tap or click any place, wait a minute, it will disappear automatically.

    About RecognizerIntent Class, please take a look the following code, I have made some comments.

     // create the intent and start the activity  
                            var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);  
                            voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);  
      
                            // put a message on the modal dialog  
                            voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, Application.Context.GetString(Resource.String.messageSpeakNow));  
      
                            // if there is more then 1.5s of silence, consider the speech over  
                            voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);  
                            //The amount of time that it should take after we stop hearing speech to consider the input possibly complete.  
                            voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);  
                            //The minimum length of an utterance.  
                            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);  
                            StartActivityForResult(voiceIntent, VOICE);  
    

    Best Regards,

    Cherry Bu

    ---
    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.