问题描述
我尝试在 blazor webasm 应用程序中使用语音 SDK,但反复出现缺少“Microsoft.CognitiveServices.Speech.core.dll”的问题。
有一些关于这个问题的报告,但没有一个与 webasm 应用程序相关。
重现问题的步骤:
@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);
}
}
- 现在,当构建和运行时(无论是调试/发布、清理/重建、发布等)都会得到控制台输出:
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