After many tests, I was convinced that the problem is with KeywordRecognizer !
we need help from Microsoft team for fixed this bug
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hi there,
i have a console app that uses azure for speech recognition offline from microphone (by KeywordRecognitionModel table) on linux IOT(raspberry pi).
when i run it, at first time it works correctly and can recognize my word, but after 3 or more recognition , it crashes the app, even try-catch cant handle it.
Note : the following code works good on windows PC, without any crash or error, but on linux raspberry pi it crashes the app.
using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;
using System;
using System.Diagnostics;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
namespace VoiceAssistant
{
class Program
{
static async Task Main()
{
bool working = false;
while (true)
{
try
{
if (!working)
{
Console.WriteLine("**true working**");
working = true;
await PropertyStart();
}
}
catch (Exception ex)
{
Console.WriteLine("**false working**");
working = false;
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
private static async Task PropertyStart()
{
int count = 0;
Console.WriteLine("Start 2");
try
{
//var config = SpeechTranslationConfig.FromSubscription("key", "westus");
Console.WriteLine("Step 1");
//RecordingPanel recordingPanel = new RecordingPanel();
var keywordModel = KeywordRecognitionModel.FromFile("my_home.table");
Console.WriteLine("Step 2");
var audioConfig = AudioConfig.FromDefaultMicrophoneInput();
var keywordRecognizer = new KeywordRecognizer(audioConfig);
//keywordRecognizer.Properties.SetProperty("SPEECH-ObjectCountWarnThreshold", "10000");
Console.WriteLine("Step 3");
while (true)
{
try
{
Console.WriteLine("Start Result");
KeywordRecognitionResult result = await keywordRecognizer.RecognizeOnceAsync(keywordModel);
Console.WriteLine("A Start Result");
// Checks result.
if (result.Reason == ResultReason.RecognizedKeyword)
{
count++;
Console.WriteLine("Stop");
//await keywordRecognizer.StopRecognitionAsync();
//await keywordRecognizer.StopRecognitionAsync();
Console.WriteLine("a Stop" + result.Duration.TotalSeconds.ToString());
Console.WriteLine(count.ToString() + $"We recognized: {result.Text}");
//recordingPanel.StartBtn_Click();
//keywordRecognizer.Dispose();
}
else if (result.Reason == ResultReason.NoMatch)
{
Console.WriteLine($"NOMATCH: Speech could not be recognized.");
}
else if (result.Reason == ResultReason.Canceled)
{
var cancellation = CancellationDetails.FromResult(result);
Console.WriteLine($"CANCELED: Reason={cancellation.Reason}");
if (cancellation.Reason == CancellationReason.Error)
{
Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");
Console.WriteLine($"CANCELED: ErrorDetails={cancellation.ErrorDetails}");
Console.WriteLine($"CANCELED: Did you update the subscription info?");
}
}
//await RecognizeSpeechAsync();
Console.WriteLine("**");
}
catch (Exception ex)
{
Console.WriteLine("Error in :::: " + ex.Message);
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error " + ex.Message);
}
Console.ReadLine();
}
}
After many tests, I was convinced that the problem is with KeywordRecognizer !
we need help from Microsoft team for fixed this bug