SAPI does not implement phonetic alphabet selection.

dj45-sys

New member
Joined
Jul 12, 2021
Messages
2
Programming Experience
1-3
Hey, Coders
Programming my virtual assistant I have encountered this error
- SAPI does not implement phonetic alphabet selection.
I have reviewed the solution in forums and I have found that I have to add this line of code

C#:
gb.Culture = new System.Globalization.CultureInfo("es-ES");

I have added it but the problem continues.

Objective: For the assistant to respond both through response and actions.

Steps that led to reproduce the error: Well, I do not remember very well how it happened but I think it was due to a change in the gui

Current results: Does not recognize audio

Environment: WPF System.Speech

Thanks in advance and this is my code
C#:
private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try{

                rec.SetInputToDefaultAudioDevice();

                Choices sentences = new Choices(loadSentences());

                GrammarBuilder gb = new GrammarBuilder();
                gb.Append(sentences);
                gb.Culture = new System.Globalization.CultureInfo("es-ES");

                Grammar g = new Grammar(gb);
                
                rec.LoadGrammar(g);
                rec.RecognizeAsync(RecognizeMode.Multiple);

                rec.SpeechRecognized += Rec_SpeechRecognized;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        
        
        private void Rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            try
            {
                foreach (Commands c in list)
                {
                    if (e.Result.Confidence > 0.6)
                    {
                        if (c.Command.ToString().Equals(e.Result.Text.ToString()))
                        {
                            MessageBox.Show(c.Command.ToString());

                            if (c.Action.Trim().Length > 0 || c.Action != null)
                            {
                                System.Diagnostics.Process.Start(c.Action.ToString());
                            }

                            if (c.Response.Trim().Length > 0)
                            {
                                nexus.SpeakAsync(c.Response.ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            
        }
 
Out of WPF... Your issue is with SAPI. The fact that you are using a WPF GUI for your app doesn't change the context of the problem.
 
Depends. Can you point me to the documentation that says that SAPI is supposed to support phonetic alphabet?
 
I have to question why you're using SAPI in the first place, given that there's a managed Speech API and you're creating a .NET application. Is there something that SAPI provides that System.Speech does not?
 
Back
Top Bottom