Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK
MIT License
2.87k stars 1.85k forks source link

(SPXERR_MIC_ERROR) GetCallStack not implemented in WinRT - DialogServiceConnector #1338

Closed CarteKiwi closed 2 years ago

CarteKiwi commented 2 years ago

Hi,

Describe the bug (RuntimeError) : 0x15 (SPXERR_MIC_ERROR) GetCallStack not implemented in WinRT

To Reproduce Code:

var commandsConfig = CustomCommandsConfig.FromSubscription(applicationId, subscription, region);
commandsConfig.Language = "fr-fr";

var micro = devices.FirstOrDefault((c) => c.Name.Contains("Cinema")).Name;
                var config = AudioConfig.FromMicrophoneInput(micro);

_dialogServiceConnector = new DialogServiceConnector(commandsConfig, audioConfig);
_dialogServiceConnector.ActivityReceived += OnActivityReceived;
_dialogServiceConnector.Recognizing += OnRecognizing;
_dialogServiceConnector.Recognized += OnRecognized;
_dialogServiceConnector.Canceled += OnCanceled;
_dialogServiceConnector.SessionStarted += OnSessionStarted;
_dialogServiceConnector.SessionStopped += OnSessionStopped;

await _dialogServiceConnector.ConnectAsync();

bool isMicAvailable = true;
                try
                {
                    var mediaCapture = new Windows.Media.Capture.MediaCapture();
                    var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
                    settings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.Audio;
                    await mediaCapture.InitializeAsync(settings);
                }
                catch (Exception)
                {
                    isMicAvailable = false;
                }

                if (!isMicAvailable)
                {
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-microphone"));
                }
                else
                {
                    Debug.WriteLine("Microphone has been enabled");
                }

await _dialogServiceConnector.ListenOnceAsync();

Steps to reproduce the behavior:

  1. Instanciate CustomCommandsConfig
  2. Instanciate AudioConfig using a specific microphone (in my case: "Microsoft LifeCam Cinema")
  3. Instanciate DialogServiceConnector (using the CustomCommandsConfig instanciated in 1 and AudioConfig from 2)
  4. Call ConnectAsync from DialogServiceConnector
  5. Call ListenOnceAsync()
  6. SessionsStarted is called, then SpeechRecognitionCanceledEvent fired with the exception details.

Expected behavior The ListOnceAync() should not fire the Canceled event. (By the way, I am using ListenOnceAsync here because StartKeywordRecognitionAsync do nothing (it's working on x64 Machine, when executing locally on my machine).)

Version of the Cognitive Services Speech SDK 1.19.0

Platform, Operating System, and Programming Language

Additional context

CarteKiwi commented 2 years ago

It's working on Raspberry Pi 3 with W10 Iot 17763. Not working on Dragonboard 410C. I tried this project: WebcamApp sample It's working well (no need to use the devcon remove cmd).

I think the problem is coming from _dialogServiceConnector. It seems no able to use the microphone on Dragonboard, I don't know why.

The StartKeywordRecognitionAsync()does nothing. Nothing append when saying my usual key word.

Your help will be appreciate a lot, I'm stuck on it. Thanks.

brandom-msft commented 2 years ago

Thanks for providing the log, from there it looks like the microphone isn't being enumerated. The "model" field is empty.

"audio":{"source":{"type":"Microphones","model":"","samplerate":"16000","bitspersample":"16","channelcount":"1"}}}}

You mentioned that you're not using the instructions devcon remove cmd per the WebcamApp sample, maybe that or something following is missing in your setup?

CarteKiwi commented 2 years ago

Hi again :)

I tried again using the devcon remove ADCM\QCOM242E and devcon remove AUDD\QCOM2451 as mentionned.

BUT, using devcon remove will produce a negative effect: the HDMI sound is not working anymore !

I added a registry entry to enable HDMI audio: reg add HKLM\System\ControlSet001\Services\QCAUD\TopologySpeaker\Device0\DeviceConfig /v DeviceID /t REG_DWORD /d 0x46 /f

The HDMI audio is working fine until I use the devcon remove cmd.

In french, I will say: "C'est le chat qui se mord la queue" => I'm stuck: impossible to use HDMI audio (using default driver) and USB microphone (LifeCam Cinema) with DialogServiceConnector.

==> I think that the solution would be to:

(This is very important to keep the HDMI audio. This is the reason why I choose a DragonBoard 410C instead of Raspberry Pi 3 or 4, which is not supported by W10 (drivers are not implemented by MS))

Thanks again for your help. The light is not so far, we should be able to find a solution :) I continue investigate.

CarteKiwi commented 2 years ago

Fixed with the previous listed issue. Use the AudioConfig.FromMicrophoneInput(deviceID) did the trick. I can use the specified microphone, without removing default sound device of the Dragonboard 410C.

Thanks.