对不起,如果问题标题不好,但我试图解释我的意思:
据我所知,我可以使用system()
函数在我的 C++ 代码中使用 Linux 终端的命令。例如system("aplay sound.wav");
. 我不知道我是否可以像这样编写所有 Linux 命令,但是aplay
可以。
所以,我的问题在这里:我想espeak
在我的 C++ 程序中使用。我喜欢 espeak 读取我通过它传递的每个字符串(类似于aplay
上面代码中的内容,但尊重“字符串”)。是通过函数调用它更好,system()
还是在我的 C++ 代码中编写这样的代码并char* text
在我想读取新字符串时更改?:
#include <string.h>
#include <malloc.h>
#include <espeak-ng/speak_lib.h>
espeak_POSITION_TYPE position_type;
espeak_AUDIO_OUTPUT output;
char *path=NULL;
int Buflength = 500, Options=0;
void* user_data;
t_espeak_callback *SynthCallback;
espeak_PARAMETER Parm;
char Voice[] = {"English"};
char *text = {"this is a english test"};
unsigned int Size,position=0, end_position=0, flags=espeakCHARS_AUTO, *unique_identifier;
int main(int argc, char* argv[] )
{
output = AUDIO_OUTPUT_PLAYBACK;
int I, Run = 1, L;
espeak_Initialize(output, Buflength, path, Options );
espeak_SetVoiceByName(Voice);
const char *langNativeString = "en"; //Default to US English
espeak_VOICE voice;
memset(&voice, 0, sizeof(espeak_VOICE)); // Zero out the voice first
voice.languages = langNativeString;
voice.name = "US";
voice.variant = 2;
voice.gender = 1;
espeak_SetVoiceByProperties(&voice);
Size = strlen(text)+1;
espeak_Synth( text, Size, position, position_type, end_position, flags,
unique_identifier, user_data );
espeak_Synchronize( );
return 0;
}
哪个更快?