gpt4 book ai didi

c++ - Windows 上的 Flite API 错误

转载 作者:太空宇宙 更新时间:2023-11-04 12:45:18 25 4
gpt4 key购买 nike

我为windows构建flite,代码是:

#include "..\\include\\flite.h"
cst_voice *register_cmu_us_kal();
int main(int argc, char **argv)
{ cst_voice *v;
if (argc != 2)
{
fprintf(stderr, "usage: flite_test FILE\n");
exit(-1);
}
flite_init();
v = new_voice();
flite_text_to_speech("This is a test",v,"play");
return 0;
}

但我收到 printf 消息“usage:”,如果我删除它,我会收到“尝试访问 -1 类型 val flite 中的词典”。我在 Windows 上,所以我在没有文档中的参数的情况下调用 project.exe。 你知道如何解决这个问题吗?

最佳答案

如评论中所述,您应该删除参数计数 (argc) 检查。

此外:当您调用 new_voice 方法时,您会得到未初始化的 cst_voice 并且您仍然无法使用它。

这就是你得到错误的原因:

tried to access lexicon in -1 type val flite

这意味着 lex (cst_lexicon) 在 cst_voice 结构中仍未初始化。

我想您需要执行类似以下代码的操作:

cst_voice *register_cmu_us_no_wave()
{
cst_voice *v = new_voice();
cst_lexicon *lex;

v->name = "no_wave_voice";

/* Set up basic values for synthesizing with this voice */
usenglish_init(v);
feat_set_string(v->features,"name","cmu_us_no_wave");

/* Lexicon */
lex = cmu_lex_init();
feat_set(v->features,"lexicon",lexicon_val(lex));

/* Intonation */
feat_set_float(v->features,"int_f0_target_mean",95.0);
feat_set_float(v->features,"int_f0_target_stddev",11.0);

feat_set_float(v->features,"duration_stretch",1.1);

/* Post lexical rules */
feat_set(v->features,"postlex_func",uttfunc_val(lex->postlex));

/* Waveform synthesis: diphone_synth */
feat_set(v->features,"wave_synth_func",uttfunc_val(&no_wave_synth));

return v;
}

关于c++ - Windows 上的 Flite API 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51979973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com