如何在Windows Server 2012 R2上运行Microsoft.CognitiveServices.Speech [英] How to run Microsoft.CognitiveServices.Speech on Windows Server 2012 R2

查看:554
本文介绍了如何在Windows Server 2012 R2上运行Microsoft.CognitiveServices.Speech的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将语音从wav文件转换为文本.因此,我从

I need to convert speech from a wav file into text. So I downloaded the sample C# code project from the Quickstart: Recognize speech using Speech service C# SDK page, and followed the instructions on the page.

它可以在Windows 10中运行,但是我需要该项目才能在Windows Servers 2012 R2上运行,而在Windows Servers 2012 R2上却无法运行.

It works in Windows 10, but I need the project to work on Windows Servers 2012 R2 and it doesn't work on Windows Servers 2012 R2.

当我在Windows Servers 2012 R2上运行它时,我按下 3的3键.带有文件输入的语音识别选项.但是,当它尝试执行以下代码(带有有效的订阅和区域值)时

When I run it on Windows Servers 2012 R2, I press the 3 key for the 3. Speech recognition with file input option. But when it tries to execute the following code (with valid subscription and region values)

var factory = SpeechFactory.FromSubscription("YourSubscriptionKey", "YourServiceRegion");

抛出以下异常:

发生System.TypeInitializationException HResult = 0x80131534 Message ='Microsoft.CognitiveServices.Speech.Internal.carbon_csharpPINVOKE'的类型初始值设定项引发了异常. 来源= Microsoft.CognitiveServices.Speech.csharp 堆栈跟踪: 在Microsoft.CognitiveServices.Speech.Internal.carbon_csharpPINVOKE.SpeechFactory_FromSubscription(字符串jarg1,字符串jarg2) 在Microsoft.CognitiveServices.Speech.Internal.SpeechFactory.FromSubscription(字符串订阅,字符串区域) 在Microsoft.CognitiveServices.Speech.SpeechFactory.FromSubscription(字符串subscriptionKey,字符串区域) 在MicrosoftSpeechSDKSamples.SpeechRecognitionSamples.d__2.MoveNext()中的C:\ temp \ csharp_samples \ speech_recognition_samples.cs:第86行

System.TypeInitializationException occurred HResult=0x80131534 Message=The type initializer for 'Microsoft.CognitiveServices.Speech.Internal.carbon_csharpPINVOKE' threw an exception. 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 subscription, String region) at Microsoft.CognitiveServices.Speech.SpeechFactory.FromSubscription(String subscriptionKey, String region) at MicrosoftSpeechSDKSamples.SpeechRecognitionSamples.d__2.MoveNext() in C:\temp\csharp_samples\speech_recognition_samples.cs:line 86

内部例外1: TypeInitializationException:"SWIGExceptionHelper"的类型初始值设定项引发了异常.

Inner Exception 1: TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.

内部例外2: DllNotFoundException:无法加载DLL'Microsoft.CognitiveServices.Speech.csharp.bindings.dll':找不到指定的模块. (来自HRESULT的异常:0x8007007E)

Inner Exception 2: DllNotFoundException: Unable to load DLL 'Microsoft.CognitiveServices.Speech.csharp.bindings.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

我认为Microsoft.CognitiveServices.Speech.csharp.bindings.dll不喜欢在Windows Server 2012 R2上运行,因为它存在于bin文件夹中(并且没有丢失)并且可以在Windows 10上运行.我写道下面的代码在一个小的Hello World控制台项目中,它引发了在Windows Server 2012 R2上运行的相同异常.

I think the Microsoft.CognitiveServices.Speech.csharp.bindings.dll doesn't like running on Windows Server 2012 R2, as it exists in the bin folder (and isn't missing) and works on Windows 10. I wrote the following code in a little Hello World console project and it threw the same exception running on Windows Server 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}");
    }
}

并且我尝试过以管理员身份运行,以防万一这是允许的事情.但这什么也没做.

And I've tried running as Administrator in case it was a permission thing. But that didn't do anything.

有人可以帮助我\向我展示在Windows Server 2012 R2上运行语音服务示例需要做什么吗?

Can someone please help me \ show me what I need to do to run the Speech service sample on Windows Server 2012 R2?

推荐答案

在构建">配置管理器"中检查项目的平台设置.
必须将其设置为x64或x86,而不是AnyCpu.

Check your platform settings for your project in Build > Configuration Manager.
It must be set to x64 or x86, not to AnyCpu.

这篇关于如何在Windows Server 2012 R2上运行Microsoft.CognitiveServices.Speech的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆