static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int control) { // control: bit0=1 include mbrola voices int ix; int score; int nv; // number of candidates int n_parts = 0; int lang_len = 0; espeak_VOICE *vp; char language[80]; char buf[sizeof(path_home)+80]; // count number of parts in the specified language if ((voice_select->languages != NULL) && (voice_select->languages[0] != 0)) { n_parts = 1; lang_len = strlen(voice_select->languages); for (ix = 0; (ix <= lang_len) && ((unsigned)ix < sizeof(language)); ix++) { if ((language[ix] = tolower(voice_select->languages[ix])) == '-') n_parts++; } } if ((n_parts == 1) && (control & 1)) { if (strcmp(language, "mbrola") == 0) { language[2] = 0; // truncate to "mb" lang_len = 2; } sprintf(buf, "%s/voices/%s", path_home, language); if (GetFileLength(buf) == -2) { // A subdirectory name has been specified. List all the voices in that subdirectory language[lang_len++] = PATHSEP; language[lang_len] = 0; n_parts = -1; } } // select those voices which match the specified language nv = 0; for (ix = 0; ix < n_voices_list; ix++) { vp = voices_list[ix]; if (((control & 1) == 0) && (memcmp(vp->identifier, "mb/", 3) == 0)) continue; if ((score = ScoreVoice(voice_select, language, n_parts, lang_len, voices_list[ix])) > 0) { voices[nv++] = vp; vp->score = score; } } voices[nv] = NULL; // list terminator if (nv == 0) return 0; // sort the selected voices by their score qsort(voices, nv, sizeof(espeak_VOICE *), (int(__cdecl *)(const void *, const void *))VoiceScoreSorter); return nv; }
static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int control) {//====================================================================================== // control: bit0=1 include mbrola voices int ix; int score; int nv; // number of candidates int n_parts=0; int lang_len=0; espeak_VOICE *vp; char language[80]; // count number of parts in the specified language if((voice_select->languages != NULL) && (voice_select->languages[0] != 0)) { n_parts = 1; lang_len = strlen(voice_select->languages); for(ix=0; (ix<=lang_len) && ((unsigned)ix < sizeof(language)); ix++) { if((language[ix] = tolower(voice_select->languages[ix])) == '-') n_parts++; } } // select those voices which match the specified language nv = 0; for(ix=0; ix<n_voices_list; ix++) { vp = voices_list[ix]; if(((control & 1) == 0) && (memcmp(vp->identifier,"mb/",3) == 0)) continue; if((score = ScoreVoice(voice_select, language, n_parts, lang_len, voices_list[ix])) > 0) { voices[nv++] = vp; vp->score = score; } } voices[nv] = NULL; // list terminator if(nv==0) return(0); // sort the selected voices by their score qsort(voices,nv,sizeof(espeak_VOICE *),VoiceScoreSorter); return(nv); } // end of SetVoiceScores