【发布时间】:2018-10-24 15:46:20
【问题描述】:
我需要将 wav 文件中的语音转换为文本。所以我从Quickstart: Recognize speech using Speech service C# SDK页面下载了示例C#代码项目,并按照页面上的说明进行操作。
它适用于 Windows 10,但我需要该项目在 Windows Servers 2012 R2 上运行,而它不适用于 Windows Servers 2012 R2。
当我在 Windows Servers 2012 R2 上运行它时,我按下 3 键来获取 3。带有文件输入的语音识别选项。但是当它尝试执行以下代码时(使用有效的订阅和区域值)
var factory = SpeechFactory.FromSubscription("YourSubscriptionKey", "YourServiceRegion");
抛出以下异常:
发生 System.TypeInitializationException H结果=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(字符串订阅密钥,字符串区域) 在 MicrosoftSpeechSDKSamples.SpeechRecognitionSamples.d__2.MoveNext() 在 C:\temp\csharp_samples\speech_recognition_samples.cs:line 86
内部异常 1: TypeInitializationException:“SWIGExceptionHelper”的类型初始化程序引发了异常。
内部异常 2: DllNotFoundException:无法加载 DLL 'Microsoft.CognitiveServices.Speech.csharp.bindings.dll':找不到指定的模块。 (HRESULT 异常:0x8007007E)
我认为 Microsoft.CognitiveServices.Speech.csharp.bindings.dll 不喜欢在 Windows Server 2012 R2 上运行,因为它存在于 bin 文件夹中(并且没有丢失)并且可以在 Windows 10 上运行。我写道在一个小小的 Hello World 控制台项目中添加以下代码,它在 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}");
}
}
我已经尝试以管理员身份运行,以防这是一个权限问题。但这并没有起到任何作用。
谁能帮我\告诉我在 Windows Server 2012 R2 上运行语音服务示例需要做什么?
【问题讨论】:
标签: c# speech-recognition microsoft-cognitive