微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Blazor (webasm) 应用程序中的 Azure Speech SDK (C#) - 错误

如何解决Blazor (webasm) 应用程序中的 Azure Speech SDK (C#) - 错误

我尝试在 blazor webasm 应用程序中使用语音 SDK,但反复出现缺少“Microsoft.CognitiveServices.Speech.core.dll”的问题。

有一些关于这个问题的报告,但没有一个与 webasm 应用程序相关。

重现问题的步骤:

  1. VS2019 中的新 blazor webasm 项目 sc1 sc2

  2. 安装语音 SDK 包 sc3

  3. 用最少的代码更新 Index.Razor 以重现

@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. 现在,当构建和运行时(无论是调试/发布、清理/重建、发布等)都会得到控制台输出
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) 

chrome中的app页面打开了,但是确实缺少资源: sc5

正如我所提到的,我发现了一些关于与此问题相关的错误的报告,但没有一个 webasm 目标。 我发现提到的唯一解决方案是手动将 Microsoft.CognitiveServices.Speech.core.dll 复制到目标目录。

我不太确定如何为 webasm 项目正确地做到这一点,因为我是新手(以及整个 .net)。

作为一个绝望的人,我尝试将 Microsoft.CognitiveServices.Speech.core.dll 复制到文件夹 \bin\Debug\net5.0\wwwroot_framework\ 并更新 blazor.boot.json。然后dll会出现在chrome的blazor-resources中,但是报错信息是一样的。 (System.DllNotFoundException)。

问题是我不知道我可以在 nuget\packages\microsoft.cognitiveservices.speech\1.14.0\ 文件夹中找到哪些 Microsoft.CognitiveServices.Speech.core.dll 文件可以工作,如果有的话。

我可能在这里遗漏了一些重要的东西,任何帮助或解释将不胜感激。

解决方法

事实证明,目前还不支持 WASM 目标。 Js-sdk 是暂时的选择。 github issue

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。