我正在尝试从C++
项目中编译一些Festival
代码。当我编译Festival
时,我收到以下错误:
Making in directory ./src ...
Making in directory src/arch ...
Making in directory src/arch/festival ...
Making in directory src/modules ...
Making in directory src/modules/rxp ...
Making in directory src/modules/clunits ...
Making in directory src/modules/clustergen ...
Making in directory src/modules/MultiSyn ...
Making in directory src/modules/MultiSyn/inst_tmpl ...
Making in directory src/modules/hts_engine ...
Making in directory src/modules/diphone ...
gcc -c -g -I../include -I../../../src/include -I../../../../speech_tools/include di_io.cc
di_io.cc: In function ‘void load_index(DIPHONE_DATABASE*)’:
di_io.cc:111: error: ambiguous overload for ‘operator=’ in ‘line = EST_TokenStream::get_upto_eoln()()’
../../../../speech_tools/include/EST_String.h:477: note: candidates are: EST_String& EST_String::operator=(const char*) <near match>
../../../../speech_tools/include/EST_String.h:479: note: EST_String& EST_String::operator=(char) <near match>
../../../../speech_tools/include/EST_String.h:481: note: EST_String& EST_String::operator=(const EST_String&) <near match>
make[3]: *** [di_io.o] Error 1
make[2]: *** [diphone] Error 2
make[1]: *** [modules] Error 2
make: *** [src] Error 2
发生错误的函数:
static void load_index(DIPHONE_DATABASE *database)
{
EST_TokenStream ts;
int i;
EST_String line;
if (ts.open(database->index_file) == -1)
{
cerr << "Diphone: Can't open file " << database->index_file << endl;
festival_error();
}
for (i=0; (!ts.eof()) && (i<database->ndiphs);)
{
line = ts.get_upto_eoln(); //this is di_io.cc:111
if ((line.length() > 0) && (line[0] != ';'))
{
EST_TokenStream ls;
ls.open_string(line);
database->indx[i]->diph = wstrdup(ls.get().string());
database->indx[i]->file = wstrdup(ls.get().string());
database->indx[i]->beg = atof(ls.get().string());
database->indx[i]->mid = atof(ls.get().string());
database->indx[i]->end = atof(ls.get().string());
ls.close();
i++;
}
}
if (i == database->ndiphs)
{
cerr << "Diphone: too many diphones in DB" << endl;
festival_error();
}
database->nindex = i;
database->ndiphs = i;
ts.close();
}
如何摆脱上述错误?
答案 0 :(得分:2)
get_upto_eoln
返回什么?
您可以在operator=
课程中精确重载EST_String
。
或者,您可以明确地创建一个字符串,如:
line = std::string(ts.get_upto_eoln());
而不是
line = ts.get_upto_eoln();
答案 1 :(得分:2)
我假设您使用的非标准类型来自speech-tools
库,记录为here,因为这是我在Google上搜索类名时发现的。如果这是错的,请更新问题以指明它们的来源。
我还假设错误行(di_io.cc
的第111行)是这样的:
line = ts.get_upto_eoln();
因为那是我能看到的唯一一个可能导致错误信息的人;再次,如果它是一个不同的行,请更新问题。
EST_TokenStream::get_upto_eoln
返回EST_Token
。您正尝试将其分配给不同类型的变量(EST_String
),并且没有隐式转换。
您可以使用EST_String
函数将函数结果转换为string
:
line = ts.get_upto_eoln().string();