Microsoft Cognitive Services Voise to text doesn't work on uploaded to Azure website

Sviatlana 20 Reputation points
2024-07-04T14:41:38.0133333+00:00

I'm using Azure AI services to recognize speach and convert it into text with .Net

SpeechConfig speechConfig = SpeechConfig.FromSubscription(subscriptionKey, region);
            SpeechRecognitionResult result;
            using (SpeechRecognizer recognizer = new(speechConfig))
            {
                // Actively listen to the system microphone and wait for speaking to stop
                result = await recognizer.RecognizeOnceAsync();
                switch (result.Reason)
                {
                    case ResultReason.RecognizedSpeech:
                        // We were able to understand the user
                        return Json(new { result = result.Text }); 
                 ...

It works fine on localhost, but after website was posted on Azure portal it stoped working and all users getting an error:

Exception with an error code: 0xe (SPXERR_MIC_NOT_AVAILABLE)

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,347 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,583 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amira Bedhiafi 18,741 Reputation points
    2024-07-04T21:28:27.77+00:00

    The error shows that the mic is not recognized or not detected by the speech recognition system or accessible in the hosted environment on Azure.

    Azure web apps (and other cloud environments) do not have access to physical hardware like microphones. The error suggests that the application is trying to access a microphone on the server, which is not possible.

    So instead of performing speech recognition on the server, consider moving the speech recognition functionality to the client-side using JavaScript. You can use the Web Speech API or Azure's Cognitive Services SDK for JavaScript to handle speech recognition in the browser.

    0 comments No comments

0 additional answers

Sort by: Most helpful