I created a simple UWP and it worked, I cloud not re-produce the issue
Paul
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
VS 2022, Win 11 Home build 22621.819
The below works in Debug and Release testing, however when I publish the Application it fails to stop Continuous Voice. I have narrowed it down to the while loop does not pick change "StaticVariables.ContinuousVoice " The variable is changed
Should I be doing something different?
thanks
public async Task SpeechContinuousMicAsync()
{
StaticVariables.VoiceText = " ";
StaticVariables.ContinuousVoice = true;
speechconfig = SpeechConfig.FromSubscription(Names.VoiceKey, Names.VoiceRegion);
speechconfig.EnableDictation();
StaticVariables.LogM = new() { Category = "VOICE", Action = "Before Using", SubAction = " " };
LogWriteLine();
// Creates a speech recognizer from microphone.
using (var recognizer = new SpeechRecognizer(speechconfig, audioConfig))
{
var phraseList = PhraseListGrammar.FromRecognizer(recognizer);
phraseList.Clear();
phraseList.AddPhrase("sedentary");
// Subscribes to events.
recognizer.Recognizing += (s, e) =>
{
// StaticVariables.VoiceText += e.Result.Text;
};
recognizer.Recognized += (s, e) =>
{
StaticVariables.VoiceText += $"{e.Result.Text} ";
StaticVariables.LogM = new() { Category = "VOICE", Action = "In Recognized:", SubAction = StaticVariables.ContinuousVoice.ToString() };
LogWriteLine();
};
recognizer.Canceled += (s, e) =>
{
Console.WriteLine($"\n Canceled. Reason: {e.Reason.ToString()}, CanceledReason: {e.Reason}");
StaticVariables.LogM = new() { Category = "VOICE", Action = "Canceled Reason:", SubAction = e.Reason.ToString() };
LogWriteLine();
};
recognizer.SessionStarted += (s, e) =>
{
Console.WriteLine("\n Session started event.");
StaticVariables.LogM = new() { Category = "VOICE", Action = "Session started event", SubAction = " " };
LogWriteLine();
};
recognizer.SessionStopped += (s, e) =>
{
Console.WriteLine("\n Session stopped event.");
StaticVariables.LogM = new() { Category = "VOICE", Action = "Session stopped event", SubAction = " " };
LogWriteLine();
};
// Starts continuous recognition.
// Uses StopContinuousRecognitionAsync() to stop recognition.
await recognizer.StartContinuousRecognitionAsync().ConfigureAwait(false);
StaticVariables.LogM = new() { Category = "VOICE", Action = "Before Do Loop ", SubAction = StaticVariables.VoiceText };
LogWriteLine();
do
{
} while (StaticVariables.ContinuousVoice == true);
// Stops recognition.
await recognizer.StopContinuousRecognitionAsync().ConfigureAwait(false);
StaticVariables.LogM = new() { Category = "VOICE", Action = "After await Stop", SubAction = StaticVariables.VoiceText };
LogWriteLine();
}
}
the above is called using the below
switch (btn.Tag.ToString())
{
case "VoiceOn":
MicOn.Visibility = Visibility.Collapsed;
MicOff.Visibility = Visibility.Visible;
await vtext.SpeechContinuousMicAsync();
StaticVariables.LogM = new() { Category = "VOICE", Action = "After await Stop", SubAction = StaticVariables.VoiceText };
logC.LogWriteLine();
newCase.CaseDescription = StaticVariables.VoiceText;
break;
case "VoiceOff":
MicOn.Visibility = Visibility.Visible;
MicOff.Visibility = Visibility.Collapsed;
StaticVariables.ContinuousVoice = false;
StaticVariables.LogM = new() { Category = "VOICE", Action = "After setting false", SubAction = StaticVariables.ContinuousVoice.ToString() };
logC.LogWriteLine();
I created a simple UWP and it worked, I cloud not re-produce the issue
Paul