public bool QueryVoiceRecognized(out PXCMVoiceRecognition.Recognition data) { data = new PXCMVoiceRecognition.Recognition(); data.nBest = new PXCMVoiceRecognition.Recognition.NBest[4]; data.dictation = ""; if (!initialized) { return(false); } IntPtr data1 = Marshal.AllocHGlobal(2112); bool sts = QueryVoiceRecognizedC(instance, data1); if (sts) { data.timeStamp = (ulong)Marshal.ReadInt64(data1, 0); for (int i = 0; i < 4; i++) { data.nBest[i].label = Marshal.ReadInt32(data1, 8 + i * 8); data.nBest[i].confidence = Marshal.ReadInt32(data1, 8 + i * 8 + 4); } data.duration = (uint)Marshal.ReadInt32(data1, 60); data.dictation = Marshal.PtrToStringUni(new IntPtr(data1.ToInt64() + 64), 1024).Split(new Char[] { '\0' })[0]; } Marshal.FreeHGlobal(data1); return(sts); }
public override void OnRecognized(ref PXCMVoiceRecognition.Recognition data) { if (data.label < 0) { _track.OnVoiceInput(new VoiceData("Dictation", data.dictation)); } else { //form.ClearScores(); VoiceData voiceData = new VoiceData("Command"); for (int i = 0; i < 4; i++) { int label = data.nBest[i].label; uint confidence = data.nBest[i].confidence; if (label < 0 || confidence == 0) { continue; } voiceData.Commands.Add(VoiceTracking.GameCommands[label], confidence); //scores += VoiceTracking.GameCommands[label] + ":" + confidence + ","; } _track.OnVoiceInput(voiceData); } }
public override void OnRecognized(ref PXCMVoiceRecognition.Recognition data) { form.OnRecognized(data); /* * if (data.label < 0) * { * form.PrintConsole(data.dictation); * } * else * { * form.ClearScores(); * for (int i = 0; i < 4; i++) * { * int label = data.nBest[i].label; * uint confidence = data.nBest[i].confidence; * if (label < 0 || confidence == 0) continue; * form.SetScore(label,confidence); * } * }*/ }
public void OnRecognized(PXCMVoiceRecognition.Recognition data) { if (data.label < 0) { System.Diagnostics.Debug.Print("dictation: " + data.dictation); } else { for (int i = 0; i < 4; i++) { int label = data.nBest[i].label; uint confidence = data.nBest[i].confidence; if (label < 0 || confidence == 0) { continue; } if (i == 0 && confidence > 30) { if (cmds[label] == "next slide" || cmds[label] == "nextslide" || cmds[label] == "powerpoint next slide" || cmds[label] == "powerpoint next slide please") { gotoSlide(1); } if (cmds[label] == "previous slide" || cmds[label] == "powerpoint previous slide" || cmds[label] == "powerpoint previous slide please") { gotoSlide(-1); } if (cmds[label] == "create new slide" || cmds[label] == "add new slide" && confidence > 40 || cmds[label] == "add slide") { newslide(); } if (cmds[label] == "delete slide" && confidence > 40) { deleteslide(); } if (cmds[label] == "undo" || cmds[label] == "un do") { undo(); } if (cmds[label] == "redo" || cmds[label] == "re do") { redo(); } if (cmds[label] == "powerpoint start slideshow" || cmds[label] == "powerpoint begin slideshow" || cmds[label] == "start slideshow") { startshow(); } if (cmds[label] == "powerpoint exit slideshow" || cmds[label] == "exit slideshow") { endshow(); } } System.Diagnostics.Debug.Print("dictation: " + data.dictation + " > " + Convert.ToString(i) + " label: " + cmds[label] + ", confidence:" + Convert.ToString(confidence)); } } }
public override void OnRecognized(ref PXCMVoiceRecognition.Recognition data) { voiceState = !voiceState; //alertLabel = ""; detectedPhrase = data.dictation; confidenceLevel = data.confidence; /* * string str; * str = data.dictation; * * Console.WriteLine("Recognized<{0}>", str); * * * // Command words * if (str.CompareTo("swap forward") == 0) * Console.WriteLine("The previous image is shown!\n"); * else if (str.CompareTo("swap backward") == 0 || str.CompareTo("swap back") == 0) * Console.WriteLine("The next image is shown!\n"); * else if (str.CompareTo("rank") == 0 || str.CompareTo("ranking") == 0 || str.CompareTo("ranking mode") == 0) * Console.WriteLine("Ranking Mode is on!\n"); * else if (str.CompareTo("select") == 0 || str.CompareTo("selecting") == 0 || str.CompareTo("selecting mode") == 0) * Console.WriteLine("The image is selected!\n"); * * // Category * else if (str.CompareTo("cat") == 0 || str.CompareTo("kitty") == 0) * Console.WriteLine("Images from 1 to 25 are shown!\n"); * else if (str.CompareTo("aeroplane") == 0 || str.CompareTo("plane") == 0) * Console.WriteLine("Images from 26 to 50 are shown!\n"); * else if (str.CompareTo("dog") == 0 || str.CompareTo("puppy") == 0) * Console.WriteLine("Images from 51 to 75 are shown!\n"); * else if (str.CompareTo("donut") == 0) * Console.WriteLine("Images from 76 to 100 are shown!\n"); * else if (str.CompareTo("Eiffel Tower") == 0 || str.CompareTo("tower") == 0) * Console.WriteLine("Images from 101 to 125 are shown!\n"); * else if (str.CompareTo("Tom Mason") == 0) * Console.WriteLine("Images from 126 to 150 are shown!\n"); * else if (str.CompareTo("Taylor Swift") == 0) * Console.WriteLine("Images from 151 to 175 are shown!\n"); * else if (str.CompareTo("T-shirt") == 0) * Console.WriteLine("Images from 176 to 200 are shown!\n"); * else if (str.CompareTo("tennis racket") == 0) * Console.WriteLine("Images from 201 to 225 are shown!\n"); * else if (str.CompareTo("apple") == 0) * Console.WriteLine("Images from 226 to 250 are shown!\n"); * else if (str.CompareTo("eyeglasses") == 0) * Console.WriteLine("Images from 251 to 275 are shown!\n"); * else if (str.CompareTo("hourglass") == 0) * Console.WriteLine("Images from 276 to 300 are shown!\n"); * else if (str.CompareTo("Moon") == 0) * Console.WriteLine("Images from 301 to 325 are shown!\n\n"); * else if (str.CompareTo("sun") == 0) * Console.WriteLine("Images from 326 to 350 are shown!\n"); * else if (str.CompareTo("revolver") == 0 || str.CompareTo("gun") == 0) * Console.WriteLine("Images from 351 to 375 are shown!\n"); * else if (str.CompareTo("hamburger") == 0) * Console.WriteLine("Images from 376 to 400 are shown!\n"); * else if (str.CompareTo("pumpkin") == 0) * Console.WriteLine("Images from 401 to 425 are shown!\n"); * else if (str.CompareTo("ladder") == 0) * Console.WriteLine("Images from 426 to 450 are shown!\n"); * else if (str.CompareTo("skull") == 0) * Console.WriteLine("Images from 451 to 475 are shown!\n"); * else if (str.CompareTo("car") == 0) * Console.WriteLine("Images from 476 to 500 are shown!\n"); * else if (str.CompareTo("I MuSe") == 0) * Console.WriteLine("Voice Command!\n"); * else * Console.WriteLine("Please speak a command word or a name of categories.\n"); */ }
public bool QueryVoiceRecognized(out PXCMVoiceRecognition.Recognition data) { data=new PXCMVoiceRecognition.Recognition(); data.nBest=new PXCMVoiceRecognition.Recognition.NBest[4]; data.dictation=""; if (!initialized) return false; IntPtr data1=Marshal.AllocHGlobal(2112); bool sts=QueryVoiceRecognizedC(instance,data1); if (sts) { data.timeStamp=(ulong)Marshal.ReadInt64(data1,0); for (int i=0;i<4;i++) { data.nBest[i].label=Marshal.ReadInt32(data1,8+i*8); data.nBest[i].confidence=Marshal.ReadInt32(data1,8+i*8+4); } data.duration=(uint)Marshal.ReadInt32(data1,60); data.dictation=Marshal.PtrToStringUni(new IntPtr(data1.ToInt64()+64),1024).Split(new Char[]{'\0'})[0]; } Marshal.FreeHGlobal(data1); return sts; }
public override void OnRecognized(ref PXCMVoiceRecognition.Recognition data) { Console.WriteLine("\nRecognized<{0}>", data.dictation); word = data.dictation; }