BOOL Mecab_load(Mecab *m, const char *dicdir){ int i; int argc = 3; char **argv; if(m == NULL) return FALSE; if(m->mecab != NULL) Mecab_clear(m); if(dicdir == NULL || strlen(dicdir) == 0) return FALSE; argv = (char **) malloc(sizeof(char *) * argc); argv[0] = strdup("mecab"); argv[1] = strdup("-d"); argv[2] = strdup(dicdir); m->mecab = mecab_new(argc, argv); for(i = 0;i < argc;i++) free(argv[i]); free(argv); if(m->mecab == NULL){ fprintf(stderr,"ERROR: Mecab_load() in mecab.cpp: Cannot open %s.\n",dicdir); return FALSE; } return TRUE; }
static void Open_JTalk_clear(Open_JTalk * open_jtalk) { Mecab_clear(&open_jtalk->mecab); NJD_clear(&open_jtalk->njd); JPCommon_clear(&open_jtalk->jpcommon); HTS_Engine_clear(&open_jtalk->engine); }
TextToSpeech::~TextToSpeech() { Mecab_clear(&open_jtalk_.mecab); NJD_clear(&open_jtalk_.njd); JPCommon_clear(&open_jtalk_.jpcommon); HTS_Engine_clear(&open_jtalk_.engine); }
static void cleanup(struct app *app) { Mecab_clear(&app->mecab); NJD_clear(&app->njd); JPCommon_clear(&app->jpcommon); HTS_Engine_clear(&app->engine); play_drain(app->play_h); play_exit(app->play_h); free(app->pcm); }
TextToSpeech::~TextToSpeech() { Mecab_clear(&open_jtalk_.mecab); NJD_clear(&open_jtalk_.njd); JPCommon_clear(&open_jtalk_.jpcommon); HTS_Engine_clear(&open_jtalk_.engine); play_drain(play_h_); play_exit(play_h_); delete[] (pcm_); }
void Mecab_load(Mecab *m, char *dicdir){ const int argc = 3; char *argv[] = {(char *) "mecab", (char *) "-d", dicdir}; if(m->mecab != NULL) Mecab_clear(m); m->mecab = mecab_new(argc,argv); if(m->mecab == NULL){ fprintf(stderr,"ERROR: Mecab_load() in mecab.cpp: Cannot open %s.\n",dicdir); exit(1); } }