简体   繁体   中英

Out to set audio file in AudioConfig function from Azure cognitive services

I would like to load an audio wav file in My Xamarin forms project.

The audio file is in SpeechApp=>Data=>audio.wav

I am using the Azure AudioConfig function like this:

var taskCompleteionSource = new TaskCompletionSource<int>();
            var config = SpeechConfig.FromSubscription("xxx", "xx");

       var transcriptionStringBuilder = new StringBuilder();


      // Replace the language with your language in BCP-47 format, e.g., en-US.
      var language = "fr-FR";
      config.SpeechRecognitionLanguage = language;
      config.OutputFormat = OutputFormat.Detailed;

using (var audioInput = AudioConfig.FromWavFileInput("SpeechApp.Data.audio.wav"))
        {
            using (var recognizer = new SpeechRecognizer(config, audioInput))
            {


                // Stops recognition.  
                await recognizer.StopContinuousRecognitionAsync();
            }
        }

But It is not working and I have this error : System.DllNotFoundException: Microsoft.CognitiveServices.Speech.core.dll

My error comes from this lines : var config = SpeechConfig.FromSubscription()

I was inspired from this web site : click here

Thanks for your help

Could you please try something like below:

using (var audioInput = AudioConfig.FromWavFileInput(@"SpeechApp.Data.audio.wav"))
            {
                using (var recognizer = new SpeechRecognizer(config, audioInput))
                {

}

You can refer this link for more samples in different languages.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM