Как я могу перечислить доступные голоса и языки, используя espeak API?

я использую озвучки API от C ++ сделать простой синтез текста в речь из моего встроенного приложения. В настоящее время я скопировал эту строку из базового примера о том, как начать:

espeak_SetVoiceByName("default");

Кажется, это работает нормально, однако я знаю, что в espeak есть несколько голосов на разных языках. Как я могу перечислять те и позже Выбрать они используют espeak API?

0

Решение

Документация для espeak API — это сам файл заголовка. Вы можете найти это Вот.

Чтобы перечислить существующие голоса, вы можете использовать что-то вроде этого:

const espeak_VOICE **list=espeak_ListVoices(0);
espeak_VOICE *voice=0;
for(;*list!=0;++list){
voice=*list;
if(0!=voice){
//Look at voice parameters such has voice->name here
}
}

Позже, когда вы нашли голос, который хотите использовать, вы можете установить его следующим образом:

if(0!=voice){
espeak_SetVoiceByProperties(voice);
}

espeak_VOICE Структура определяется следующим образом:

typedef struct {
const char *name;      // a given name for this voice. UTF8 string.
const char *languages;       // list of pairs of (byte) priority + (string) language (and dialect qualifier)
const char *identifier;      // the filename for this voice within espeak-data/voices
unsigned char gender;  // 0=none 1=male, 2=female,
unsigned char age;     // 0=not specified, or age in years
unsigned char variant; // only used when passed as a parameter to espeak_SetVoiceByProperties
unsigned char xx1;     // for internal use
int score;       // for internal use
void *spare;     // for internal use
} espeak_VOICE;
1

Другие решения

Использовать espeak_SetVoiceByProperties функция, которая определена непосредственно под той, которую вы использовали.

#ifdef __cplusplus
extern "C"#endif
ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name);
/* Searches for a voice with a matching "name" field.  Language is not considered.
"name" is a UTF8 string.

Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/

#ifdef __cplusplus
extern "C"#endif
ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec);
/* An espeak_VOICE structure is used to pass criteria to select a voice.  Any of the following
fields may be set:

name     NULL, or a voice name

languages  NULL, or a single language string (with optional dialect), eg. "en-uk", or "en"
gender   0=not specified, 1=male, 2=female

age      0=not specified, or an age in years

variant  After a list of candidates is produced, scored and sorted, "variant" is used to index
that list and choose a voice.
variant=0 takes the top voice (i.e. best match). variant=1 takes the next voice, etc
*/

espeak_VOICE структура определена и задокументирована недалеко от нее.

espeak_ListVoices Функция для перечисления голосов по запросу определяется прямо над функциями, которые я цитировал.

0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector