认知服务。 Azure终结点无法正常工作

时间:2019-05-08 16:59:13

标签: c# azure unity3d speech-to-text azure-cognitive-services

我集成了Microsoft认知服务文本语音的30天免费试用期。

var config = SpeechConfig.FromSubscription("fake", "westus");

   using (var recognizer = new SpeechRecognizer(config))
      {
        lock (threadLocker)
        {
            waitingForReco = true;
        }

        var result = recognizer.RecognizeOnceAsync().Result;

        string newMessage = string.Empty;
        if (result.Reason == ResultReason.RecognizedSpeech)
        {

            newMessage = result.Text;
        }
        else if (result.Reason == ResultReason.NoMatch)
        {
            newMessage = "NOMATCH: Speech could not be recognized.";
        }
        else if (result.Reason == ResultReason.Canceled)
        {
            var cancellation = CancellationDetails.FromResult(result);
            newMessage = $"CANCELED: Reason={cancellation.Reason} ErrorDetails={cancellation.ErrorDetails}";
        }

        lock (threadLocker)
        {
            message = newMessage;
            waitingForReco = false;
        }
    }

当我使用免费的演示密钥连接到api时,它将起作用。当我在Azure中创建Azure认知服务时,它始终返回已取消。

我需要为此演示密钥和生产密钥配置其他任何区别吗?

1 个答案:

答案 0 :(得分:2)

我认为您可能创建了错误的服务。对于认知服务,有很多类型,例如面部,路易斯,语音服务等。在这种情况下,您需要在Azure门户上创建资源时通过搜索语音来创建语音服务。

enter image description here

enter image description here

希望有帮助!