FLite 不会从 file/festvox 存储库加载语音

FLite won't load voice from file/festvox repository

我仍然无法使用 FLite TTS。将其构建到我的项目(Ubuntu 16.04 上的 c++)后,我无法加载任何语音来执行 TTS 转换。我已经尝试了三种方法来初始化所需的声音,但没有成功。

起初我尝试了文档示例中的“register_cmu_us_kal”,但它有很多构建错误,甚至无法编译,因为它找不到一些内部使用的函数。

后来尝试“flite_voice_select”只是在运行时崩溃(然后发现没有语音返回,因为语音列表是空的,我应该填充它吗?init方法不应该这样做吗?)

最后我厌倦了“flite_voice_load”,得到了一些关于哪里出了问题的提示,但它并没有起作用。

使用“flite_voice_load”调用我得到以下结果:

2020-09-08T12:54:55.099821  DEBUG   TTSFliteManager::TTSTranslate()
Error load voice: lang/lex eng not supported in this binary
2020-09-08T12:55:01.588762  DEBUG   TTSFliteManager::TTSTranslate() voice list = 0
2020-09-08T12:55:01.588814  ERROR   TTSFliteManager::TTSTranslate() NO VOICE SELECTED 0

如果我做对了,它会找到 voice.flitevox 文件,但缺少其他东西,语言?词典?我不知道,特别是因为我只使用 FLtie 本身提供的声音,所以我认为它们做得很好。 查看函数签名,我的理解是在加载语音之前我不能使用“flite_add_voice”或“flite_add_lang”,所以我还缺少其他什么指令来实际加载语音文件我的应用程序完成转换了吗?

extern "C" {
cst_voice *register_cmu_us_kal(const char*);
}     
...
bool
TTSFliteManager::TTSTranslate(std::string text, std::string destination)
{
    ADD_LOG_DEBUG << "TTSFliteManager::TTSTranslate()";
    cst_voice *voice;
    flite_init();
//    std::string voiceName = "file:///home/user/download/cmu_us_aew.flitevox";
    std::string voiceName = "http://festvox.org/flite/packed/flite-2.0/voices/cmu_us_rxr.flitevox";

    voice = flite_voice_load(voiceName.c_str());
//    voice = flite_voice_select(voiceName.c_str());
//    voice = register_cmu_us_kal(NULL);
    
    
    ADD_LOG_DEBUG << "TTSFliteManager::TTSTranslate() voice list = " << flite_voice_list ;
    
    if(voice == nullptr)
    {
        ADD_LOG_ERROR << "TTSFliteManager::TTSTranslate() NO VOICE SELECTED " << voice;
        return false;
    }
    ADD_LOG_DEBUG << "TTSFliteManager::TTSTranslate() ready to convert text '" << text.c_str() << "' to destination '" << destination.c_str() << "' with voice '" << voice << "'";
    float secs = flite_text_to_speech(text.c_str(),voice,destination.c_str());
    if (secs == 0)
    {
        ADD_LOG_ERROR << "TTSFliteManager::TTSTranslate() ERROR GENERATED AUDIO FILE IS EMPTY";
        return false;
    }
    return true;
    
}

令我特别困惑和沮丧的是,从命令行它可以完美地工作,所以它实际上就在那里,只是看不到它。以下命令生成了一个完美可听的文件:

flite -voice file:///home/user/download/cmu_us_aew.flitevox -f /home/user/download/flite-2.0.0-release/doc/intro.txt -o intro.wav

与 ALX23z 的废话相反,这里有一个解决方案(也许实际阅读文档并尝试实施解决方案会更有帮助):

extern "C" {
cst_voice *register_cmu_us_rms(const char *voxdir);
void unregister_cmu_us_rms(cst_voice *v);
void usenglish_init(cst_voice *v);
cst_lexicon *cmulex_init(void);
}
    
bool
TTSFliteManager::TTSTranslate(std::string text, std::string destination)
{
    ADD_LOG_DEBUG << "TTSFliteManager::TTSTranslate()";
    cst_voice *voice;
    flite_init();
    std::string voiceName = "/home/user/download/cmu_us_rms.flitevox";
//    std::string voiceName = "http://festvox.org/flite/packed/flite-2.0/voices/cmu_us_rms.flitevox";
    flite_add_lang("eng",usenglish_init,cmulex_init);
    flite_add_lang("usenglish",usenglish_init,cmulex_init);

    voice = flite_voice_load(voiceName.c_str());    
    if(voice == nullptr)
    {
        ADD_LOG_ERROR << "TTSFliteManager::TTSTranslate() NO VOICE SELECTED " << voice;
        return false;
    }
    ADD_LOG_DEBUG << "TTSFliteManager::TTSTranslate() ready to convert text '" << text.c_str() << "' to destination '" << destination.c_str() << "' with voice '" << voice << "'";
    float secs = flite_text_to_speech(text.c_str(),voice,destination.c_str());
    if (secs == 0)
    {
        ADD_LOG_ERROR << "TTSFliteManager::TTSTranslate() ERROR GENERATED AUDIO FILE IS EMPTY";
        return false;
    }
    return true;
}

请注意它与本地文件和远程文件完美配合,只需取消注释第二个“std::string voiceName”(并删除第一个)声明让库从在线存储库下载语音,我去了出于明显的性能原因的本地文件。