无法启动程序。 Pocketsphinx.dll缺少错误

时间:2016-06-23 11:52:07

标签: c++ visual-studio cmusphinx pocketsphinx

我已经设置了在visual studio中使用的其他库目录和lib文件夹。也建立成功,但每当我尝试从Visual Studio执行该程序时,它返回以下错误:

  

程序无法启动,因为您的计算机缺少pocketsphinx.dll。尝试重新安装程序以解决问题。

当我检查目录时,我看到pocketsphinx.dll在那里。

我的代码是(摘自pocketsphinx wikia):

#include <pocketsphinx.h>

#define MODELDIR "C:\Sphinx\pocketsphinx\model" 
int
main(int argc, char *argv[])
{
ps_decoder_t *ps;
cmd_ln_t *config;
FILE *fh;
char const *hyp, *uttid;
int16 buf[512];
int rv;
int32 score;

config = cmd_ln_init(NULL, ps_args(), TRUE,
             "-hmm", MODELDIR "/en-us/en-us",
             "-lm", MODELDIR "/en-us/en-us.lm.bin",
             "-dict", MODELDIR "/en-us/cmudict-en-us.dict",
             NULL);
if (config == NULL) {
    fprintf(stderr, "Failed to create config object, see log for details\n");
    return -1;
}

ps = ps_init(config);
if (ps == NULL) {
    fprintf(stderr, "Failed to create recognizer, see log for details\n");
    return -1;
}

fh = fopen("goforward.raw", "rb");
if (fh == NULL) {
    fprintf(stderr, "Unable to open input file goforward.raw\n");
    return -1;
}

rv = ps_start_utt(ps);

while (!feof(fh)) {
    size_t nsamp;
    nsamp = fread(buf, 2, 512, fh);
    rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
}

rv = ps_end_utt(ps);
hyp = ps_get_hyp(ps, &score);
printf("Recognized: %s\n", hyp);

fclose(fh);
ps_free(ps);
cmd_ln_free_r(config);

return 0;
}

编辑: pocketsphinx.dll位于bin\Debug\x64文件夹中,与pocketsphinx.lib一样。

1 个答案:

答案 0 :(得分:1)

在Visual Studio中的调试器中运行程序时,默认情况下,工作目录参数(项目设置 - >配置属性 - >调试)为$(ProjectDir)。将其更改为$(TargetDir),它应该开始。