繁体   English   中英

VSCode 发生异常:CLR/System.ApplicationException

[英]VSCode exception has occurred: CLR/System.ApplicationException

我正在使用 VSCode 中的 C# 处理语音转文本 model。 model 正确转录第一个文件。 当我添加一个新文件并尝试转录时,我收到以下错误:

发生异常:CLR/System.ApplicationException System.Private.CoreLib.dll 中发生“System.ApplicationException”类型的异常,但未在用户代码中处理:“异常错误代码:0x8 (SPXERR_FILE_OPEN_FAILED)”在 Microsoft。 CognitiveServices.Speech.Internal.SpxExceptionThrower.ThrowIfFail(IntPtr hr) 在 Microsoft.CognitiveServices.Speech.Recognizer.FromConfig(GetRecognizerFromConfigDelegate fromConfig, SpeechConfig SpeechConfig, AudioConfig audioConfig) 在 Microsoft.CognitiveServices.Speech.SpeechRecognizer..ctor(SpeechConfig speechConfig, AudioConfig audioConfig) ) 在 NEST.Program.d__1.MoveNext() 中 C:\Users\admin\source\repos\AI-102-Process-Speech-master\transcribe_speech_to_text\csharp\NEST\Program.cs:System.Runtime 的第 26 行。 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)的 System.Runtime.CompilerServices.TaskAwai 的 ExceptionServices.ExceptionDispatchInfo.Throw() ter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at NEST.Program.d__0.MoveNext() in C:\Users\admin\source\repos\AI-102-Process-Speech-master \transcribe_speech_to_text\csharp\NEST\Program.cs:第 12 行

await RecognizeSpeechAsync(); part 是发生异常的地方(第 12 行)。 第 26 行正在使用 (var Recognizer = new SpeechRecognizer(config, audioInput))。

我的代码是:

using System;
using System.Threading.Tasks;
using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;

namespace NEST
{
    class Program
    {
        static async Task Main(string[] args)
        {
            await RecognizeSpeechAsync();
        }

        static async Task RecognizeSpeechAsync()
        {
            // Configure the subscription information for the service to access.
            // Use either key1 or key2 from the Speech Service resource you have created
            var config = SpeechConfig.FromSubscription("subscriptionkeyx", "regionx");

            // Setup the audio configuration, in this case, using a file that is in local storage.
            using (var audioInput = AudioConfig.FromWavFileInput("C:/Users/admin/source/repos          /AI-102-Process-Speech-master/transcribe_speech_to_text/media/whatstheweatherlike.wav"))

            // Pass the required parameters to the Speech Service which includes the configuration
            // and the audio file name that you will use as input
            using (var recognizer = new SpeechRecognizer(config, audioInput))
            {
                Console.WriteLine("Recognizing first result...");
                var result = await recognizer.RecognizeOnceAsync();

提前致谢。

SPXERR_FILE_OPEN_FAILED表示文件未找到或打开失败。

我在文件路径中添加了一个空格来重现您的问题。 (您使用的是绝对路径。)

错误路径:

C:/Users/Administrator/source/repos   /vscodeConsole/narration.wav

在此处输入图像描述

正确的路径

C:/Users/Administrator/source/repos/vscodeConsole/narration.wav

在此处输入图像描述

私人的

查看错误信息,26号线附近有错误。

您可以使用我的示例代码进行测试 如果它运行正常,那是你的代码有问题。 我初步判断是你文件路径附近的代码异常。

在此处输入图像描述

如果我的示例代码不能正常运行,可能是安装了VSCode(含Extension)或者dotnet core导致的,需要进一步的TroubleShooting。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM