- Home /
 
 
               Question by 
               kartikaneja · Aug 01, 2011 at 04:43 AM · 
                voiceopenni  
              
 
              OpenNI and/or SAPI
Hey.. I was wondering if anybody knows if we can use Microsoft Speech API (SAPI) and/or any other voice recognition software for Unity?
Also.. do any of the OpenNI wrappers offer voice recognition capability?
               Comment
              
 
               
              Answer by Yanger_xy · Dec 15, 2011 at 02:08 PM
i am using SAPI,It works perfect in debug mode. but after building it, it crashed down when it comes to GetVoice function.
Here's my code.
 private SpVoice _voiceNotice = null;
 
                  _voiceNotice = new SpVoice();
     try
     {
         SpeechLib.ISpeechObjectTokens objTokens = _voiceNotice.GetVoices("", "");
         const string useVoice = "ScanSoft Mei-Ling_Full_22kHz";
         int useIndex = -1;
         for (int i = 0; i < objTokens.Count; i++)
         {
             if (objTokens.Item(i).GetDescription() == useVoice)
             {
                 useIndex = i;
                 break;
             }
         }
         if (useIndex == -1)
         {
             UnityEngine.Debug.Log("无法找到ScanSoft Mei-Ling_Full_22kHz 声音");
             useIndex = 0;
         }
         _voiceNotice.Voice = objTokens.Item(useIndex);
     }
     catch (System.Exception ex)
     {
         print(ex.Message);
     }
 
              Your answer