root/speech/TranscribeCSharp/Program.cs @ 487

Revision 487, 1.9 KB (checked in by ben, 8 months ago)

Add speech recognition code from a few years back.

Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5//using System.Speech;
6using SpeechLib;
7
8namespace Transcribe
9{
10    class Program
11    {
12        static void Main(string[] args)
13        {
14            return;
15            if (args.Length != 1 || !File.Exists(args[0]))
16            {
17                System.Console.Out.WriteLine("Must supply valid filename at command line");
18            }
19            else
20            {
21                SpSharedRecognizer ssr = new SpSharedRecognizer();
22               
23                SpInProcRecoContext rContext = new SpInProcRecoContext();
24                rContext.Pause();
25                //rContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(
26                //        RecoContext_Recognition);
27
28                rContext.Recognizer.SetPropertyNumber("AdaptationOn", 0);
29               
30                // Create dictation grammar
31                ISpeechRecoGrammar g = rContext.CreateGrammar(42);
32                g.DictationLoad(null, SpeechLoadOption.SLOStatic);
33               
34                ushort rus;
35                System.Guid aGuid;
36                WaveFormatEx wfe;
37                SpStream fs = new SpStream();
38                fs.BindToFile(ref rus, SPFILEMODE.SPFM_OPEN_READONLY,
39                    ref aGuid, ref wfe, 38 /*SPEVENTENUM.SPEI_RECOGNITION*/);
40                //rContext.Recognizer.AudioInputStream = fs;
41                g.DictationSetState(SpeechRuleState.SGDSActive);
42
43               
44                rContext.Resume();
45               
46            }
47           
48        }
49/*
50        static public void RecoContext_Recognition(int StreamNumber,
51            object StreamPosition,
52            SpeechRecognitionType RecognitionType,
53            ISpeechRecoResult Result)
54        {
55            int index;
56        }
57 * */
58    }
59}
Note: See TracBrowser for help on using the browser.