我需要把语音从wav文件转换成文本。因此,我从C#页面下载了示例Quickstart:使用语音服务C# SDK识别语音代码项目,并按照页面上的说明进行了操作。
它在Windows10中工作,但我需要该项目在2012 R2上工作,而在2012 R2上不工作。
当我在Windows 2012 R2上运行它时,我按下3的3键。带有文件输入选项的语音识别。但是,当它尝试执行以下代码时(具有有效的订阅和区域值)
var factory = SpeechFactory.FromSubscription("YourSubscriptionKey", "YourServiceRegion");
引发以下异常:
System.TypeInitializationException发生了'Microsoft.CognitiveServices.Speech.Internal.carbon_csharpPINVOKE‘的HResult=0x80131534 Message=The类型初始化程序引发了一个异常。Source=Microsoft.CognitiveServices.Speech.csharp StackTrace: at Microsoft.CognitiveServices.Speech.Internal.carbon_csharpPINVOKE.SpeechFactory_FromSubscription(String jarg1,String jarg2) at Microsoft.CognitiveServices.Speech.Internal.SpeechFactory.FromSubscription(String订阅,String region) at Microsoft.CognitiveServices.Speech.SpeechFactory.FromSubscription(String subscriptionKey,String StackTrace) at MicrosoftSpeechSDKSamples.SpeechRecognitionSamples.d__2.MoveNext() in C:\temp\csharp_samples\speech_recognition_samples.cs:line 86
内部异常1: TypeInitializationException:“SWIGExceptionHelper”的类型初始化程序引发了一个异常.
'Microsoft.CognitiveServices.Speech.csharp.bindings.dll':内部异常2::无法加载DLL DllNotFoundException,无法找到指定的模块。(HRESULT例外: 0x8007007E)
我认为Microsoft.CognitiveServices.Speech.csharp.bindings.dll不喜欢运行在Windows 2012 R2上,因为它存在于bin文件夹中(并且没有丢失),并且在Windows 10上工作。我在一个小Hello项目中编写了以下代码,它抛出了运行在Windows 2012 R2上的相同异常。
class Program
{
[DllImport("Microsoft.CognitiveServices.Speech.csharp.bindings.dll", CharSet = CharSet.None, EntryPoint = "CSharp_MicrosoftfCognitiveServicesfSpeechfInternal_TRANSLATION_LANGUAGE_RESOURCE_SCOPE_SPEECH_get___", ExactSpelling = false)]
public static extern int TRANSLATION_LANGUAGE_RESOURCE_SCOPE_SPEECH_get();
static void Main(string[] args)
{
int test = TRANSLATION_LANGUAGE_RESOURCE_SCOPE_SPEECH_get();
Console.WriteLine($"API value: {test}");
}
}
我试着以管理员的身份运行以防万一这是允许的事情。但这没什么用。
有人能帮我吗?告诉我在Windows 2012 R2上运行语音服务示例需要做些什么?
发布于 2018-11-02 17:08:43
在Build > Configuration中检查项目的平台设置。
它必须设置为x64或x86,而不是AnyCpu。
发布于 2018-05-15 14:32:53
安装最新的Microsoft重新发行版用于Visual 2017应该会修复它,请参阅C++。
(我们会尽快更新文档)
发布于 2018-05-29 11:23:30
目前,SDK很难依赖于。您的服务器映像上有以下dlls : Ksuser.dll、Mf.dll、Mfcore.dll、Mfplat.dll、Mfreadwrite.dll?
https://stackoverflow.com/questions/50339524
复制相似问题