Search code examples
c#azureunity-game-enginespeech-to-textazure-cognitive-services

Cognitive services. Azure endpoint not working


I integrated the 30 days free trial of the Speech to Text of Microsoft Cognitive Services.

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;
        }
    }

When i connect to the api with the free demo key it works. When i create an Azure Cognitive Service in Azure it always returns Canceled.

Are there any other differences i have to configure for this demo key and a production key?


Solution

  • I think you might created the wrong service. For cognitive services, there are many types, such as face, luis, speechservice and so on. In this case, you need to create a speech service by searching speech when you create a resource on azure portal.

    enter image description here

    enter image description here

    Hope it helps!