I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!
Since the Microsoft Q&A community has a policy that The question author cannot accept their own answer. They can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer. Accepted answers show up at the top, resulting in improved discoverability for others.
Issue: Exception [SPXERR_RUNTIME_ERROR 0x1b] When Using SpeechRecognizer with AudioProcessingOptions for Echo Cancellation
Solution: Case History Link: https://learn.microsoft.com/en-us/answers/questions/2168570/exception-(spxerr-runtime-error-0x1b)-when-using-s#comment-1930643
The below solution will work with 64-bit applications only. Here is a revised version of your code snippet with the necessary checks:
var speechConfig = SpeechConfig.FromSubscription("YourKey", "YourRegion");
using (var audioProcessingOptions = AudioProcessingOptions.Create(AudioProcessingConstants.AUDIO_INPUT_PROCESSING_ENABLE_V2))
{
using (var audioConfig = AudioConfig.FromDefaultMicrophoneInput(audioProcessingOptions))
{
try
{
using (SpeechRecognizer recognizer = new SpeechRecognizer(speechConfig, audioConfig))
{
// Recognition logic
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.
Thanks