예제 #1
0
        public SpeechAligner(string amPath, string dictPath, string g2PPath)
        {
            var configuration = new Configuration();

            configuration.AcousticModelPath = amPath;
            configuration.DictionaryPath    = dictPath;

            _context = new Context(configuration);
            if (g2PPath != null)
            {
                _context.SetLocalProperty("dictionary->allowMissingWords", "true");
                _context.SetLocalProperty("dictionary->createMissingWords", "true");
                _context.SetLocalProperty("dictionary->g2pModelPath", g2PPath);
                _context.SetLocalProperty("dictionary->g2pMaxPron", "2");
            }
            _context.SetLocalProperty("lexTreeLinguist->languageModel", "dynamicTrigramModel");
            _recognizer    = (Recognizer)_context.GetInstance(typeof(Recognizer));
            _grammar       = (AlignerGrammar)_context.GetInstance(typeof(AlignerGrammar));
            _languageModel = (DynamicTrigramModel)_context.GetInstance(typeof(DynamicTrigramModel));
            Tokenizer      = new UsEnglishTokenizer();
        }
예제 #2
0
        public string align()
        {
            if (PROP_PERFORM_SPOTTING)
            {
                phraseSpotterResult = new List <PhraseSpotterResult>();
                collectPhraseSpottingResult();
            }

            cm = new ConfigurationManager(config);
            AlignerSearchManager sm = (AlignerSearchManager)cm
                                      .lookup("searchManager");

            sm.setSpotterResult(phraseSpotterResult);
            optimize();
            setGlobalProperties();
            recognizer = (Recognizer)cm.lookup(PROP_RECOGNIZER);
            grammar    = (AlignerGrammar)cm.lookup(PROP_GRAMMAR);
            datasource = (AudioFileDataSource)cm.lookup(PROP_AUDIO_DATA_SOURCE);
            datasource.setAudioFile(new File(audioFile), null);
            allocate();
            return(start_align());
        }