如何使用espeak API枚举可用语音和语言? 我使用C++的API来做一些简单的文本到语音合成。目前,我从关于如何开始的基本示例中复制了这一行: espeak_SetVoiceByName("default");
这似乎很好,但我知道espeak有几种不同语言的声音。如何使用espeak API枚举它们,然后在以后使用espeak API选择它们?使用espeak_SetVoiceByProperties下定义的函数如何使用espeak API枚举可用语音和语言? 我使用C++的API来做一些简单的文本到语音合成。目前,我从关于如何开始的基本示例中复制了这一行: espeak_SetVoiceByName("default");,c++,text-to-speech,espeak,C++,Text To Speech,Espeak,这似乎很好,但我知道espeak有几种不同语言的声音。如何使用espeak API枚举它们,然后在以后使用espeak API选择它们?使用espeak_SetVoiceByProperties下定义的函数 #ifdef __cplusplus extern "C" #endif ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name); /* Searches for a voice with a matching "nam
#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\u ListVoices
函数用于根据请求枚举语音,它定义在我引用的函数的正上方。espeak API的文档就是headerfile本身。你可以找到它
要枚举现有语音,可以使用以下方法:
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
}
}
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;
稍后,当您找到要使用的语音时,可以使用以下设置:
if(0!=voice){
espeak_SetVoiceByProperties(voice);
}
espeak\u VOICE
结构的定义如下:
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
}
}
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;
简单地阅读API文档?我没有找到API文档。我真的试过了,信不信由你。谷歌
espeak
。2.第一个结果。3.“文件”。4.“espeak库API”。5.阅读:)那不是单据,那是页眉。但是谢谢:-)@LennartRolland:标题是医生。你没有看到里面的文档注释解释如何使用它吗?我在回答中引用了相关的答案。^它也没有回答这个问题。@LennartRolland:是的,它回答了。请再读一遍。Q是如何列举可用的声音。