Search code examples
blazorazure-cognitive-services

Why Microsoft.CognitiveServices.Speech from Blazor WebAssembly [NET 6.0] does not work?


I have a .NET console app that works perfectly fine.

Both PowerShell and curl return no errors https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/troubleshooting

In Blazor I have

    string speechKey = "<...>"; .
    string speechRegion = "<...>";

    var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);

And speechConfig is null here (not in the console app)

I debug and:

fail: Microsoft.WebAssembly.Diagnostics.DevToolsProxy[0] sending error response for id: msg-BCE647DB29F0CA15F52342050F3B6E49:::1041 -> [Result: IsOk: False, IsErr: True, Value: , Error: {   "result": {     "type": "object",     "subtype": "error",     "description": "Cannot find member named 'SpeechConfig'.",     "className": "ReferenceError"   } } ]

enter image description here


Solution

  • The reason is that WebAssembly (WASM) is not currently supported by Azure Speech SDK, we have work item to make that support available in the future. See related issue https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/930

    Currently for browser development, we have JS SDK available https://github.com/Microsoft/cognitive-services-speech-sdk-js