• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  vocab.h                                                                  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                         *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 
21 /** FILE:	        vocab.h
22 **  DATE MODIFIED:	31-Aug-07
23 **  DESCRIPTION:	Container class for Nuance Vocabulary access
24 **
25 **			All rights reserved
26 */
27 
28 #ifndef __vocab_h__
29 #define  __vocab_h__
30 
31 #include <vector>
32 #include <string>
33 #include "SR_Session.h"
34 #include "SR_Vocabulary.h"
35 
36 //#include "srec_arb.h"
37 
38 #include "simapi.h"
39 
40 
41 #define GENERIC_CONTEXT '_'
42 #define SILENCE_CONTEXT '#'
43 #define INTRA_SILENCE_CONTEXT '&'
44 
45 class Vocabulary
46 {
47  public:
48     Vocabulary();
49     Vocabulary( std::string const & vocFileName );
50     ~Vocabulary();
getSRVocabularyHandle()51     SR_Vocabulary *getSRVocabularyHandle() { return m_hVocab; }
52  private:
53     SR_Vocabulary *m_hVocab;
54 };
55 
56 
57 class AcousticModel
58 {
59     public:
60         AcousticModel( std::string & arbFileName );
61         ~AcousticModel();
getCAModelHandle()62         CA_Arbdata *getCAModelHandle() {return m_CA_Arbdata; }
63         int getStateIndices(int id, std::vector<int> & stateIDs);
64     private:
65         CA_Arbdata* m_CA_Arbdata;
66 };
67 
68 
69 class Pronunciation
70 {
71     public:
72         typedef enum PelPosition {LEFT, RIGHT, MIDDLE};
73         Pronunciation();
74         //    Pronunciation( Vocabulary & vocab );
75         int lookup( Vocabulary & vocab, std::string  & phrase );
76         ~Pronunciation();
77         int addPron( std::string & s );
78         int getPronCount(); // returns number of prons
79         bool getPron( int index, std::string &s );
80         void clear();
81         void print();
82         void printModelIDs();
83         int getPhonemeCount( int pronIndex );
84         bool getPhoneme( int pronIndex, int picIndex , std::string &phoneme );
85         int lookupModelIDs( AcousticModel &acoustic );
86         int getModelCount( int pronIndex ); //
87         int getModelID( int pronIndex, int modelPos );
88         bool getPIC( int pronIndex, int picIndex, std::string &pic );
89 
90     private:
91         Vocabulary *m_pVocab;
92 
93         std::string m_Phrase;
94         std::vector<std::string> m_Prons;
95         std::vector< std::vector<int> > m_ModelIDs;
96 };
97 
98 #endif // __vocab_h__
99 
100 
101