arqe
arqe

Reputation: 116

Azure Speech SDK (C#) in Blazor (webasm) app - bug

I an trying to use the speech SDK in blazor webasm app, but with recurring problem of missing "Microsoft.CognitiveServices.Speech.core.dll".

There are a few reports about this issue, but not single one relating to webasm app.

Steps to reproduce the problem:

  1. new blazor webasm project in VS2019 sc1 sc2

  2. Install Speech SDK package sc3

  3. Update Index.Razor with minimum code to reproduce

@page "/"

@using Microsoft.CognitiveServices.Speech;

<h1>Bug Reproduction</h1>


@code {

    private static readonly string SpeechSubscriptionKey = "somevalidkey";
    private static readonly string SpeechLocation = "somelocation";

    private SpeechConfig _SpeechConfig;

    protected override async Task OnInitializedAsync()
    {

        _SpeechConfig = SpeechConfig.FromSubscription(SpeechSubscriptionKey, SpeechLocation);


    }
}

sc4

  1. Now, when build and run (no matter debug/release, clean/rebuild, publish etc.) will get you the console output:
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Microsoft.CognitiveServices.Speech.core.dll
System.DllNotFoundException: Microsoft.CognitiveServices.Speech.core.dll
   at Microsoft.CognitiveServices.Speech.SpeechConfig.FromSubscription(String subscriptionKey, String region) 

The app page in the chrome opens, but the resource is indeed missing: sc5

As I mentioned, I found several reports about bugs related to this issue, but none of webasm target. The only resolution I found mentioned was to manually copy the Microsoft.CognitiveServices.Speech.core.dll to the target directory.

I am not quite sure how to do that correctly for webasm project, as I am new to it (as well as to .net as a whole).

As an act of desperate man, I tried copying Microsoft.CognitiveServices.Speech.core.dll to the folder \bin\Debug\net5.0\wwwroot_framework\ and updating blazor.boot.json. The dll will then appear in blazor-resources in chrome, but the error message is the same. (System.DllNotFoundException).

The problem is that I have no idea which of the Microsoft.CognitiveServices.Speech.core.dll files I can find in nuget\packages\microsoft.cognitiveservices.speech\1.14.0\ folder could work, if any.

I may be missing something important here, any help or explanation what goes on would be greatly appreciated.

Upvotes: 0

Views: 864

Answers (3)

Bennyboy1973
Bennyboy1973

Reputation: 4281

Yeah, the NuGet package for .Net only works on Windows machines, and is framework dependent. The JavaScript library is the way to go for Blazor.

Even for the server flavor, you don't want to be routing many extra megabytes of audio data through your server to the client anyway, so-- JavaScript is still the way to go.

There was recently another question about the Speech SDK, in which I give a working tutorial (including github link) integrating the JS SDK with Blazor. You can see it here:

https://stackoverflow.com/a/78565273/3433178

Upvotes: 0

Ehasanul Hoque
Ehasanul Hoque

Reputation: 650

Currently Azure Speech SDK has no support for wasm project. JS SDK or rest approach are the option to integrate in wasm project.

Please read this medium article to integrate azure speech service in blazor wasm project using rest approach Click here

Upvotes: -1

arqe
arqe

Reputation: 116

It turned out that WASM target is not yet supported. Js-sdk is the option for the time being. github issue

Upvotes: 1

Related Questions