summaryrefslogtreecommitdiff
path: root/tools/grxmlcompile/vocab.h
blob: e52604516d7c2dbfba9e56f63979d545c25bfdef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*---------------------------------------------------------------------------*
 *  vocab.h                                                                  *
 *                                                                           *
 *  Copyright 2007, 2008 Nuance Communciations, Inc.                         *
 *                                                                           *
 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
 *  you may not use this file except in compliance with the License.         *
 *                                                                           *
 *  You may obtain a copy of the License at                                  *
 *      http://www.apache.org/licenses/LICENSE-2.0                           *
 *                                                                           *
 *  Unless required by applicable law or agreed to in writing, software      *
 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
 *  See the License for the specific language governing permissions and      *
 *  limitations under the License.                                           *
 *                                                                           *
 *---------------------------------------------------------------------------*/


/** FILE:	        vocab.h
**  DATE MODIFIED:	31-Aug-07
**  DESCRIPTION:	Container class for Nuance Vocabulary access
**
**			All rights reserved
*/

#ifndef __vocab_h__
#define  __vocab_h__

#include <vector>
#include <string>
#include "SR_Session.h"
#include "SR_Vocabulary.h"

//#include "srec_arb.h"

#include "simapi.h"


#define GENERIC_CONTEXT '_'
#define SILENCE_CONTEXT '#'
#define INTRA_SILENCE_CONTEXT '&'

class Vocabulary
{
 public:
    Vocabulary();
    Vocabulary( std::string const & vocFileName );
    ~Vocabulary();
    SR_Vocabulary *getSRVocabularyHandle() { return m_hVocab; }
 private:
    SR_Vocabulary *m_hVocab;
};


class AcousticModel
{
    public:
        AcousticModel( std::string & arbFileName );
        ~AcousticModel();
        CA_Arbdata *getCAModelHandle() {return m_CA_Arbdata; }
        int getStateIndices(int id, std::vector<int> & stateIDs);
    private:
        CA_Arbdata* m_CA_Arbdata;
};


class Pronunciation
{
    public:
        typedef enum PelPosition {LEFT, RIGHT, MIDDLE};
        Pronunciation();
        //    Pronunciation( Vocabulary & vocab );
        int lookup( Vocabulary & vocab, std::string  & phrase );
        ~Pronunciation();
        int addPron( std::string & s );
        int getPronCount(); // returns number of prons
        bool getPron( int index, std::string &s );
        void clear();
        void print();
        void printModelIDs();
        int getPhonemeCount( int pronIndex );
        bool getPhoneme( int pronIndex, int picIndex , std::string &phoneme );
        int lookupModelIDs( AcousticModel &acoustic );
        int getModelCount( int pronIndex ); //
        int getModelID( int pronIndex, int modelPos );
        bool getPIC( int pronIndex, int picIndex, std::string &pic );

    private:
        Vocabulary *m_pVocab;

        std::string m_Phrase;
        std::vector<std::string> m_Prons;
        std::vector< std::vector<int> > m_ModelIDs;
};

#endif // __vocab_h__