C++ 无法打开文件:../sysdeps/posix/system.c
我正在尝试将一些字符串传递到C++ 无法打开文件:../sysdeps/posix/system.c,c++,error-handling,segmentation-fault,coredump,espeak,C++,Error Handling,Segmentation Fault,Coredump,Espeak,我正在尝试将一些字符串传递到espeak,它将通过以下代码显示它们: #include <string.h> #include <malloc.h> #include <espeak/speak_lib.h> #include <iostream> #include <stdlib.h> #include <unistd.h> //#include <cstring> using namespace std;
espeak
,它将通过以下代码显示它们:
#include <string.h>
#include <malloc.h>
#include <espeak/speak_lib.h>
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
//#include <cstring>
using namespace std;
int main()
{
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"};
int i=0;
char text[11][200] {"hi ",
"This is...",
"you can ... ",
"I am ,,,, " ,
"you can ... ",
"hope you ... ",
"come in ... ",
"if you ... ",
"you will... ",
"I hope ... ",
"Take care "
};
unsigned int Size,position=0, end_position=0, flags=espeakCHARS_AUTO, *unique_identifier;
output = AUDIO_OUTPUT_PLAYBACK;
espeak_Initialize(output, Buflength, path, Options );
espeak_SetVoiceByName(Voice);
const char *langNativeString = "en_US";
espeak_VOICE voice= {0};
voice.languages = langNativeString;
voice.name = "US";
voice.variant = 2;
voice.gender = 1;
// Size = strlen(text)+1;
for (;;)
{
for(i=0; i<11; i++)
{
Size = sizeof(text[i]);
system("eog --fullscreen --disable-gallery --single-window 1.jpg &");
usleep(3000000);
espeak_Synth( text[i], Size, position, position_type, end_position, flags,
unique_identifier, user_data );
espeak_Synchronize( );
system("eog --fullscreen --disable-gallery --single-window 1.jpg &");
usleep(3000000);
}
//fflush(stdout);
}
return 0;
}
#包括
#包括
#包括
#包括
#包括
#包括
//#包括
使用名称空间std;
int main()
{
espeak_位置_类型位置_类型;
espeak_音频_输出;
char*path=NULL;
int BUFLENGHT=500,选项=0;
作废*用户数据;
t_espeak_callback*SynthCallback;
espeak_参数Parm;
字符语音[]={“英语”};
int i=0;
字符文本[11][200]{“hi”,
“这是……”,
“你可以……”,
“我是,,,”,
“你可以……”,
“希望你……”,
“进来……”,
“如果你……”,
“你会……”,
“我希望……”,
“保重”
};
无符号整数大小,位置=0,结束位置=0,标志=espeakCHARS\u AUTO,*唯一标识符;
输出=音频输出播放;
espeak_初始化(输出、长度、路径、选项);
espeak_SetVoiceByName(语音);
const char*langNativeString=“en_US”;
espeak_VOICE={0};
voice.languages=langNativeString;
voice.name=“美国”;
voice.variant=2;
voice.gender=1;
//大小=strlen(文本)+1;
对于(;;)
{
对于(i=0;i你认为有11个数组(句子),但实际上只有10个。
这两个
"I am glad too meet you here "
"you can see many science and technology products here ",
实际上只有一个,因为您错过了结尾的逗号我确实将这部分代码传输到了main()
函数的外部,现在它可以正常工作了:
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"};
int i=0;
unsigned int Size,position=0, end_position=0, flags=espeakCHARS_AUTO, *unique_identifier;
这一行代码中出现错误:`system(“eog—全屏—禁用库—single window 1.jpg&”)`如果从控制台运行该命令,是否会出现相同的错误?eog是否在代码外部正确运行?初始化所有变量。@marom:是的,我可以编译并运行system(eog)
在其他程序中没有错误。可能重复的代码是错误的,我已经解释了原因。有时代码正常工作的事实不会改变原始语句。好的,请告诉我哪些行是无用的,我可以删除它们?