~ubuntu-branches/ubuntu/oneiric/espeak/oneiric

« back to all changes in this revision

Viewing changes to src/synth_mbrola.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2011-05-04 11:25:46 UTC
  • mfrom: (1.1.24 upstream) (5.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20110504112546-ykijzihgc7ybgzn2
Tags: 1.45.04-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Add gbp.conf for use with git buildpackage
  - Update the explanation of the -b command-line flag in the espeak manpage

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
 
110
110
static MBROLA_TAB *mbrola_tab = NULL;
111
111
static int mbrola_control = 0;
112
 
 
 
112
static int mbr_name_prefix = 0;
113
113
 
114
114
espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int srate)
115
115
{//===================================================================================
123
123
 
124
124
        mbrola_name[0] = 0;
125
125
        mbrola_delay = 0;
 
126
        mbr_name_prefix = 0;
126
127
 
127
128
        if(mbrola_voice == NULL)
128
129
        {
133
134
 
134
135
        sprintf(path,"%s/mbrola/%s",path_home,mbrola_voice);
135
136
#ifdef PLATFORM_POSIX
 
137
        // if not found, then also look in
 
138
        //   usr/share/mbrola/xx, /usr/share/mbrola/xx/xx, /usr/share/mbrola/voices/xx
136
139
        if(GetFileLength(path) <= 0)
137
140
        {
138
 
                // mbrola voice file not found, look in /usr/share
139
141
     sprintf(path,"/usr/share/mbrola/%s",mbrola_voice);
140
142
        }
141
143
        if(GetFileLength(path) <= 0)
142
144
        {
143
 
                // mbrola voice file not found, look in /usr/share
 
145
     sprintf(path,"/usr/share/mbrola/%s/%s",mbrola_voice,mbrola_voice);
 
146
        }
 
147
        if(GetFileLength(path) <= 0)
 
148
        {
144
149
     sprintf(path,"/usr/share/mbrola/voices/%s",mbrola_voice);
145
150
        }
146
151
#endif
147
152
#ifdef PLATFORM_WINDOWS
148
153
        if(load_MBR() == FALSE)     // load mbrola.dll
149
 
                return(EE_INTERNAL_ERROR); 
 
154
        {
 
155
                fprintf(stderr, "Can't load mbrola.dll\n");
 
156
                return(EE_INTERNAL_ERROR);
 
157
        } 
150
158
#endif
151
159
 
152
160
        if(init_MBR(path) != 0)      // initialise the required mbrola voice
196
204
{//==========================================================================================================================================
197
205
// Look up a phoneme in the mbrola phoneme name translation table
198
206
// It may give none, 1, or 2 mbrola phonemes
199
 
        int mnem = ph->mnemonic;
200
207
        MBROLA_TAB *pr;
201
208
        PHONEME_TAB *other_ph;
202
209
        int found = 0;
 
210
        static int mnem;
203
211
 
204
212
        // control
205
213
        // bit 0  skip the next phoneme
206
214
        // bit 1  match this and Previous phoneme
207
215
        // bit 2  only at the start of a word
208
216
        // bit 3  don't match two phonemes across a word boundary
 
217
        // bit 4  add this phoneme name as a prefix to the next phoneme name (used for de4 phoneme prefix '?')
 
218
 
 
219
        *name2=0;
 
220
        *split=0;
 
221
        *control=0;
 
222
        mnem = ph->mnemonic;
209
223
 
210
224
        pr = mbrola_tab;
211
225
        while(pr->name != 0)
245
259
                                *name2 = pr->mbr_name2;
246
260
                                *split = pr->percent;
247
261
                                *control = pr->control;
248
 
                                return(pr->mbr_name);
 
262
 
 
263
                                if(pr->control & 0x10)
 
264
                                {
 
265
                                        mbr_name_prefix = pr->mbr_name;
 
266
                                        return(0);
 
267
                                }
 
268
                                mnem = pr->mbr_name;
 
269
                                break;
249
270
                        }
250
271
                }
251
272
 
252
273
                pr++;
253
274
        }
254
 
        *name2=0;
255
 
        *split=0;
256
 
        *control=0;
 
275
 
 
276
        if(mbr_name_prefix != 0)
 
277
        {
 
278
                mnem = (mnem << 8) | (mbr_name_prefix & 0xff);
 
279
        }
 
280
        mbr_name_prefix = 0;
257
281
        return(mnem);
258
282
}
259
283