Software Archive
Read-only legacy content
17060 Discussions

Optimize Speech Recognition

Priyank_T_
Beginner
336 Views

The below code is for Recognizing Speech through wav file.

Currently it takes about 2 to 3 sec to recognize the file. Is there any way to reduce that time.

 

    public void ReadFile(string InputAudioFilePath)
        {
            PXCMSession session = PXCMSession.CreateInstance();
            
            // session is a PXCMSession instance.
            PXCMAudioSource source = session.CreateAudioSource();

            // Set the audio fie
            PXCMAudioSource.DeviceInfo dinfo = new PXCMAudioSource.DeviceInfo();
          
            dinfo.did = InputAudioFilePath;

            // Set the active device
            source.SetDevice(dinfo);
            PXCMSpeechRecognition sr;
            session.CreateImpl<PXCMSpeechRecognition>(out sr);
            PXCMSpeechRecognition.ProfileInfo pinfo;

          
            String[] cmds = new String[4] { "Switch On", "Switch Off", "Light On","Light Off" };

            // Build the grammar.
            sr.BuildGrammarFromStringList(1, cmds, null);

            // Set the active grammar.
            sr.SetGrammar(1);


            sr.QueryProfile(0, out pinfo);
            sr.SetProfile(pinfo);
            // Set handler
            PXCMSpeechRecognition.Handler handler = new PXCMSpeechRecognition.Handler();
            handler.onRecognition = OnRecognition;
            // Start recognition
            var str = sr.StartRec(source, handler);
                              
        }

 

 

0 Kudos
0 Replies
Reply